Esempio n. 1
0
void
Mds_Tx(struct wbsoft_priv * adapter)
{
	phw_data_t	pHwData = &adapter->sHwData;
	PMDS		pMds = &adapter->Mds;
	DESCRIPTOR	TxDes;
	PDESCRIPTOR	pTxDes = &TxDes;
	u8		*XmitBufAddress;
	u16		XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold;
	u8		FillIndex, TxDesIndex, FragmentCount, FillCount;
	unsigned char	BufferFilled = false, MICAdd = 0;


	if (pMds->TxPause)
		return;
	if (!hal_driver_init_OK(pHwData))
		return;

	//Only one thread can be run here
	if (!atomic_inc_return(&pMds->TxThreadCount) == 1)
		goto cleanup;

	// Start to fill the data
	do {
		FillIndex = pMds->TxFillIndex;
		if (pMds->TxOwner[FillIndex]) { // Is owned by software 0:Yes 1:No
#ifdef _PE_TX_DUMP_
			WBDEBUG(("[Mds_Tx] Tx Owner is H/W.\n"));
#endif
			break;
		}

		XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex); //Get buffer
		XmitBufSize = 0;
		FillCount = 0;
		do {
			PacketSize = adapter->sMlmeFrame.len;
			if (!PacketSize)
				break;

			//For Check the buffer resource
			FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD;
			//931130.5.b
			FragmentCount = PacketSize/FragmentThreshold + 1;
			stmp = PacketSize + FragmentCount*32 + 8;//931130.5.c 8:MIC
			if ((XmitBufSize + stmp) >= MAX_USB_TX_BUFFER) {
				printk("[Mds_Tx] Excess max tx buffer.\n");
				break; // buffer is not enough
			}


			//
			// Start transmitting
			//
			BufferFilled = true;

			/* Leaves first u8 intact */
			memset((u8 *)pTxDes + 1, 0, sizeof(DESCRIPTOR) - 1);

			TxDesIndex = pMds->TxDesIndex;//Get the current ID
			pTxDes->Descriptor_ID = TxDesIndex;
			pMds->TxDesFrom[ TxDesIndex ] = 2;//Storing the information of source comming from
			pMds->TxDesIndex++;
			pMds->TxDesIndex %= MAX_USB_TX_DESCRIPTOR;

			MLME_GetNextPacket( adapter, pTxDes );

			// Copy header. 8byte USB + 24byte 802.11Hdr. Set TxRate, Preamble type
			Mds_HeaderCopy( adapter, pTxDes, XmitBufAddress );

			// For speed up Key setting
			if (pTxDes->EapFix) {
#ifdef _PE_TX_DUMP_
				WBDEBUG(("35: EPA 4th frame detected. Size = %d\n", PacketSize));
#endif
				pHwData->IsKeyPreSet = 1;
			}

			// Copy (fragment) frame body, and set USB, 802.11 hdr flag
			CurrentSize = Mds_BodyCopy(adapter, pTxDes, XmitBufAddress);

			// Set RTS/CTS and Normal duration field into buffer
			Mds_DurationSet(adapter, pTxDes, XmitBufAddress);

			//
			// Calculation MIC from buffer which maybe fragment, then fill into temporary address 8 byte
			// 931130.5.e
			if (MICAdd)
				Mds_MicFill( adapter, pTxDes, XmitBufAddress );

			//Shift to the next address
			XmitBufSize += CurrentSize;
			XmitBufAddress += CurrentSize;

#ifdef _IBSS_BEACON_SEQ_STICK_
			if ((XmitBufAddress[ DOT_11_DA_OFFSET+8 ] & 0xfc) != MAC_SUBTYPE_MNGMNT_PROBE_REQUEST) // +8 for USB hdr
#endif
				pMds->TxToggle = true;

			// Get packet to transmit completed, 1:TESTSTA 2:MLME 3: Ndis data
			MLME_SendComplete(adapter, 0, true);

			// Software TSC count 20060214
			pMds->TxTsc++;
			if (pMds->TxTsc == 0)
				pMds->TxTsc_2++;

			FillCount++; // 20060928
		} while (HAL_USB_MODE_BURST(pHwData)); // End of multiple MSDU copy loop. false = single true = multiple sending

		// Move to the next one, if necessary
		if (BufferFilled) {
			// size setting
			pMds->TxBufferSize[ FillIndex ] = XmitBufSize;

			// 20060928 set Tx count
			pMds->TxCountInBuffer[FillIndex] = FillCount;

			// Set owner flag
			pMds->TxOwner[FillIndex] = 1;

			pMds->TxFillIndex++;
			pMds->TxFillIndex %= MAX_USB_TX_BUFFER_NUMBER;
			BufferFilled = false;
		} else
			break;

		if (!PacketSize) // No more pk for transmitting
			break;

	} while(true);

	//
	// Start to send by lower module
	//
	if (!pHwData->IsKeyPreSet)
		Wb35Tx_start(adapter);

 cleanup:
	atomic_dec(&pMds->TxThreadCount);
}
Esempio n. 2
0
File: mds.c Progetto: 7799/linux
void
Mds_Tx(struct wbsoft_priv *adapter)
{
	struct hw_data *pHwData = &adapter->sHwData;
	struct wb35_mds *pMds = &adapter->Mds;
	struct wb35_descriptor	TxDes;
	struct wb35_descriptor *pTxDes = &TxDes;
	u8	*XmitBufAddress;
	u16	XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold;
	u8	FillIndex, TxDesIndex, FragmentCount, FillCount;
	unsigned char	BufferFilled = false;


	if (pMds->TxPause)
		return;
	if (!hal_driver_init_OK(pHwData))
		return;

	/* Only one thread can be run here */
	if (atomic_inc_return(&pMds->TxThreadCount) != 1)
		goto cleanup;

	/* Start to fill the data */
	do {
		FillIndex = pMds->TxFillIndex;
		/* Is owned by software 0:Yes 1:No */
		if (pMds->TxOwner[FillIndex]) {
			pr_debug("[Mds_Tx] Tx Owner is H/W.\n");
			break;
		}

		/* Get buffer */
		XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex);
		XmitBufSize = 0;
		FillCount = 0;
		do {
			PacketSize = adapter->sMlmeFrame.len;
			if (!PacketSize)
				break;

			/* For Check the buffer resource */
			FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD;
			/* 931130.5.b */
			FragmentCount = PacketSize/FragmentThreshold + 1;
			/* 931130.5.c 8:MIC */
			stmp = PacketSize + FragmentCount*32 + 8;
			if ((XmitBufSize + stmp) >= MAX_USB_TX_BUFFER)
				break; /* buffer is not enough */

			/*
			 * Start transmitting
			 */
			BufferFilled = true;

			/* Leaves first u8 intact */
			memset((u8 *)pTxDes + 1, 0, sizeof(struct wb35_descriptor) - 1);

			TxDesIndex = pMds->TxDesIndex; /* Get the current ID */
			pTxDes->Descriptor_ID = TxDesIndex;
			/* Storing the information of source coming from */
			pMds->TxDesFrom[TxDesIndex] = 2;
			pMds->TxDesIndex++;
			pMds->TxDesIndex %= MAX_USB_TX_DESCRIPTOR;

			MLME_GetNextPacket(adapter, pTxDes);

			/*
			 * Copy header. 8byte USB + 24byte 802.11Hdr.
			 * Set TxRate, Preamble type
			*/
			Mds_HeaderCopy(adapter, pTxDes, XmitBufAddress);

			/* For speed up Key setting */
			if (pTxDes->EapFix) {
				pr_debug("35: EPA 4th frame detected. Size = %d\n",
						 PacketSize);
				pHwData->IsKeyPreSet = 1;
			}

			/* Copy (fragment) frame body, and set USB, 802.11 hdr flag */
			CurrentSize = Mds_BodyCopy(adapter, pTxDes, XmitBufAddress);

			/* Set RTS/CTS and Normal duration field into buffer */
			Mds_DurationSet(adapter, pTxDes, XmitBufAddress);

			/* Shift to the next address */
			XmitBufSize += CurrentSize;
			XmitBufAddress += CurrentSize;

			/* Get packet to transmit completed,
			 * 1:TESTSTA 2:MLME 3: Ndis data
			*/
			MLME_SendComplete(adapter, 0, true);

			/* Software TSC count 20060214 */
			pMds->TxTsc++;
			if (pMds->TxTsc == 0)
				pMds->TxTsc_2++;

			FillCount++; /* 20060928 */
		/*
		 * End of multiple MSDU copy loop.
		 * false = single
		 * true = multiple sending
		 */
		} while (HAL_USB_MODE_BURST(pHwData));

		/* Move to the next one, if necessary */
		if (BufferFilled) {
			/* size setting */
			pMds->TxBufferSize[FillIndex] = XmitBufSize;

			/* 20060928 set Tx count */
			pMds->TxCountInBuffer[FillIndex] = FillCount;

			/* Set owner flag */
			pMds->TxOwner[FillIndex] = 1;

			pMds->TxFillIndex++;
			pMds->TxFillIndex %= MAX_USB_TX_BUFFER_NUMBER;
			BufferFilled = false;
		} else
			break;

		if (!PacketSize) /* No more pk for transmitting */
			break;

	} while (true);

	/*
	 * Start to send by lower module
	 */
	if (!pHwData->IsKeyPreSet)
		Wb35Tx_start(adapter);

cleanup:
		atomic_dec(&pMds->TxThreadCount);
}
Esempio n. 3
0
void
Mds_Tx(struct wbsoft_priv *adapter)
{
	struct hw_data *pHwData = &adapter->sHwData;
	struct wb35_mds *pMds = &adapter->Mds;
	struct wb35_descriptor	TxDes;
	struct wb35_descriptor *pTxDes = &TxDes;
	u8		*XmitBufAddress;
	u16		XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold;
	u8		FillIndex, TxDesIndex, FragmentCount, FillCount;
	unsigned char	BufferFilled = false;


	if (pMds->TxPause)
		return;
	if (!hal_driver_init_OK(pHwData))
		return;

	/*                                 */
	if (atomic_inc_return(&pMds->TxThreadCount) != 1)
		goto cleanup;

	/*                        */
	do {
		FillIndex = pMds->TxFillIndex;
		if (pMds->TxOwner[FillIndex]) { /*                                 */
			pr_debug("[Mds_Tx] Tx Owner is H/W.\n");
			break;
		}

		XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex); /*            */
		XmitBufSize = 0;
		FillCount = 0;
		do {
			PacketSize = adapter->sMlmeFrame.len;
			if (!PacketSize)
				break;

			/*                               */
			FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD;
			/*            */
			FragmentCount = PacketSize/FragmentThreshold + 1;
			stmp = PacketSize + FragmentCount*32 + 8; /*                  */
			if ((XmitBufSize + stmp) >= MAX_USB_TX_BUFFER) {
				printk("[Mds_Tx] Excess max tx buffer.\n");
				break; /*                      */
			}


			/*
                        
    */
			BufferFilled = true;

			/*                        */
			memset((u8 *)pTxDes + 1, 0, sizeof(struct wb35_descriptor) - 1);

			TxDesIndex = pMds->TxDesIndex; /*                    */
			pTxDes->Descriptor_ID = TxDesIndex;
			pMds->TxDesFrom[TxDesIndex] = 2; /*                                               */
			pMds->TxDesIndex++;
			pMds->TxDesIndex %= MAX_USB_TX_DESCRIPTOR;

			MLME_GetNextPacket(adapter, pTxDes);

			/*                                                                      */
			Mds_HeaderCopy(adapter, pTxDes, XmitBufAddress);

			/*                          */
			if (pTxDes->EapFix) {
				pr_debug("35: EPA 4th frame detected. Size = %d\n", PacketSize);
				pHwData->IsKeyPreSet = 1;
			}

			/*                                                          */
			CurrentSize = Mds_BodyCopy(adapter, pTxDes, XmitBufAddress);

			/*                                                   */
			Mds_DurationSet(adapter, pTxDes, XmitBufAddress);

			/*                           */
			XmitBufSize += CurrentSize;
			XmitBufAddress += CurrentSize;

			/*                                                                 */
			MLME_SendComplete(adapter, 0, true);

			/*                             */
			pMds->TxTsc++;
			if (pMds->TxTsc == 0)
				pMds->TxTsc_2++;

			FillCount++; /*          */
		} while (HAL_USB_MODE_BURST(pHwData)); /*                                                                         */

		/*                                    */
		if (BufferFilled) {
			/*              */
			pMds->TxBufferSize[FillIndex] = XmitBufSize;

			/*                       */
			pMds->TxCountInBuffer[FillIndex] = FillCount;

			/*                */
			pMds->TxOwner[FillIndex] = 1;

			pMds->TxFillIndex++;
			pMds->TxFillIndex %= MAX_USB_TX_BUFFER_NUMBER;
			BufferFilled = false;
		} else
			break;

		if (!PacketSize) /*                             */
			break;

	} while (true);

	/*
                                 
  */
	if (!pHwData->IsKeyPreSet)
		Wb35Tx_start(adapter);

cleanup:
		atomic_dec(&pMds->TxThreadCount);
}