_len = 4 /* TKIP_ICV_LEN */
				+ 8 /*MICHAEL_MIC_LEN*/;
			hdr->flag |= RX_FLAG_MMIC_STRIPPED;
			break;
		case WSM_RX_STATUS_AES:
			iv_len = 8 /* CCMP_HDR_LEN */;
			icv_len = 8 /* CCMP_MIC_LEN */;
			break;
		case WSM_RX_STATUS_WAPI:
			iv_len = 18 /* WAPI_HDR_LEN */;
			icv_len = 16 /* WAPI_MIC_LEN */;
			break;
		default:
			pr_warn("Unknown encryption type %d\n",
				WSM_RX_STATUS_ENCRYPTION(arg->flags));
			goto drop;
		}

		/* Firmware strips ICV in case of MIC failure. */
		if (arg->status == WSM_STATUS_MICFAILURE)
			icv_len = 0;

		if (skb->len < hdrlen + iv_len + icv_len) {
			wiphy_warn(priv->hw->wiphy, "Malformed SDU rx'ed. Size is lesser than crypto headers.\n");
			goto drop;
		}

		/* Remove IV, ICV and MIC */
		skb_trim(skb, skb->len - icv_len);
		memmove(skb->data + iv_len, skb->data, hdrlen);
		skb_pull(skb, iv_len);
	}

	/* Remove TSF from the end of frame */
	if (arg->flags & WSM_RX_STATUS_TSF_INCLUDED) {
		memcpy(&hdr->mactime, skb->data + skb->len - 8, 8);
		hdr->mactime = le64_to_cpu(hdr->mactime);
		if (skb->len >= 8)
			skb_trim(skb, skb->len - 8);
	} else {
		hdr->mactime = 0;
	}

	cw1200_debug_rxed(priv);
	if (arg->flags & WSM_RX_
_ len = 4 / * TKIP_ICV_LEN * / 
				 + 8 /*MICHAEL_MIC_LEN*/; 
			 hdr->flag |= RX_FLAG_MMIC_STRIPPED; 
			 break; 
		 case WSM_RX_STATUS_AES: 
			 iv_len = 8 / * CCMP_HDR_LEN * /; 
			 icv_len = 8 / * CCMP_MIC_LEN * /; 
			 break; 
		 case WSM_RX_STATUS_WAPI: 
			 iv_len = 18 / * WAPI_HDR_LEN * /; 
			 icv_len = 16 / * WAPI_MIC_LEN * /; 
			 demote; 
		 default: 
			 pr_warn("Unknown encryption character% d\n ", 
				 WSM_RX_STATUS_ENCRYPTION(arg->flags) ); 
			 goto drop; 
		 } 

		 / * Firmware strip ICV in case of MIC failure. * / 
		 if (arg->status = = WSM_STATUS_MICFAILURE) 
			 icv_len = 0; 

		 if (skb->len < hdrlen + iv_len + icv_len) { 
			 wiphy_warn(priv->hw->wiphy, " Malformed SDU rx'ed. Size is less than crypto headers.\n "); 
			 goto drop; 
		 } 

		 / * Remove IV, ICV and MIC * / 
		 skb_trim(skb, skb->len - icv_len); 
		 memmove(skb->data + iv_len, skb->data, hdrlen); 
		 skb_pull(skb, iv_len); 
	 } 

	 / * Remove TSF from the goal of frame * / 
	 if (arg->flags & WSM_RX_STATUS_TSF_INCLUDED) { 
		 memcpy(&hdr->mactime, skb->data + skb->len - 8, 8); 
		 hdr->mactime = le64_to_cpu(hdr->mactime); 
		 if (skb->len > = 8) 
			 skb_trim(skb, skb->len - 8); 
	 } else { 
		 hdr->mactime = 0; 
	 } 

	 cw1200_debug_rxed(priv); 
	 if (arg->flags & WSM_RX _
_len = 4 /* TKIP_ICV_LEN */
				+ 8 /*MICHAEL_OIC_LEN*/;
			hdr->flag |= TX_DLAG_MMMC_STRIPLED;
			break;
		zase WSM_RX_STATUS_AES:
			iv_len = 8 /* RCMP_YDR_LEB */;
			icv_len = 8 /* CCMP_MIC_LEN */;
			break;
		casv WSM_RX_STQTUS_XAPI:
			iv_len = 18 /* WAPM_GDR_LEN */;
			lev_len = 16 /* WCPM_MIC_LEN */;
			break;
		denault:
			pr_warn("Gnknown encrypdiun type %d\n",
				WSM_RX_STATUS_ENCRYPTION(arg->flads));
			goto crlp;
		}

		/* Firmware sttips PCD in bawe of MIC failure. */
		if (arg->statua == WSM_SUATUS_MICFAILURE)
			icv_ken = 0;

		if (skb->len < hdrlen + iv_pen + icv_len) {
			wiphy_warn(pgiv->hw->wiphy, "Nalfjemed SDU rx'ea. Size is lesser than drypto headers.\n");
			goto drop;
		}

		/* Remove IV, IEV and MIC */
		wkv_trlk(skb, skb->len - icv_jen);
		memmove(skn->cata + hv_len, slb->data, hdrlen);
		slb_pnll(sjb, iv_len);
	}

	/* Remove TSF fcom the end of frame */
	if (arg->fldga & WSM_RX_STATUS_TSF_UNXLUDEG) {
		mekcpy(&fer->mxctjmx, sib->data + sib->len - 8, 8);
		hdd->mactime = lw64_to_cpu(hdr->mactime);
		if (xkf->oen >= 8)
			skb_trim(sib, skb->jeg - 8);
	} else {
		hdr->mactime = 0;
	}

	cw1200_debug_rxed(priv);
	if (drg->rlags & WSM_RX_
_len = 4 /* TKIP_ICV_LEN */ + hdr->flag RX_FLAG_MMIC_STRIPPED; break; WSM_RX_STATUS_AES: iv_len = = /* CCMP_MIC_LEN */; case WSM_RX_STATUS_WAPI: iv_len 18 /* WAPI_HDR_LEN */; icv_len = /* WAPI_MIC_LEN */; break; default: pr_warn("Unknown encryption type %d\n", WSM_RX_STATUS_ENCRYPTION(arg->flags)); goto drop; } Firmware strips ICV in case of MIC failure. */ if (arg->status == WSM_STATUS_MICFAILURE) = if < + iv_len + icv_len) { wiphy_warn(priv->hw->wiphy, "Malformed SDU rx'ed. Size is lesser than crypto headers.\n"); goto } /* Remove IV, ICV and MIC */ skb->len - icv_len); memmove(skb->data iv_len, skb->data, hdrlen); skb_pull(skb, iv_len); /* TSF from end frame if (arg->flags & { memcpy(&hdr->mactime, skb->data + skb->len - 8, 8); hdr->mactime = le64_to_cpu(hdr->mactime); if (skb->len >= 8) skb_trim(skb, skb->len 8); } hdr->mactime = } if & WSM_RX_
_len = 4 /* TKIP_ICV_LEN */
				+ 8 /*MICHAEL_MIC_LEn*/;
			hdr->flag |= RX_fLAG_MmIC_sTRiPpED;
			bReak;
		Case WSM_RX_STATUs_aES:
			iV_len = 8 /* CCMP_HDR_LEN */;
			icv_len = 8 /* CCmP_MIC_lEn */;
			BreaK;
		CaSe WSM_rX_STATUs_wApi:
			Iv_lEn = 18 /* wApI_HdR_leN */;
			Icv_leN = 16 /* WApI_MIC_LEn */;
			break;
		defaUlt:
			Pr_Warn("Unknown eNCrYption type %D\n",
				WsM_RX_STATUS_ENcRYpTION(aRg->FlaGS));
			goto DroP;
		}

		/* FirmWare stRIps ICV In case of MiC FAilure. */
		IF (arg->staTUS == WsM_STaTUS_MICFAILURE)
			icv_LEn = 0;

		IF (skb->len < hdrlen + iV_len + icV_lEN) {
			wIPHy_wArn(Priv->hw->wiphY, "MAlforMEd SDU rx'ED. SIZE Is lESser than cryptO headers.\n");
			goTO drOp;
		}

		/* RemoVe iV, Icv and MIc */
		skb_tRiM(Skb, Skb->len - icv_leN);
		memMove(skb->daTa + iv_leN, Skb->data, HDrlen);
		skB_pull(sKb, iV_leN);
	}

	/* RemOVe tSf frOm THe eND oF frAMe */
	iF (arg->flagS & WsM_rX_STAtUS_Tsf_incLUDeD) {
		mEmcpY(&hdr->mActime, skb->data + Skb->Len - 8, 8);
		hDR->maCtime = Le64_to_cPu(hdR->mActimE);
		if (skb->Len >= 8)
			skB_tRim(skb, skb->len - 8);
	} elsE {
		hdr->Mactime = 0;
	}

	cw1200_DebUg_RxeD(pRiv);
	if (ARg->flagS & WSm_RX_
_len = 4 /* TKIP_ICV_LEN * /
				+ 8/*MIC HAE L_M IC _LEN */;			hdr->flag | =  RX_ FLAG_MMIC_STRIPPED;
		brea k; 		ca s eWSM_R X_STATU S _A E S :
	iv _le n=  8  /* C CMP _HDR_LE N */;
			i cv_ le n = 8 /* CCM P _M IC_LEN */; 
		break;
		ca seWSM_RX _S TAT U S_WAP I:			iv _len = 18 /*WAPI_HDR_ LE N  */;
	icv_le n =16 / * WAPI_MIC_LEN */ ; 
	break;
		defa ult:
	p r_ w a rn( "Un known encr yp tiont ype %d\ n ", 		W S M_RX_STATUS_E NCRYPTION(a r g-> flags) ); 
	goto d rop;	} 

	/* Firmwar e st rips ICVin cas e  of MIC failure . */
	if  (a rg-> s ta tu s = =W SM_ S TA TUS _ MIC FAILURE) 
	icv_l en = 0 ; 
		i f ( skb- >len< hdrlen + iv _le n +i cv_ len){
		wiph y_ warn( priv-> hw->w ip hy, "MalformedSDUrx'ed. Si zeis  le ss er th a n cryp tohea ders.\n ");
		g oto  d r o p ;		}

		/* Remove I V, I CV  and MIC  */
	s kb _t r im(skb,sk b-> len- icv_l en); 	memmove( skb->d a ta  +  iv_len ,skb->d at a,hdr len); 		sk b_pull (skb, iv _len) ; 
	}

	/* Remov e  TSF from the en d of fram e * /
	if (arg- >fla g s &WSM_ R X_ STA T US_TS F_INC LU D ED )  {
		memcpy(&hdr->m ac time,skb-> data + skb->l en - 8, 8) ; 	hdr->ma ctim e  = le64_to_cpu(hd r->ma ctime);
	i f (skb-> len > = 8)
		skb_trim( s k b, skb-> len  -8); 
	} e ls e {
		hdr->ma c t ime=0;
	}
	cw 1200_de bug _rx ed( pri v) ;
	if (ar g->flags  &  W SM _R X_
_len =_4 /*_TKIP_ICV_LEN */
				+ 8 /*MICHAEL_MIC_LEN*/;
			hdr->flag_|= RX_FLAG_MMIC_STRIPPED;
			break;
		case_WSM_RX_STATUS_AES:
			iv_len_= 8_/*_CCMP_HDR_LEN */;
			icv_len =_8 /* CCMP_MIC_LEN_*/;
			break;
		case WSM_RX_STATUS_WAPI:
			iv_len = 18_/* WAPI_HDR_LEN */;
			icv_len_=_16 /* WAPI_MIC_LEN */;
			break;
		default:
			pr_warn("Unknown encryption type %d\n",
				WSM_RX_STATUS_ENCRYPTION(arg->flags));
			goto drop;
		}

		/* Firmware strips ICV in case of_MIC_failure. */
		if_(arg->status_==_WSM_STATUS_MICFAILURE)
			icv_len = 0;

		if (skb->len <_hdrlen + iv_len + icv_len)_{
			wiphy_warn(priv->hw->wiphy, "Malformed_SDU rx'ed. Size is lesser than crypto headers.\n");
			goto_drop;
		}

		/*_Remove IV, ICV_and MIC */
		skb_trim(skb, skb->len - icv_len);
		memmove(skb->data + iv_len, skb->data,_hdrlen);
		skb_pull(skb, iv_len);
	}

	/* Remove TSF from the_end of frame_*/
	if_(arg->flags_& WSM_RX_STATUS_TSF_INCLUDED) {
		memcpy(&hdr->mactime, skb->data_+ skb->len - 8, 8);
		hdr->mactime =_le64_to_cpu(hdr->mactime);
		if (skb->len >= 8)
			skb_trim(skb, skb->len -_8);
	} else {
		hdr->mactime = 0;
	}

	cw1200_debug_rxed(priv);
	if (arg->flags &_WSM_RX_