// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * * Purpose: Provide functions to setup NIC operation mode * Functions: * s_vSafeResetTx - Rest Tx * card_set_rspinf - Set RSPINF * CARDvUpdateBasicTopRate - Update BasicTopRate * CARDbAddBasicRate - Add to BasicRateSet * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet * card_get_tsf_offset - Calculate TSFOffset * vt6655_get_current_tsf - Read Current NIC TSF counter * card_get_next_tbtt - Calculate Next Beacon TSF counter * CARDvSetFirstNextTBTT - Set NIC Beacon time * CARDvUpdateNextTBTT - Sync. NIC Beacon time * card_radio_power_off - Turn Off NIC Radio Power * * Revision History: * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. * 08-26-2003 Kyle Hsu: Modify the definition type of iobase. * 09-01-2003 Bryan YC Fan: Add vUpdateIFS(). * */ #include "card.h" #include "baseband.h" #include "mac.h" #include "desc.h" #include "rf.h" #include "power.h" /*--------------------- Static Definitions -------------------------*/ #define C_SIFS_A … #define C_SIFS_BG … #define C_EIFS … #define C_SLOT_SHORT … #define C_SLOT_LONG … #define C_CWMIN_A … #define C_CWMIN_B … #define C_CWMAX … #define WAIT_BEACON_TX_DOWN_TMO … /*--------------------- Static Variables --------------------------*/ static const unsigned short rx_bcn_tsf_off[MAX_RATE] = …; /*--------------------- Static Functions --------------------------*/ static void vt6655_mac_set_bb_type(void __iomem *iobase, u32 mask) { … } /*--------------------- Export Functions --------------------------*/ /* * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode. * * Parameters: * In: * wRate - Tx Rate * byPktType - Tx Packet type * Out: * tx_rate - pointer to RSPINF TxRate field * rsv_time - pointer to RSPINF RsvTime field * * Return Value: none */ static void calculate_ofdmr_parameter(unsigned char rate, u8 bb_type, unsigned char *tx_rate, unsigned char *rsv_time) { … } /*--------------------- Export Functions --------------------------*/ /* * Description: Update IFS * * Parameters: * In: * priv - The adapter to be set * Out: * none * * Return Value: None. */ bool card_set_phy_parameter(struct vnt_private *priv, u8 bb_type) { … } /* * Description: Sync. TSF counter to BSS * Get TSF offset and write to HW * * Parameters: * In: * priv - The adapter to be sync. * rx_rate - data rate of receive beacon * bss_timestamp - Rx BCN's TSF * qwLocalTSF - Local TSF * Out: * none * * Return Value: none */ bool card_update_tsf(struct vnt_private *priv, unsigned char rx_rate, u64 bss_timestamp) { … } /* * Description: Set NIC TSF counter for first Beacon time * Get NEXTTBTT from adjusted TSF and Beacon Interval * * Parameters: * In: * priv - The adapter to be set. * beacon_interval - Beacon Interval * Out: * none * * Return Value: true if succeed; otherwise false */ bool card_set_beacon_period(struct vnt_private *priv, unsigned short beacon_interval) { … } /* * Description: Turn off Radio power * * Parameters: * In: * priv - The adapter to be turned off * Out: * none * */ void card_radio_power_off(struct vnt_private *priv) { … } void card_safe_reset_tx(struct vnt_private *priv) { … } /* * Description: * Reset Rx * * Parameters: * In: * priv - Pointer to the adapter * Out: * none * * Return Value: none */ void CARDvSafeResetRx(struct vnt_private *priv) { … } /* * Description: Get response Control frame rate in CCK mode * * Parameters: * In: * priv - The adapter to be set * wRateIdx - Receiving data rate * Out: * none * * Return Value: response Control frame rate */ static unsigned short CARDwGetCCKControlRate(struct vnt_private *priv, unsigned short wRateIdx) { … } /* * Description: Get response Control frame rate in OFDM mode * * Parameters: * In: * priv - The adapter to be set * wRateIdx - Receiving data rate * Out: * none * * Return Value: response Control frame rate */ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *priv, unsigned short wRateIdx) { … } /* * Description: Set RSPINF * * Parameters: * In: * priv - The adapter to be set * Out: * none * * Return Value: None. */ void card_set_rspinf(struct vnt_private *priv, u8 bb_type) { … } void CARDvUpdateBasicTopRate(struct vnt_private *priv) { … } bool CARDbIsOFDMinBasicRate(struct vnt_private *priv) { … } unsigned char card_get_pkt_type(struct vnt_private *priv) { … } /* * Description: Calculate TSF offset of two TSF input * Get TSF Offset from RxBCN's TSF and local TSF * * Parameters: * In: * priv - The adapter to be sync. * qwTSF1 - Rx BCN's TSF * qwTSF2 - Local TSF * Out: * none * * Return Value: TSF Offset value */ u64 card_get_tsf_offset(unsigned char rx_rate, u64 qwTSF1, u64 qwTSF2) { … } /* * Description: Read NIC TSF counter * Get local TSF counter * * Parameters: * In: * priv - The adapter to be read * Out: * none * * Return Value: Current TSF counter */ u64 vt6655_get_current_tsf(struct vnt_private *priv) { … } /* * Description: Read NIC TSF counter * Get NEXTTBTT from adjusted TSF and Beacon Interval * * Parameters: * In: * qwTSF - Current TSF counter * wbeaconInterval - Beacon Interval * Out: * qwCurrTSF - Current TSF counter * * Return Value: TSF value of next Beacon */ u64 card_get_next_tbtt(u64 qwTSF, unsigned short beacon_interval) { … } /* * Description: Set NIC TSF counter for first Beacon time * Get NEXTTBTT from adjusted TSF and Beacon Interval * * Parameters: * In: * iobase - IO Base * beacon_interval - Beacon Interval * Out: * none * * Return Value: none */ void CARDvSetFirstNextTBTT(struct vnt_private *priv, unsigned short beacon_interval) { … } /* * Description: Sync NIC TSF counter for Beacon time * Get NEXTTBTT and write to HW * * Parameters: * In: * priv - The adapter to be set * qwTSF - Current TSF counter * beacon_interval - Beacon Interval * Out: * none * * Return Value: none */ void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 qwTSF, unsigned short beacon_interval) { … }