software/drivers/sd8887/src/wlan/mlan/mlan_11h.c
/**
 *  @brief  Prepare CMD_CHAN_REPORT_REQUEST firmware command
 *
 *  @param priv      Private driver information structure
 *  @param pcmd_ptr  Output parameter: Pointer to the command being
 *                   prepared to for firmware
 *  @param pinfo_buf HostCmd_DS_CHAN_RPT_REQ passed as void data block
 *
 *  @return          MLAN_STATUS_SUCCESS or MLAN_STATUS_PENDING
 */
@brief  Prepare CMD_CHAN_REPORT_REQUEST firmware command
@param priv      Private driver information structure
@param pcmd_ptr  Output parameter: Pointer to the command being
prepared to for firmware
@param pinfo_buf HostCmd_DS_CHAN_RPT_REQ passed as void data block


@brief Prepare CMD_CHAN_REPORT_REQUEST firmware command @param priv Private driver information structure @param pcmd_ptr Output parameter : Pointer to the command being prepared to for firmware @param pinfo_buf HostCmd_DS_CHAN_RPT_REQ passed as void data block
static mlan_status
wlan_11h_cmd_chan_rpt_req(mlan_private *priv,
			  HostCmd_DS_COMMAND *pcmd_ptr, const t_void *pinfo_buf)
{
	const HostCmd_DS_CHAN_RPT_REQ *pchan_rpt_req =
		(HostCmd_DS_CHAN_RPT_REQ *)pinfo_buf;
	wlan_dfs_device_state_t *pstate_dfs = &priv->adapter->state_dfs;
	MrvlIEtypes_ChanRpt11hBasic_t *ptlv_basic;
	t_bool is_cancel_req = MFALSE;
	if (pchan_rpt_req->millisec_dwell_time == 0)
		is_cancel_req = MTRUE;
	ENTER();
	if (pstate_dfs->dfs_check_pending && !is_cancel_req) {
		PRINTM(MERROR,
		       "11h: ChanRptReq - previous CMD_CHAN_REPORT_REQUEST has"
		       " not returned its result yet (as EVENT_CHANNEL_READY)."
		       "  This command will be dropped.\n");
		LEAVE();
		return MLAN_STATUS_PENDING;
	}
	pcmd_ptr->size = sizeof(HostCmd_DS_CHAN_RPT_REQ) + S_DS_GEN;
	memcpy(priv->adapter, &pcmd_ptr->params.chan_rpt_req, pchan_rpt_req,
	       sizeof(HostCmd_DS_CHAN_RPT_REQ));
	pcmd_ptr->params.chan_rpt_req.chan_desc.startFreq =
		wlan_cpu_to_le16(pchan_rpt_req->chan_desc.startFreq);
	pcmd_ptr->params.chan_rpt_req.millisec_dwell_time =
		wlan_cpu_to_le32(pchan_rpt_req->millisec_dwell_time);
	if (!is_cancel_req &&
	    wlan_11h_radar_detect_required(priv,
					   pchan_rpt_req->chan_desc.chanNum)) {
		ptlv_basic =
			(MrvlIEtypes_ChanRpt11hBasic_t *)(((t_u8 *)(pcmd_ptr)) +
							  pcmd_ptr->size);
		ptlv_basic->Header.type =
			wlan_cpu_to_le16(TLV_TYPE_CHANRPT_11H_BASIC);
		ptlv_basic->Header.len =
			wlan_cpu_to_le16(sizeof(MeasRptBasicMap_t));
		memset(priv->adapter, &ptlv_basic->map, 0,
		       sizeof(MeasRptBasicMap_t));
		ptlv_basic->map.radar = 1;
		pcmd_ptr->size += sizeof(MrvlIEtypes_ChanRpt11hBasic_t);
	}
	pstate_dfs->dfs_check_pending = MFALSE;
	pstate_dfs->dfs_radar_found = MFALSE;
	pstate_dfs->dfs_check_priv = MNULL;
	if (!is_cancel_req)
		pstate_dfs->dfs_check_channel =
			pchan_rpt_req->chan_desc.chanNum;
	LEAVE();
	return MLAN_STATUS_SUCCESS;
}
static mlan_status wlan_11h_cmd_chan_rpt_req ( mlan_private * priv , HostCmd_DS_COMMAND * pcmd_ptr , const t_void * pinfo_buf ) { const HostCmd_DS_CHAN_RPT_REQ * pchan_rpt_req = ( HostCmd_DS_CHAN_RPT_REQ * ) pinfo_buf ; wlan_dfs_device_state_t * pstate_dfs = & priv -> adapter -> state_dfs ; MrvlIEtypes_ChanRpt11hBasic_t * ptlv_basic ; t_bool is_cancel_req = MFALSE ; if ( pchan_rpt_req -> millisec_dwell_time == 0 ) is_cancel_req = MTRUE ; ENTER ( ) ; if ( pstate_dfs -> dfs_check_pending && ! is_cancel_req ) { PRINTM ( MERROR , " " " " " \n " ) ; LEAVE ( ) ; return MLAN_STATUS_PENDING ; } pcmd_ptr -> size = sizeof ( HostCmd_DS_CHAN_RPT_REQ ) + S_DS_GEN ; memcpy ( priv -> adapter , & pcmd_ptr -> params . chan_rpt_req , pchan_rpt_req , sizeof ( HostCmd_DS_CHAN_RPT_REQ ) ) ; pcmd_ptr -> params . chan_rpt_req . chan_desc . startFreq = wlan_cpu_to_le16 ( pchan_rpt_req -> chan_desc . startFreq ) ; pcmd_ptr -> params . chan_rpt_req . millisec_dwell_time = wlan_cpu_to_le32 ( pchan_rpt_req -> millisec_dwell_time ) ; if ( ! is_cancel_req && wlan_11h_radar_detect_required ( priv , pchan_rpt_req -> chan_desc . chanNum ) ) { ptlv_basic = ( MrvlIEtypes_ChanRpt11hBasic_t * ) ( ( ( t_u8 * ) ( pcmd_ptr ) ) + pcmd_ptr -> size ) ; ptlv_basic -> Header . type = wlan_cpu_to_le16 ( TLV_TYPE_CHANRPT_11H_BASIC ) ; ptlv_basic -> Header . len = wlan_cpu_to_le16 ( sizeof ( MeasRptBasicMap_t ) ) ; memset ( priv -> adapter , & ptlv_basic -> map , 0 , sizeof ( MeasRptBasicMap_t ) ) ; ptlv_basic -> map . radar = 1 ; pcmd_ptr -> size += sizeof ( MrvlIEtypes_ChanRpt11hBasic_t ) ; } pstate_dfs -> dfs_check_pending = MFALSE ; pstate_dfs -> dfs_radar_found = MFALSE ; pstate_dfs -> dfs_check_priv = MNULL ; if ( ! is_cancel_req ) pstate_dfs -> dfs_check_channel = pchan_rpt_req -> chan_desc . chanNum ; LEAVE ( ) ; return MLAN_STATUS_SUCCESS ; }
@brief  Prepare CMD_CHAN_REPORT_REQUEST firmware command
  @param priv      Private driver information structure
  @param pcmd_ptr  Output parameter: Pointer to the command being
                   prepared to for firmware
  @param pinfo_buf HostCmd_DS_CHAN_RPT_REQ passed as void data block
@brief Prepare CMD_CHAN_REPORT_REQUEST firmware command @param priv Private driver information structure @param pcmd_ptr Output parameter : Pointer to the command being prepared to for firmware @param pinfo_buf HostCmd_DS_CHAN_RPT_REQ passed as void data block
/*
	 * pchan_rpt_req->millisec_dwell_time would be zero if the chan_rpt_req
	 * is to cancel current ongoing report
	 */ /* Converted to little endian in wlan_11h_cmd_process */ /* if DFS channel, add BASIC report TLV, and set radar bit */ /* update dfs sturcture.
	 * dfs_check_pending is set when we receive CMD_RESP == SUCCESS */