Commit e829d65e authored by Larry Finger's avatar Larry Finger

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: default avatarLarry Finger <Larry.Finger@lwfinger.net>
parent 1800925f
...@@ -2243,13 +2243,10 @@ void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stat ...@@ -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); struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
if (stats->bIsAMPDU && !stats->bFirstMPDU) { if (stats->bIsAMPDU && !stats->bFirstMPDU)
stats->mac_time[0] = priv->LastRxDescTSFLow; stats->mac_time = priv->LastRxDescTSF;
stats->mac_time[1] = priv->LastRxDescTSFHigh; else
} else { priv->LastRxDescTSF = stats->mac_time;
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 rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index )
......
...@@ -642,8 +642,7 @@ struct r8192_priv { ...@@ -642,8 +642,7 @@ struct r8192_priv {
int rxringcount; int rxringcount;
u16 rxbuffersize; u16 rxbuffersize;
u32 LastRxDescTSFHigh; u64 LastRxDescTSF;
u32 LastRxDescTSFLow;
u16 EarlyRxThreshold; u16 EarlyRxThreshold;
u32 ReceiveConfig; u32 ReceiveConfig;
......
...@@ -78,36 +78,33 @@ void rtl8192_hw_wakeup_wq(void *data) ...@@ -78,36 +78,33 @@ void rtl8192_hw_wakeup_wq(void *data)
#define MIN_SLEEP_TIME 50 #define MIN_SLEEP_TIME 50
#define MAX_SLEEP_TIME 10000 #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); struct r8192_priv *priv = rtllib_priv(dev);
u32 rb = jiffies; u32 tmp;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&priv->ps_lock,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)) if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) {
||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) {
spin_unlock_irqrestore(&priv->ps_lock,flags); 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; return;
} }
if (((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) {
((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| printk(KERN_INFO "========>too long to sleep:%lld > %ld\n",
((tl<rb)&&(tl<MSECS(69))&&((tl+0xffffffff-rb)>MSECS(MAX_SLEEP_TIME)))) { time - jiffies, MSECS(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); spin_unlock_irqrestore(&priv->ps_lock,flags);
return; return;
} }
{ tmp = time - jiffies;
u32 tmp = (tl>rb)?(tl-rb):(rb-tl);
queue_delayed_work_rsl(priv->rtllib->wq, 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, queue_delayed_work_rsl(priv->rtllib->wq,
(void *)&priv->rtllib->hw_sleep_wq,0); (void *)&priv->rtllib->hw_sleep_wq,0);
spin_unlock_irqrestore(&priv->ps_lock,flags); spin_unlock_irqrestore(&priv->ps_lock,flags);
......
...@@ -33,7 +33,7 @@ struct net_device; ...@@ -33,7 +33,7 @@ struct net_device;
#define INIT_DEFAULT_CHAN 1 #define INIT_DEFAULT_CHAN 1
void rtl8192_hw_wakeup(struct net_device *dev); 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_wq(struct net_device *dev);
void rtllib_ips_leave(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev);
void IPSLeave_wq (void *data); void IPSLeave_wq (void *data);
......
...@@ -993,7 +993,7 @@ struct ieee_ibss_seq { ...@@ -993,7 +993,7 @@ struct ieee_ibss_seq {
* any adverse affects. */ * any adverse affects. */
struct rtllib_rx_stats { struct rtllib_rx_stats {
#if 1 #if 1
u32 mac_time[2]; u64 mac_time;
s8 rssi; s8 rssi;
u8 signal; u8 signal;
u8 noise; u8 noise;
...@@ -1679,7 +1679,7 @@ struct rtllib_network { ...@@ -1679,7 +1679,7 @@ struct rtllib_network {
struct rtllib_tim_parameters tim; struct rtllib_tim_parameters tim;
u8 dtim_period; u8 dtim_period;
u8 dtim_data; u8 dtim_data;
u32 last_dtim_sta_time[2]; u64 last_dtim_sta_time;
u8 wmm_info; u8 wmm_info;
struct rtllib_wmm_ac_param wmm_param[4]; struct rtllib_wmm_ac_param wmm_param[4];
...@@ -2305,8 +2305,7 @@ struct rtllib_device { ...@@ -2305,8 +2305,7 @@ struct rtllib_device {
int ps_timeout; int ps_timeout;
int ps_period; int ps_period;
struct tasklet_struct ps_task; struct tasklet_struct ps_task;
u32 ps_th; u64 ps_time;
u32 ps_tl;
bool polling; bool polling;
short raw_tx; short raw_tx;
...@@ -2498,7 +2497,7 @@ struct rtllib_device { ...@@ -2498,7 +2497,7 @@ struct rtllib_device {
/* power save mode related */ /* power save mode related */
void (*sta_wake_up) (struct net_device *dev); 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); 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_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); int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network);
......
...@@ -1867,8 +1867,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, ...@@ -1867,8 +1867,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
network->dtim_period = info_element->data[1]; network->dtim_period = info_element->data[1];
if (ieee->state != RTLLIB_LINKED) if (ieee->state != RTLLIB_LINKED)
break; break;
network->last_dtim_sta_time[0] = jiffies; network->last_dtim_sta_time = jiffies;
network->last_dtim_sta_time[1] = stats->mac_time[1];
network->dtim_data = RTLLIB_DTIM_VALID; network->dtim_data = RTLLIB_DTIM_VALID;
...@@ -2466,8 +2465,7 @@ static inline void update_network(struct rtllib_network *dst, ...@@ -2466,8 +2465,7 @@ static inline void update_network(struct rtllib_network *dst,
dst->atim_window = src->atim_window; dst->atim_window = src->atim_window;
dst->dtim_period = src->dtim_period; dst->dtim_period = src->dtim_period;
dst->dtim_data = src->dtim_data; dst->dtim_data = src->dtim_data;
dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; dst->last_dtim_sta_time = src->last_dtim_sta_time;
dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters));
dst->bssht.bdSupportHT = src->bssht.bdSupportHT; dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
......
...@@ -2037,7 +2037,7 @@ void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) ...@@ -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; int timeout = ieee->ps_timeout;
u8 dtim; u8 dtim;
...@@ -2074,7 +2074,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) ...@@ -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)) (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
return 0; return 0;
if (time_l){ if (time){
if (ieee->bAwakePktSent == true) { if (ieee->bAwakePktSent == true) {
pPSC->LPSAwakeIntvl = 1; pPSC->LPSAwakeIntvl = 1;
} else { } else {
...@@ -2107,17 +2107,11 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) ...@@ -2107,17 +2107,11 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l)
LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; 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); + 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; return 1;
...@@ -2126,7 +2120,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) ...@@ -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) inline void rtllib_sta_ps(struct rtllib_device *ieee)
{ {
u32 th,tl; u64 time;
short sleep; short sleep;
unsigned long flags,flags2; unsigned long flags,flags2;
...@@ -2146,7 +2140,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ...@@ -2146,7 +2140,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee)
spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); 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 */ /* 2 wake, 1 sleep, 0 do nothing */
if (sleep == 0) if (sleep == 0)
{ {
...@@ -2154,7 +2148,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ...@@ -2154,7 +2148,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee)
} }
if (sleep == 1){ if (sleep == 1){
if (ieee->sta_sleep == LPS_IS_SLEEP){ 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){ else if (ieee->sta_sleep == LPS_IS_WAKE){
...@@ -2164,8 +2158,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ...@@ -2164,8 +2158,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee)
ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND;
ieee->ack_tx_to_ieee = 1; ieee->ack_tx_to_ieee = 1;
rtllib_sta_ps_send_null_frame(ieee,1); rtllib_sta_ps_send_null_frame(ieee,1);
ieee->ps_th = th; ieee->ps_time = time;
ieee->ps_tl = tl;
} }
spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
...@@ -2241,7 +2234,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) ...@@ -2241,7 +2234,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success)
/* Null frame with PS bit set */ /* Null frame with PS bit set */
if (success){ if (success){
ieee->sta_sleep = LPS_IS_SLEEP; 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 /* 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 * has not RXed so we can't assume the AP believe us awake
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment