software/drivers/sd8887/src/wlan/mlan/mlan_sdio.c
/**
 *  @brief This function receives data from the card in aggregate mode.
 *
 *  @param pmadapter A pointer to mlan_adapter structure
 *  @param pmbuf      A pointer to the SDIO data/cmd buffer
 *  @param port      Current port on which packet needs to be rxed
 *  @param rx_len    Length of received packet
 *  @return          MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
@brief This function receives data from the card in aggregate mode.
@brief This function receives data from the card in aggregate mode .
static mlan_status
wlan_sdio_card_to_host_mp_aggr(mlan_adapter *pmadapter, mlan_buffer
			       *pmbuf, t_u8 port, t_u16 rx_len)
{
	mlan_status ret = MLAN_STATUS_SUCCESS;
	t_s32 f_do_rx_aggr = 0;
	t_s32 f_do_rx_cur = 0;
	t_s32 f_aggr_cur = 0;
	t_s32 f_post_aggr_cur = 0;
	t_u32 pind = 0;
	t_u32 pkt_type = 0;
	ENTER();
	if (!pmadapter->mpa_rx.enabled) {
		PRINTM(MINFO,
		       "card_2_host_mp_aggr: rx aggregation disabled !\n");
		f_do_rx_cur = 1;
		goto rx_curr_single;
	}
	if (pmadapter->mp_rd_bitmap & DATA_PORT_MASK) {
		PRINTM(MINFO, "card_2_host_mp_aggr: Not last packet\n");
		if (MP_RX_AGGR_IN_PROGRESS(pmadapter)) {
			if (MP_RX_AGGR_BUF_HAS_ROOM(pmadapter, rx_len)) {
				f_aggr_cur = 1;
			} else {
				f_do_rx_aggr = 1;
				f_post_aggr_cur = 1;
			}
		} else {
			f_aggr_cur = 1;
		}
	} else {
		PRINTM(MINFO, "card_2_host_mp_aggr: Last packet\n");
		if (MP_RX_AGGR_IN_PROGRESS(pmadapter)) {
			f_do_rx_aggr = 1;
			if (MP_RX_AGGR_BUF_HAS_ROOM(pmadapter, rx_len)) {
				f_aggr_cur = 1;
			} else {
				f_do_rx_cur = 1;
			}
		} else {
			f_do_rx_cur = 1;
		}
	}
	if (f_aggr_cur) {
		PRINTM(MINFO, "Current packet aggregation.\n");
		MP_RX_AGGR_SETUP(pmadapter, pmbuf, port, rx_len);
		if (MP_RX_AGGR_PKT_LIMIT_REACHED(pmadapter) ||
		    MP_RX_AGGR_PORT_LIMIT_REACHED(pmadapter)
			) {
			PRINTM(MINFO,
			       "card_2_host_mp_aggr: Aggregation Packet limit reached\n");
			f_do_rx_aggr = 1;
		}
	}
	if (f_do_rx_aggr) {
		if (MLAN_STATUS_SUCCESS != wlan_receive_mp_aggr_buf(pmadapter)) {
			ret = MLAN_STATUS_FAILURE;
			goto done;
		}
	}
rx_curr_single:
	if (f_do_rx_cur) {
		PRINTM(MINFO, "RX: f_do_rx_cur: port: %d rx_len: %d\n", port,
		       rx_len);
		if (MLAN_STATUS_SUCCESS !=
		    wlan_sdio_card_to_host(pmadapter, &pkt_type,
					   (t_u32 *)&pmadapter->upld_len, pmbuf,
					   rx_len, pmadapter->ioport + port)) {
			ret = MLAN_STATUS_FAILURE;
			goto done;
		}
		if (pkt_type != MLAN_TYPE_DATA
		    && pkt_type != MLAN_TYPE_SPA_DATA) {
			PRINTM(MERROR,
			       "receive a wrong pkt from DATA PORT: type=%d, len=%dd\n",
			       pkt_type, pmbuf->data_len);
			pmbuf->status_code = MLAN_ERROR_DATA_RX_FAIL;
			ret = MLAN_STATUS_FAILURE;
			goto done;
		}
		pmadapter->mpa_rx_count[0]++;
		wlan_decode_rx_packet(pmadapter, pmbuf, pkt_type, MTRUE);
	}
	if (f_post_aggr_cur) {
		PRINTM(MINFO, "Current packet aggregation.\n");
		MP_RX_AGGR_SETUP(pmadapter, pmbuf, port, rx_len);
	}
done:
	if (ret == MLAN_STATUS_FAILURE) {
		if (MP_RX_AGGR_IN_PROGRESS(pmadapter)) {
			for (pind = 0; pind < pmadapter->mpa_rx.pkt_cnt; pind++) {
				wlan_free_mlan_buffer(pmadapter,
						      pmadapter->mpa_rx.
						      mbuf_arr[pind]);
			}
			MP_RX_AGGR_BUF_RESET(pmadapter);
		}
		if (f_do_rx_cur) {
			wlan_free_mlan_buffer(pmadapter, pmbuf);
		}
	}
	LEAVE();
	return ret;
}
static mlan_status wlan_sdio_card_to_host_mp_aggr ( mlan_adapter * pmadapter , mlan_buffer * pmbuf , t_u8 port , t_u16 rx_len ) { mlan_status ret = MLAN_STATUS_SUCCESS ; t_s32 f_do_rx_aggr = 0 ; t_s32 f_do_rx_cur = 0 ; t_s32 f_aggr_cur = 0 ; t_s32 f_post_aggr_cur = 0 ; t_u32 pind = 0 ; t_u32 pkt_type = 0 ; ENTER ( ) ; if ( ! pmadapter -> mpa_rx . enabled ) { PRINTM ( MINFO , " \n " ) ; f_do_rx_cur = 1 ; goto rx_curr_single ; } if ( pmadapter -> mp_rd_bitmap & DATA_PORT_MASK ) { PRINTM ( MINFO , " \n " ) ; if ( MP_RX_AGGR_IN_PROGRESS ( pmadapter ) ) { if ( MP_RX_AGGR_BUF_HAS_ROOM ( pmadapter , rx_len ) ) { f_aggr_cur = 1 ; } else { f_do_rx_aggr = 1 ; f_post_aggr_cur = 1 ; } } else { f_aggr_cur = 1 ; } } else { PRINTM ( MINFO , " \n " ) ; if ( MP_RX_AGGR_IN_PROGRESS ( pmadapter ) ) { f_do_rx_aggr = 1 ; if ( MP_RX_AGGR_BUF_HAS_ROOM ( pmadapter , rx_len ) ) { f_aggr_cur = 1 ; } else { f_do_rx_cur = 1 ; } } else { f_do_rx_cur = 1 ; } } if ( f_aggr_cur ) { PRINTM ( MINFO , " \n " ) ; MP_RX_AGGR_SETUP ( pmadapter , pmbuf , port , rx_len ) ; if ( MP_RX_AGGR_PKT_LIMIT_REACHED ( pmadapter ) || MP_RX_AGGR_PORT_LIMIT_REACHED ( pmadapter ) ) { PRINTM ( MINFO , " \n " ) ; f_do_rx_aggr = 1 ; } } if ( f_do_rx_aggr ) { if ( MLAN_STATUS_SUCCESS != wlan_receive_mp_aggr_buf ( pmadapter ) ) { ret = MLAN_STATUS_FAILURE ; goto done ; } } rx_curr_single : if ( f_do_rx_cur ) { PRINTM ( MINFO , " \n " , port , rx_len ) ; if ( MLAN_STATUS_SUCCESS != wlan_sdio_card_to_host ( pmadapter , & pkt_type , ( t_u32 * ) & pmadapter -> upld_len , pmbuf , rx_len , pmadapter -> ioport + port ) ) { ret = MLAN_STATUS_FAILURE ; goto done ; } if ( pkt_type != MLAN_TYPE_DATA && pkt_type != MLAN_TYPE_SPA_DATA ) { PRINTM ( MERROR , " \n " , pkt_type , pmbuf -> data_len ) ; pmbuf -> status_code = MLAN_ERROR_DATA_RX_FAIL ; ret = MLAN_STATUS_FAILURE ; goto done ; } pmadapter -> mpa_rx_count [ 0 ] ++ ; wlan_decode_rx_packet ( pmadapter , pmbuf , pkt_type , MTRUE ) ; } if ( f_post_aggr_cur ) { PRINTM ( MINFO , " \n " ) ; MP_RX_AGGR_SETUP ( pmadapter , pmbuf , port , rx_len ) ; } done : if ( ret == MLAN_STATUS_FAILURE ) { if ( MP_RX_AGGR_IN_PROGRESS ( pmadapter ) ) { for ( pind = 0 ; pind < pmadapter -> mpa_rx . pkt_cnt ; pind ++ ) { wlan_free_mlan_buffer ( pmadapter , pmadapter -> mpa_rx . mbuf_arr [ pind ] ) ; } MP_RX_AGGR_BUF_RESET ( pmadapter ) ; } if ( f_do_rx_cur ) { wlan_free_mlan_buffer ( pmadapter , pmbuf ) ; } } LEAVE ( ) ; return ret ; }
@brief This function receives data from the card in aggregate mode.
@brief This function receives data from the card in aggregate mode .
/* Some more data RX pending */ /* No room in Aggr buf, do rx aggr now */ /* Rx aggr not in progress */ /* No more data RX pending */ /* No room in Aggr buf, do rx aggr now */ /* Curr pkt can be aggregated */ /* No more pkts allowed in Aggr buf, rx it */ /* do aggr RX now */ /* Curr pkt can be aggregated */ /* MP-A transfer failed - cleanup */ /* Single Transfer pending */ /* Free curr buff also */