diff options
Diffstat (limited to 'drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c')
| -rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 115 | 
1 files changed, 63 insertions, 52 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 28a6ce3bc23..50303e1adff 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -171,7 +171,6 @@ static void _rtl92c_write_fw(struct ieee80211_hw *hw,  static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw)  {  	struct rtl_priv *rtlpriv = rtl_priv(hw); -	int err = -EIO;  	u32 counter = 0;  	u32 value32; @@ -184,7 +183,7 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw)  		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,  			 ("chksum report faill ! REG_MCUFWDL:0x%08x .\n",  			  value32)); -		goto exit; +		return -EIO;  	}  	RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, @@ -204,8 +203,7 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw)  				 ("Polling FW ready success!!"  				 " REG_MCUFWDL:0x%08x .\n",  				 value32)); -			err = 0; -			goto exit; +			return 0;  		}  		mdelay(FW_8192C_POLLING_DELAY); @@ -214,9 +212,7 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw)  	RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,  		 ("Polling FW ready fail!! REG_MCUFWDL:0x%08x .\n", value32)); - -exit: -	return err; +	return -EIO;  }  int rtl92c_download_fw(struct ieee80211_hw *hw) @@ -226,32 +222,16 @@ int rtl92c_download_fw(struct ieee80211_hw *hw)  	struct rtl92c_firmware_header *pfwheader;  	u8 *pfwdata;  	u32 fwsize; -	int err;  	enum version_8192c version = rtlhal->version; -	const struct firmware *firmware; -	printk(KERN_INFO "rtl8192cu: Loading firmware file %s\n", +	printk(KERN_INFO "rtl8192c: Loading firmware file %s\n",  	       rtlpriv->cfg->fw_name); -	err = request_firmware(&firmware, rtlpriv->cfg->fw_name, -			       rtlpriv->io.dev); -	if (err) { -		printk(KERN_ERR "rtl8192cu: Firmware loading failed\n"); -		return 1; -	} - -	if (firmware->size > 0x4000) { -		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, -			 ("Firmware is too big!\n")); -		release_firmware(firmware); +	if (!rtlhal->pfirmware)  		return 1; -	} - -	memcpy(rtlhal->pfirmware, firmware->data, firmware->size); -	fwsize = firmware->size; -	release_firmware(firmware);  	pfwheader = (struct rtl92c_firmware_header *)rtlhal->pfirmware;  	pfwdata = (u8 *) rtlhal->pfirmware; +	fwsize = rtlhal->fwsize;  	if (IS_FW_HEADER_EXIST(pfwheader)) {  		RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, @@ -267,8 +247,7 @@ int rtl92c_download_fw(struct ieee80211_hw *hw)  	_rtl92c_write_fw(hw, version, pfwdata, fwsize);  	_rtl92c_enable_fw_download(hw, false); -	err = _rtl92c_fw_free_to_go(hw); -	if (err) { +	if (_rtl92c_fw_free_to_go(hw)) {  		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,  			 ("Firmware is not ready to run!\n"));  	} else { @@ -300,10 +279,9 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,  	struct rtl_priv *rtlpriv = rtl_priv(hw);  	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));  	u8 boxnum; -	u16 box_reg, box_extreg; +	u16 box_reg = 0, box_extreg = 0;  	u8 u1b_tmp;  	bool isfw_read = false; -	u8 buf_index = 0;  	bool bwrite_sucess = false;  	u8 wait_h2c_limmit = 100;  	u8 wait_writeh2c_limmit = 100; @@ -414,7 +392,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,  		case 1:  			boxcontent[0] &= ~(BIT(7));  			memcpy((u8 *) (boxcontent) + 1, -			       p_cmdbuffer + buf_index, 1); +			       p_cmdbuffer, 1);  			for (idx = 0; idx < 4; idx++) {  				rtl_write_byte(rtlpriv, box_reg + idx, @@ -424,7 +402,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,  		case 2:  			boxcontent[0] &= ~(BIT(7));  			memcpy((u8 *) (boxcontent) + 1, -			       p_cmdbuffer + buf_index, 2); +			       p_cmdbuffer, 2);  			for (idx = 0; idx < 4; idx++) {  				rtl_write_byte(rtlpriv, box_reg + idx, @@ -434,7 +412,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,  		case 3:  			boxcontent[0] &= ~(BIT(7));  			memcpy((u8 *) (boxcontent) + 1, -			       p_cmdbuffer + buf_index, 3); +			       p_cmdbuffer, 3);  			for (idx = 0; idx < 4; idx++) {  				rtl_write_byte(rtlpriv, box_reg + idx, @@ -444,9 +422,9 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,  		case 4:  			boxcontent[0] |= (BIT(7));  			memcpy((u8 *) (boxextcontent), -			       p_cmdbuffer + buf_index, 2); +			       p_cmdbuffer, 2);  			memcpy((u8 *) (boxcontent) + 1, -			       p_cmdbuffer + buf_index + 2, 2); +			       p_cmdbuffer + 2, 2);  			for (idx = 0; idx < 2; idx++) {  				rtl_write_byte(rtlpriv, box_extreg + idx, @@ -461,9 +439,9 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,  		case 5:  			boxcontent[0] |= (BIT(7));  			memcpy((u8 *) (boxextcontent), -			       p_cmdbuffer + buf_index, 2); +			       p_cmdbuffer, 2);  			memcpy((u8 *) (boxcontent) + 1, -			       p_cmdbuffer + buf_index + 2, 3); +			       p_cmdbuffer + 2, 3);  			for (idx = 0; idx < 2; idx++) {  				rtl_write_byte(rtlpriv, box_extreg + idx, @@ -561,6 +539,39 @@ void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)  }  EXPORT_SYMBOL(rtl92c_set_fw_pwrmode_cmd); +static bool _rtl92c_cmd_send_packet(struct ieee80211_hw *hw, +				struct sk_buff *skb) +{ +	struct rtl_priv *rtlpriv = rtl_priv(hw); +	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); +	struct rtl8192_tx_ring *ring; +	struct rtl_tx_desc *pdesc; +	u8 own; +	unsigned long flags; +	struct sk_buff *pskb = NULL; + +	ring = &rtlpci->tx_ring[BEACON_QUEUE]; + +	pskb = __skb_dequeue(&ring->queue); +	if (pskb) +		kfree_skb(pskb); + +	spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); + +	pdesc = &ring->desc[0]; +	own = (u8) rtlpriv->cfg->ops->get_desc((u8 *) pdesc, true, HW_DESC_OWN); + +	rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *) pdesc, 1, 1, skb); + +	__skb_queue_tail(&ring->queue, skb); + +	spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); + +	rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE); + +	return true; +} +  #define BEACON_PG		0 /*->1*/  #define PSPOLL_PG		2  #define NULL_PG			3 @@ -678,7 +689,7 @@ static u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = {  	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  }; -void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished) +void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished)  {  	struct rtl_priv *rtlpriv = rtl_priv(hw);  	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); @@ -687,12 +698,12 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)  	u32 totalpacketlen;  	bool rtstatus;  	u8 u1RsvdPageLoc[3] = {0}; -	bool b_dlok = false; +	bool dlok = false;  	u8 *beacon; -	u8 *p_pspoll; +	u8 *pspoll;  	u8 *nullfunc; -	u8 *p_probersp; +	u8 *probersp;  	/*---------------------------------------------------------  				(1) beacon  	---------------------------------------------------------*/ @@ -703,10 +714,10 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)  	/*-------------------------------------------------------  				(2) ps-poll  	--------------------------------------------------------*/ -	p_pspoll = &reserved_page_packet[PSPOLL_PG * 128]; -	SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000)); -	SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid); -	SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr); +	pspoll = &reserved_page_packet[PSPOLL_PG * 128]; +	SET_80211_PS_POLL_AID(pspoll, (mac->assoc_id | 0xc000)); +	SET_80211_PS_POLL_BSSID(pspoll, mac->bssid); +	SET_80211_PS_POLL_TA(pspoll, mac->mac_addr);  	SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1RsvdPageLoc, PSPOLL_PG); @@ -723,10 +734,10 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)  	/*---------------------------------------------------------  				(4) probe response  	----------------------------------------------------------*/ -	p_probersp = &reserved_page_packet[PROBERSP_PG * 128]; -	SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid); -	SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr); -	SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid); +	probersp = &reserved_page_packet[PROBERSP_PG * 128]; +	SET_80211_HDR_ADDRESS1(probersp, mac->bssid); +	SET_80211_HDR_ADDRESS2(probersp, mac->mac_addr); +	SET_80211_HDR_ADDRESS3(probersp, mac->bssid);  	SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG); @@ -744,12 +755,12 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)  	memcpy((u8 *) skb_put(skb, totalpacketlen),  	       &reserved_page_packet, totalpacketlen); -	rtstatus = rtlpriv->cfg->ops->cmd_send_packet(hw, skb); +	rtstatus = _rtl92c_cmd_send_packet(hw, skb);  	if (rtstatus) -		b_dlok = true; +		dlok = true; -	if (b_dlok) { +	if (dlok) {  		RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,  			 ("Set RSVD page location to Fw.\n"));  		RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,  |