software/drivers/sd8887/src/wlan/mlan/mlan_sdio.c
/**
 *  @brief This function sends data to the card.
 *
 *  @param pmadapter A pointer to mlan_adapter structure
 *  @param type      data or command
 *  @param pmbuf     A pointer to mlan_buffer (pmbuf->data_len should include SDIO header)
 *  @param tx_param  A pointer to mlan_tx_param
 *  @return          MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
@brief This function sends data to the card.
@brief This function sends data to the card .
mlan_status
wlan_sdio_host_to_card(mlan_adapter *pmadapter, t_u8 type, mlan_buffer *pmbuf,
		       mlan_tx_param *tx_param)
{
	mlan_status ret = MLAN_STATUS_SUCCESS;
	t_u32 buf_block_len;
	t_u32 blksz;
	t_u8 port = 0;
	t_u32 cmd53_port = 0;
	t_u8 *payload = pmbuf->pbuf + pmbuf->data_offset;
	t_u16 max_size = 0;
	ENTER();
	blksz = MLAN_SDIO_BLOCK_SIZE;
	buf_block_len = (pmbuf->data_len + blksz - 1) / blksz;
	if (type == MLAN_TYPE_CMD)
		max_size = MRVDRV_SIZE_OF_CMD_BUFFER;
	else
		max_size = pmadapter->tx_buf_size;
	if (blksz * buf_block_len <= max_size)
		*(t_u16 *)&payload[0] =
			wlan_cpu_to_le16((t_u16)(blksz * buf_block_len));
	else
		*(t_u16 *)&payload[0] =
			wlan_cpu_to_le16((t_u16)pmbuf->data_len);
	*(t_u16 *)&payload[2] = wlan_cpu_to_le16(type);
	if (type == MLAN_TYPE_DATA) {
		ret = wlan_get_wr_port_data(pmadapter, &port);
		if (ret != MLAN_STATUS_SUCCESS) {
			PRINTM(MERROR,
			       "no wr_port available: wr_bitmap=0x%08x curr_wr_port=%d\n",
			       pmadapter->mp_wr_bitmap,
			       pmadapter->curr_wr_port);
			goto exit;
		}
		pmbuf->data_len = buf_block_len * blksz;
#ifdef SDIO_MULTI_PORT_TX_AGGR
		if (tx_param)
			ret = wlan_host_to_card_mp_aggr(pmadapter, pmbuf, port,
							tx_param->next_pkt_len);
		else
			ret = wlan_host_to_card_mp_aggr(pmadapter, pmbuf, port,
							0);
#else
		ret = wlan_write_data_sync(pmadapter, pmbuf,
					   pmadapter->ioport + port);
#endif 
	} else {
		pmadapter->cmd_sent = MTRUE;
		if (pmbuf->data_len <= INTF_HEADER_LEN ||
		    pmbuf->data_len > WLAN_UPLD_SIZE)
			PRINTM(MWARN,
			       "wlan_sdio_host_to_card(): Error: payload=%p, nb=%d\n",
			       payload, pmbuf->data_len);
		pmbuf->data_len = buf_block_len * blksz;
		cmd53_port = (pmadapter->ioport) | CMD_PORT_SLCT;
		ret = wlan_write_data_sync(pmadapter, pmbuf, cmd53_port);
	}
	if (ret == MLAN_STATUS_FAILURE) {
		if (type == MLAN_TYPE_CMD)
			pmadapter->cmd_sent = MFALSE;
		if (type == MLAN_TYPE_DATA)
			pmadapter->data_sent = MFALSE;
	} else {
		if (type == MLAN_TYPE_DATA) {
			if (!
			    (pmadapter->
			     mp_wr_bitmap & (1 << pmadapter->curr_wr_port)))
				pmadapter->data_sent = MTRUE;
			else
				pmadapter->data_sent = MFALSE;
		}
		DBG_HEXDUMP(MIF_D, "SDIO Blk Wr",
			    pmbuf->pbuf + pmbuf->data_offset,
			    MIN(pmbuf->data_len, MAX_DATA_DUMP_LEN));
	}
exit:
	LEAVE();
	return ret;
}
mlan_status wlan_sdio_host_to_card ( mlan_adapter * pmadapter , t_u8 type , mlan_buffer * pmbuf , mlan_tx_param * tx_param ) { mlan_status ret = MLAN_STATUS_SUCCESS ; t_u32 buf_block_len ; t_u32 blksz ; t_u8 port = 0 ; t_u32 cmd53_port = 0 ; t_u8 * payload = pmbuf -> pbuf + pmbuf -> data_offset ; t_u16 max_size = 0 ; ENTER ( ) ; blksz = MLAN_SDIO_BLOCK_SIZE ; buf_block_len = ( pmbuf -> data_len + blksz - 1 ) / blksz ; if ( type == MLAN_TYPE_CMD ) max_size = MRVDRV_SIZE_OF_CMD_BUFFER ; else max_size = pmadapter -> tx_buf_size ; if ( blksz * buf_block_len <= max_size ) * ( t_u16 * ) & payload [ 0 ] = wlan_cpu_to_le16 ( ( t_u16 ) ( blksz * buf_block_len ) ) ; else * ( t_u16 * ) & payload [ 0 ] = wlan_cpu_to_le16 ( ( t_u16 ) pmbuf -> data_len ) ; * ( t_u16 * ) & payload [ 2 ] = wlan_cpu_to_le16 ( type ) ; if ( type == MLAN_TYPE_DATA ) { ret = wlan_get_wr_port_data ( pmadapter , & port ) ; if ( ret != MLAN_STATUS_SUCCESS ) { PRINTM ( MERROR , " \n " , pmadapter -> mp_wr_bitmap , pmadapter -> curr_wr_port ) ; goto exit ; } pmbuf -> data_len = buf_block_len * blksz ; #ifdef SDIO_MULTI_PORT_TX_AGGR if ( tx_param ) ret = wlan_host_to_card_mp_aggr ( pmadapter , pmbuf , port , tx_param -> next_pkt_len ) ; else ret = wlan_host_to_card_mp_aggr ( pmadapter , pmbuf , port , 0 ) ; #else ret = wlan_write_data_sync ( pmadapter , pmbuf , pmadapter -> ioport + port ) ; #endif } else { pmadapter -> cmd_sent = MTRUE ; if ( pmbuf -> data_len <= INTF_HEADER_LEN || pmbuf -> data_len > WLAN_UPLD_SIZE ) PRINTM ( MWARN , " \n " , payload , pmbuf -> data_len ) ; pmbuf -> data_len = buf_block_len * blksz ; cmd53_port = ( pmadapter -> ioport ) | CMD_PORT_SLCT ; ret = wlan_write_data_sync ( pmadapter , pmbuf , cmd53_port ) ; } if ( ret == MLAN_STATUS_FAILURE ) { if ( type == MLAN_TYPE_CMD ) pmadapter -> cmd_sent = MFALSE ; if ( type == MLAN_TYPE_DATA ) pmadapter -> data_sent = MFALSE ; } else { if ( type == MLAN_TYPE_DATA ) { if ( ! ( pmadapter -> mp_wr_bitmap & ( 1 << pmadapter -> curr_wr_port ) ) ) pmadapter -> data_sent = MTRUE ; else pmadapter -> data_sent = MFALSE ; } DBG_HEXDUMP ( MIF_D , " " , pmbuf -> pbuf + pmbuf -> data_offset , MIN ( pmbuf -> data_len , MAX_DATA_DUMP_LEN ) ) ; } exit : LEAVE ( ) ; return ret ; }
@brief This function sends data to the card.
@brief This function sends data to the card .
/* Allocate buffer and copy payload */ /*
	 * This is SDIO specific header
	 *  t_u16 length,
	 *  t_u16 type (MLAN_TYPE_DATA = 0,
	 *    MLAN_TYPE_CMD = 1, MLAN_TYPE_EVENT = 3)
	 */ /* Transfer data to card */ /* SDIO_MULTI_PORT_TX_AGGR */ /*Type must be MLAN_TYPE_CMD */ /* Transfer data to card */