oal_uint32 dmac_data_acq_report_data_unit(oal_uint8 *puc_daq_addr, oal_uint32 ul_len, oal_netbuf_stru *pst_netbuf) { dmac_data_acq_data_head_stru *pst_daq_data_head; oal_int32 l_bytes = 0; pst_daq_data_head = (dmac_data_acq_data_head_stru *)oal_netbuf_data(pst_netbuf); /* 填写消息头 */ pst_daq_data_head->en_send_type = DMAC_DATA_ACQ_SEND_TYPE_UNIT; pst_daq_data_head->ul_msg_sn = g_st_data_acq.ul_daq_sn; pst_daq_data_head->ul_data_len = ul_len; oal_memcopy((oal_uint8 *)pst_daq_data_head + DMAC_DATA_ACQ_DATA_HEAD_LEN, puc_daq_addr, ul_len); l_bytes = oam_netlink_kernel_send(oal_netbuf_data(pst_netbuf), OAL_SIZEOF(dmac_data_acq_info_stru) + ul_len, OAM_NL_CMD_DAQ); if (l_bytes <= 0) { OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_data_acq_report_data_unit::invalid l_bytes[%d].}", l_bytes); return OAL_FAIL; } g_st_data_acq.ul_daq_sn++; /* 等待APP侧接收完成 */ if (0 == g_st_data_acq.ul_daq_sn % DMAC_DATA_ACQ_PER_MAX_NUM) { dmac_data_acq_set_send_flag(OAL_FALSE); } return OAL_SUCC; }
oal_uint32 dmac_data_acq_report_data_info(oal_uint8 *puc_daq_addr, oal_uint32 ul_len, oal_netbuf_stru *pst_netbuf) { dmac_data_acq_info_stru *pst_daq_data_info = OAL_PTR_NULL; dmac_data_acq_data_head_stru *pst_daq_data_head = OAL_PTR_NULL; oal_int32 l_bytes = 0; oal_uint32 ul_time = 0; /***** 发送数采基本信息给app 填写消息头 *****/ pst_daq_data_head = (dmac_data_acq_data_head_stru *)oal_netbuf_data(pst_netbuf); pst_daq_data_head->en_send_type = DMAC_DATA_ACQ_SEND_TYPE_INFO; pst_daq_data_head->ul_msg_sn = 0; pst_daq_data_head->ul_data_len = OAL_SIZEOF(dmac_data_acq_info_stru); /***** 发送数采基本信息给app 填写消息内容 *****/ pst_daq_data_info = (dmac_data_acq_info_stru *)(oal_netbuf_data(pst_netbuf) + DMAC_DATA_ACQ_DATA_HEAD_LEN); pst_daq_data_info->ul_daq_addr = (oal_uint32)puc_daq_addr; pst_daq_data_info->ul_data_len = ul_len; pst_daq_data_info->ul_unit_len = DMAC_DATA_ACQ_UNIT_DATA_LEN; /***** 将daq info通知app侧 *****/ l_bytes = oam_netlink_kernel_send(oal_netbuf_data(pst_netbuf), OAL_SIZEOF(dmac_data_acq_info_stru) + DMAC_DATA_ACQ_DATA_HEAD_LEN, OAM_NL_CMD_DAQ); if (l_bytes <= 0) { OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_data_acq_report_data_info::invalid l_bytes[%d].}", l_bytes); return OAL_FAIL; } g_st_data_acq.uc_ack_flag = OAL_FALSE; while(!g_st_data_acq.uc_ack_flag) { oal_msleep(1000); if (DMAC_DATA_ACQ_MAX_WAIT_TIME <= ul_time) { OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_data_acq_report_data_info::wait app ack timeout. Try again.}"); return OAL_FAIL; } ul_time++; } return OAL_SUCC; }
oal_uint32 oam_upload_device_log_to_sdt(oal_uint8 *pc_string, oal_uint16 len) { oal_netbuf_stru *pst_skb; oal_uint32 ul_ret = OAL_SUCC; if (OAL_PTR_NULL == pc_string) { OAL_IO_PRINT("oam_upload_log_to_sdt::pc_string is null!\n"); return OAL_ERR_CODE_PTR_NULL; } pst_skb = oam_alloc_data2sdt(len); if (OAL_PTR_NULL == pst_skb) { OAL_IO_PRINT("alloc netbuf stru failed!\n"); return OAL_ERR_CODE_PTR_NULL; } /* COPY打印的内容 */ oal_memcopy(oal_netbuf_data(pst_skb), pc_string, len); /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_skb, OAM_DATA_TYPE_DEVICE_LOG, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; }
/***************************************************************************** 函 数 名 : oam_upload_log_to_sdt 功能描述 : 打印信息到PC侧可维可测工具平台中 输入参数 : pc_string : 需要打印到可维可测工具平台中的字符串,以\0结束。 输出参数 : 无 返 回 值 : OAL_SUCC或其他错误码。 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2012年10月15日 作 者 : c59720 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 oam_upload_log_to_sdt(oal_int8 *pc_string) { oal_netbuf_stru *pst_skb; oal_uint32 ul_ret = OAL_SUCC; if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return OAL_ERR_CODE_PTR_NULL; } if (OAL_PTR_NULL == pc_string) { OAL_IO_PRINT("oam_upload_log_to_sdt::pc_string is null!\n"); return OAL_ERR_CODE_PTR_NULL; } pst_skb = oam_alloc_data2sdt(OAL_SIZEOF(oam_log_info_stru)); if (OAL_PTR_NULL == pst_skb) { return OAL_ERR_CODE_PTR_NULL; } /* COPY打印的内容 */ oal_memcopy(oal_netbuf_data(pst_skb), pc_string, OAL_SIZEOF(oam_log_info_stru)); /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_skb, OAM_DATA_TYPE_LOG, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; }
OAL_STATIC oal_bool_enum_uint8 dmac_11w_robust_frame(oal_netbuf_stru *pst_mgmt_frame) { oal_uint8 uc_frame_type; oal_uint8 *puc_mac_header; oal_uint8 *puc_payload; puc_mac_header = oal_netbuf_header(pst_mgmt_frame); #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE) puc_payload = oal_netbuf_data(pst_mgmt_frame); #else puc_payload = puc_mac_header + MAC_80211_FRAME_LEN; #endif /*非管理帧*/ uc_frame_type = mac_frame_get_type_value(puc_mac_header); if (WLAN_MANAGEMENT != uc_frame_type) { return OAL_FALSE; } uc_frame_type = mac_frame_get_subtype_value(puc_mac_header); if ((OAL_TRUE == dmac_11w_robust_action(pst_mgmt_frame))|| (OAL_TRUE == dmac_11w_robust_non_action(uc_frame_type, puc_payload))) { return OAL_TRUE; } return OAL_FALSE; }
/***************************************************************************** 函 数 名 : sdt_drv_check_isdevlog 功能描述 : 检测上报日志是否为device log 输入参数 : oal_net 输出参数 : 无 返 回 值 : int32 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年12月26日 作 者 : jwx222439 修改内容 : 新生成函数 *****************************************************************************/ OAL_STATIC OAL_INLINE oal_int32 sdt_drv_check_isdevlog(oal_netbuf_stru *pst_netbuf) { oal_uint8 *puc_pkt_tail; sdt_drv_pkt_hdr_stru *pst_pkt_hdr; pst_pkt_hdr = (sdt_drv_pkt_hdr_stru *)oal_netbuf_data(pst_netbuf); puc_pkt_tail = (oal_uint8 *)pst_pkt_hdr + OAL_NETBUF_LEN(pst_netbuf); OAL_IO_PRINT("devlog {%s}\n", oal_netbuf_data(pst_netbuf)); if (SDT_DRV_PKT_END_FLG == *puc_pkt_tail || SDT_DRV_PKT_START_FLG == pst_pkt_hdr->uc_data_start_flg) { OAL_IO_PRINT("check out is device log\n"); return OAL_SUCC; } return -OAL_EFAIL; }
oal_void dmac_data_acq_workqueue(oal_work_stru *pst_work) { oal_uint32 ul_ret; oal_netbuf_stru *pst_netbuf; dmac_data_acq_info_stru *pst_daq_info; oal_uint8 *puc_daq_addr; oal_uint32 ul_len; pst_netbuf = oal_netbuf_delist(&g_st_data_acq.st_daq_workqueue.rx_daq_dbg_seq); while (OAL_PTR_NULL != pst_netbuf) { pst_daq_info = (dmac_data_acq_info_stru *)oal_netbuf_data(pst_netbuf); puc_daq_addr = (oal_uint8 *)pst_daq_info->ul_daq_addr; ul_len = pst_daq_info->ul_data_len; /* 发送数据信息给APP,若app出现错误则回复FAIL 等待APP的确认信号 */ ul_ret = dmac_data_acq_report_data_info(puc_daq_addr, ul_len, pst_netbuf); if (OAL_SUCC == ul_ret) { dmac_data_acq_report_data(puc_daq_addr, ul_len, pst_netbuf); } oal_netbuf_free(pst_netbuf); pst_netbuf = oal_netbuf_delist(&g_st_data_acq.st_daq_workqueue.rx_daq_dbg_seq); } }
/***************************************************************************** 函 数 名 : oam_stats_report_irq_info_to_sdt 功能描述 : 中断统计信息上报SDT 输入参数 : 无 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年2月21日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_void oam_stats_report_irq_info_to_sdt( oal_uint8 *puc_irq_info_addr, oal_uint16 us_irq_info_len) { oal_uint32 ul_tick; oal_uint16 us_skb_len; /* skb总长度 */ oal_netbuf_stru *pst_netbuf; oam_ota_stru *pst_ota_data; if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return ; } if (OAL_PTR_NULL == puc_irq_info_addr) { OAL_IO_PRINT("oam_stats_report_irq_info_to_sdt::puc_irq_info_addr is null!\n"); return; } /* 为上报描述符申请空间,头部预留8字节,尾部预留1字节,给sdt_drv用 */ us_skb_len = us_irq_info_len + OAL_SIZEOF(oam_ota_hdr_stru); if (us_skb_len > WLAN_SDT_NETBUF_MAX_PAYLOAD) { us_skb_len = WLAN_SDT_NETBUF_MAX_PAYLOAD; us_irq_info_len = WLAN_SDT_NETBUF_MAX_PAYLOAD - OAL_SIZEOF(oam_ota_hdr_stru); } pst_netbuf = oam_alloc_data2sdt(us_skb_len); if (OAL_PTR_NULL == pst_netbuf) { return; } pst_ota_data = (oam_ota_stru *)oal_netbuf_data(pst_netbuf); /* 获取系统TICK值 */ ul_tick = (oal_uint32)OAL_TIME_GET_STAMP_MS(); /* 填写ota消息头结构体 */ pst_ota_data->st_ota_hdr.ul_tick = ul_tick; pst_ota_data->st_ota_hdr.en_ota_type = OAM_OTA_TYPE_IRQ; pst_ota_data->st_ota_hdr.uc_frame_hdr_len = 0; pst_ota_data->st_ota_hdr.us_ota_data_len = us_irq_info_len; #if (_PRE_PRODUCT_ID == _PRE_PRODUCT_ID_HI1102_HOST) pst_ota_data->st_ota_hdr.auc_resv[0] = 2; #else pst_ota_data->st_ota_hdr.auc_resv[0] = 3; #endif /* 复制数据,填写ota数据 */ oal_memcopy((oal_void *)pst_ota_data->auc_ota_data, (const oal_void *)puc_irq_info_addr, (oal_uint32)us_irq_info_len); /* 下发至sdt接收队列,若队列满则串口输出 */ oam_report_data2sdt(pst_netbuf, OAM_DATA_TYPE_OTA, OAM_PRIMID_TYPE_OUTPUT_CONTENT); }
/***************************************************************************** 函 数 名 : oam_stats_report_usr_info 功能描述 : 把某个用户的统计信息上报sdt 输入参数 : 无 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年3月24日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 oam_stats_report_usr_info(oal_uint16 us_usr_id) { oal_uint32 ul_tick; oal_uint16 us_skb_len; /* skb总长度 */ oal_netbuf_stru *pst_netbuf; oam_ota_stru *pst_ota_data; oal_uint32 ul_ret = OAL_SUCC; oal_uint16 us_stat_info_len; if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return OAL_ERR_CODE_PTR_NULL; } if (us_usr_id >= WLAN_DEVICE_SUPPORT_MAX_NUM_SPEC * WLAN_ACTIVE_USER_MAX_NUM) { return OAL_ERR_CODE_INVALID_CONFIG; } us_stat_info_len = OAL_SIZEOF(oam_device_stat_info_stru); /* 为上报统计信息申请空间,头部预留8字节,尾部预留1字节,给sdt_drv用 */ us_skb_len = us_stat_info_len + OAL_SIZEOF(oam_ota_hdr_stru); if (us_skb_len > WLAN_SDT_NETBUF_MAX_PAYLOAD) { us_skb_len = WLAN_SDT_NETBUF_MAX_PAYLOAD; us_stat_info_len = WLAN_SDT_NETBUF_MAX_PAYLOAD - OAL_SIZEOF(oam_ota_hdr_stru); } pst_netbuf = oam_alloc_data2sdt(us_skb_len); if (OAL_PTR_NULL == pst_netbuf) { return OAL_ERR_CODE_PTR_NULL; } pst_ota_data = (oam_ota_stru *)oal_netbuf_data(pst_netbuf); /* 获取系统TICK值 */ ul_tick = (oal_uint32)OAL_TIME_GET_STAMP_MS(); /* 填写ota消息头结构体 */ pst_ota_data->st_ota_hdr.ul_tick = ul_tick; pst_ota_data->st_ota_hdr.en_ota_type = OAM_OTA_TYPE_USER_STAT_INFO; pst_ota_data->st_ota_hdr.uc_frame_hdr_len = 0; pst_ota_data->st_ota_hdr.us_ota_data_len = us_stat_info_len; oal_memcopy((oal_void *)pst_ota_data->auc_ota_data, (const oal_void *)&g_st_stat_info.ast_user_stat_info[us_usr_id], us_stat_info_len); /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_netbuf, OAM_DATA_TYPE_OTA, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; }
/***************************************************************************** 函 数 名 : sdt_drv_add_pkt_head 功能描述 : 从驱动侧接收到数据,前后加上类型等信息 输入参数 : 无 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年1月28日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ OAL_STATIC OAL_INLINE oal_void sdt_drv_add_pkt_head( oal_netbuf_stru *pst_netbuf, oam_data_type_enum_uint8 en_type, oam_primid_type_enum_uint8 en_prim_id) { /*************************** buffer structure ****************************/ /**************************************/ /* |data_hdr | data | data_tail | */ /*------------------------------------*/ /* | 8Byte | | 1Byte | */ /**************************************/ /*************************************************************************/ /************************ data header structure **************************/ /* ucFrameStart | ucFuncType | ucPrimId | ucReserver | usFrameLen | usSN */ /* --------------------------------------------------------------------- */ /* 1Byte | 1Byte | 1Byte | 1Byte | 2Bytes |2Bytes*/ /*************************************************************************/ oal_uint8 *puc_pkt_tail; sdt_drv_pkt_hdr_stru *pst_pkt_hdr; oal_uint16 us_tmp_data; oal_netbuf_push(pst_netbuf, WLAN_SDT_SKB_HEADROOM_LEN); oal_netbuf_put(pst_netbuf, WLAN_SDT_SKB_TAILROOM_LEN); /* SDT收到的消息数目加1 */ g_st_sdt_drv_mng_entry.us_sn_num++; /* 为数据头的每一个成员赋值 */ pst_pkt_hdr = (sdt_drv_pkt_hdr_stru *)oal_netbuf_data(pst_netbuf); pst_pkt_hdr->uc_data_start_flg = SDT_DRV_PKT_START_FLG; pst_pkt_hdr->en_msg_type = en_type; pst_pkt_hdr->uc_prim_id = en_prim_id; pst_pkt_hdr->uc_resv[0] = 0; us_tmp_data = (oal_uint16)OAL_NETBUF_LEN(pst_netbuf); pst_pkt_hdr->uc_data_len_low_byte = SDT_DRV_GET_LOW_BYTE(us_tmp_data); pst_pkt_hdr->uc_data_len_high_byte = SDT_DRV_GET_HIGH_BYTE(us_tmp_data); us_tmp_data = g_st_sdt_drv_mng_entry.us_sn_num; pst_pkt_hdr->uc_sequence_num_low_byte = SDT_DRV_GET_LOW_BYTE(us_tmp_data); pst_pkt_hdr->uc_sequence_num_high_byte = SDT_DRV_GET_HIGH_BYTE(us_tmp_data); /* 为数据尾赋值0x7e */ puc_pkt_tail = (oal_uint8 *)pst_pkt_hdr + OAL_NETBUF_LEN(pst_netbuf); puc_pkt_tail--; *puc_pkt_tail = SDT_DRV_PKT_END_FLG; }
/***************************************************************************** 函 数 名 : oam_print_to_sdt 功能描述 : 打印信息到PC侧可维可测工具平台中 输入参数 : pc_string : 需要打印到可维可测工具平台中的字符串,以\0结束。 输出参数 : 无 返 回 值 : OAL_SUCC或其他错误码。 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2012年10月15日 作 者 : c59720 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 oam_print_to_sdt(oal_int8 *pc_string) { oal_netbuf_stru *pst_skb; oal_uint32 ul_ret = OAL_SUCC; oal_uint16 us_strlen; if (OAL_UNLIKELY(OAL_PTR_NULL == pc_string)) { return OAL_ERR_CODE_PTR_NULL; } if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return OAL_ERR_CODE_PTR_NULL; } /* 上报sdt字符串以'0'结束 */ us_strlen = (oal_uint16)OAL_STRLEN(pc_string); us_strlen = (us_strlen > OAM_REPORT_MAX_STRING_LEN) ? OAM_REPORT_MAX_STRING_LEN : us_strlen; pst_skb = oam_alloc_data2sdt(us_strlen); if (OAL_PTR_NULL == pst_skb) { return OAL_ERR_CODE_PTR_NULL; } /* COPY打印的内容 */ oal_memset(oal_netbuf_data(pst_skb), 0, us_strlen); oal_memcopy(oal_netbuf_data(pst_skb), pc_string, (oal_uint32)us_strlen); /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_skb, OAM_DATA_TYPE_STRING, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; }
/***************************************************************************** 函 数 名 : oam_report_vap_pkt_stat_to_sdt 功能描述 : 将某一个vap下的收发包统计信息上报sdt 输入参数 : 无 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年7月10日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 oam_report_vap_pkt_stat_to_sdt(oal_uint8 uc_vap_id) { oal_uint32 ul_tick; oal_uint16 us_skb_len; /* skb总长度 */ oal_netbuf_stru *pst_netbuf; oam_ota_stru *pst_ota_data; oal_uint32 ul_ret = OAL_SUCC; oal_uint16 us_stat_info_len; if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return OAL_ERR_CODE_PTR_NULL; } us_stat_info_len = OAL_SIZEOF(oam_vap_stat_info_stru); /* 为上报统计信息申请空间,头部预留8字节,尾部预留1字节,给sdt_drv用 */ us_skb_len = us_stat_info_len + OAL_SIZEOF(oam_ota_hdr_stru); pst_netbuf = oam_alloc_data2sdt(us_skb_len); if (OAL_PTR_NULL == pst_netbuf) { return OAL_ERR_CODE_PTR_NULL; } pst_ota_data = (oam_ota_stru *)oal_netbuf_data(pst_netbuf); /* 获取系统TICK值 */ ul_tick = (oal_uint32)OAL_TIME_GET_STAMP_MS(); /* 填写ota消息头结构体 */ pst_ota_data->st_ota_hdr.ul_tick = ul_tick; pst_ota_data->st_ota_hdr.en_ota_type = OAM_OTA_TYPE_VAP_STAT_INFO; pst_ota_data->st_ota_hdr.us_ota_data_len = us_stat_info_len; pst_ota_data->st_ota_hdr.uc_frame_hdr_len = 0; oal_set_mac_addr(pst_ota_data->st_ota_hdr.auc_user_macaddr, BROADCAST_MACADDR); /* 复制数据,填写ota数据 */ oal_memcopy((oal_void *)pst_ota_data->auc_ota_data, (const oal_void *)&g_st_stat_info.ast_vap_stat_info[uc_vap_id], us_stat_info_len); /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_netbuf, OAM_DATA_TYPE_OTA, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; }
oal_uint32 dmac_data_acq_get_record(oal_void) { oal_netbuf_stru *pst_queue_netbuf; dmac_data_acq_info_stru *pst_daq_info; oal_uint32 ul_ret = OAL_FAIL; /* 采集完成可以上传数据 */ if (DMAC_DATA_ACQ_STATUS_COMPLETE == g_st_data_acq.en_daq_status) { /* 上传数据 */ g_st_data_acq.en_daq_app_error = OAL_FALSE; pst_queue_netbuf = OAL_MEM_NETBUF_ALLOC(OAL_NORMAL_NETBUF, DMAC_DATA_ACQ_UNIT_MAX_LEN, OAL_NETBUF_PRIORITY_MID); if (OAL_PTR_NULL == pst_queue_netbuf) { OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_data_acq_get_record::pst_queue_netbuf null.}"); return OAL_ERR_CODE_PTR_NULL; } pst_daq_info = (dmac_data_acq_info_stru *)oal_netbuf_data(pst_queue_netbuf); pst_daq_info->ul_daq_addr = (oal_uint32)g_st_data_acq.st_daq_prep_info.puc_start_addr; pst_daq_info->ul_data_len = g_st_data_acq.ul_length; pst_daq_info->ul_unit_len = DMAC_DATA_ACQ_UNIT_DATA_LEN; oal_netbuf_add_to_list_tail(pst_queue_netbuf, &g_st_data_acq.st_daq_workqueue.rx_daq_dbg_seq); oal_queue_work(g_st_data_acq.st_daq_workqueue.daq_rx_workqueue, &g_st_data_acq.st_daq_workqueue.rx_daq_work); ul_ret = OAL_SUCC; } else { /* 数据采集未完成,不允许上传数据 */ OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_data_acq_get_record::data acq is running.}"); ul_ret = OAL_FAIL; } return ul_ret; }
OAL_STATIC oal_bool_enum_uint8 dmac_11w_robust_action(oal_netbuf_stru *pst_mgmt_buf) { oal_uint8 uc_frame_type; oal_uint8 *puc_mac_header = oal_netbuf_header(pst_mgmt_buf); #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE) oal_uint8 *puc_mac_payload = oal_netbuf_data(pst_mgmt_buf); #else oal_uint8 *puc_mac_payload = puc_mac_header + MAC_80211_FRAME_LEN; #endif uc_frame_type = mac_frame_get_subtype_value(puc_mac_header); if (WLAN_ACTION != uc_frame_type) { return OAL_FALSE; } switch (puc_mac_payload[MAC_ACTION_OFFSET_CATEGORY]) { case MAC_ACTION_CATEGORY_SPECMGMT: case MAC_ACTION_CATEGORY_QOS: case MAC_ACTION_CATEGORY_DLS: case MAC_ACTION_CATEGORY_BA: case MAC_ACTION_CATEGORY_RADIO_MEASURMENT: case MAC_ACTION_CATEGORY_FAST_BSS_TRANSITION: case MAC_ACTION_CATEGORY_HT: case MAC_ACTION_CATEGORY_SA_QUERY: case MAC_ACTION_CATEGORY_PROTECTED_DUAL_OF_ACTION: case MAC_ACTION_CATEGORY_WNM: case MAC_ACTION_CATEGORY_MESH: case MAC_ACTION_CATEGORY_MULTIHOP: case MAC_ACTION_CATEGORY_VENDOR_SPECIFIC_PROTECTED: { return OAL_TRUE; } default: break; } return OAL_FALSE; }
oal_int32 oam_rx_post_action_function(oal_uint8 stype, hcc_netbuf_stru* pst_hcc_netbuf, oal_uint8 *pst_context) { oal_uint8 *puc_data; OAL_REFERENCE(pst_context); OAL_BUG_ON(NULL == pst_hcc_netbuf); puc_data = oal_netbuf_data(pst_hcc_netbuf->pst_netbuf); if((DUMP_REG == stype) || (DUMP_MEM == stype)) { //AL_IO_PRINT("receive dump msg = %d\n", stype); exception_bcpu_dump_recv(puc_data,pst_hcc_netbuf->pst_netbuf); oal_netbuf_free(pst_hcc_netbuf->pst_netbuf); return OAL_SUCC; } /* 调用OAM接口*/ oam_send_device_data2sdt(puc_data, (oal_uint16)pst_hcc_netbuf->len); oal_netbuf_free(pst_hcc_netbuf->pst_netbuf); return OAL_SUCC; }
/***************************************************************************** 函 数 名 : oam_stats_report_timer_info_to_sdt 功能描述 : 将软件定时器的信息上报SDT 输入参数 : puc_timer_addr:定时器结构的地址 uc_timer_len :定时器结构的长度 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年2月21日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 oam_stats_report_timer_info_to_sdt( oal_uint8 *puc_timer_addr, oal_uint8 uc_timer_len) { oal_uint32 ul_ret = OAL_SUCC; if (NULL != puc_timer_addr) { ul_ret = oam_ota_report(puc_timer_addr, uc_timer_len, 0, 0, OAM_OTA_TYPE_TIMER); return ul_ret; } else { OAL_IO_PRINT("oam_stats_report_timer_info_to_sdt::puc_timer_addr is NULL"); return OAL_ERR_CODE_PTR_NULL; } #if 0 oal_uint32 ul_tick; oal_uint16 us_skb_len; /* skb总长度 */ oal_netbuf_stru *pst_netbuf; oam_ota_stru *pst_ota_data; oal_uint32 ul_ret = OAL_SUCC; if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return OAL_ERR_CODE_PTR_NULL; } if (OAL_PTR_NULL == puc_timer_addr) { OAL_IO_PRINT("oam_stats_report_timer_info_to_sdt::puc_timer_addr is null!\n"); return OAL_ERR_CODE_PTR_NULL; } if (OAM_TIMER_MAX_LEN < uc_timer_len) { OAL_IO_PRINT("oam_stats_report_timer_info_to_sdt::uc_timer_len-->%d\n", uc_timer_len); return OAL_FAIL; } /* 为上报描述符申请空间,头部预留8字节,尾部预留1字节,给sdt_drv用 */ us_skb_len = uc_timer_len + OAL_SIZEOF(oam_ota_hdr_stru); pst_netbuf = oam_alloc_data2sdt(us_skb_len); if (OAL_PTR_NULL == pst_netbuf) { return OAL_ERR_CODE_PTR_NULL; } pst_ota_data = (oam_ota_stru *)oal_netbuf_data(pst_netbuf); /* 获取系统TICK值 */ ul_tick = (oal_uint32)OAL_TIME_GET_STAMP_MS(); /* 填写ota消息头结构体 */ pst_ota_data->st_ota_hdr.ul_tick = ul_tick; pst_ota_data->st_ota_hdr.en_ota_type = OAM_OTA_TYPE_TIMER; pst_ota_data->st_ota_hdr.uc_frame_hdr_len = 0; pst_ota_data->st_ota_hdr.us_ota_data_len = uc_timer_len; /* 复制数据,填写ota数据 */ oal_memcopy((oal_void *)pst_ota_data->auc_ota_data, (const oal_void *)puc_timer_addr, (oal_uint32)uc_timer_len); /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_netbuf, OAM_DATA_TYPE_OTA, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; #endif }
OAL_STATIC oal_uint32 host_test_get_chip_msg(oal_void) { oal_uint32 ul_return; mac_chip_stru *pst_chip; frw_event_mem_stru *pst_event_mem; frw_event_stru *pst_event; /* 事件结构体 */ oal_uint32 ul_dev_id; oal_netbuf_stru *pst_netbuf; dmac_tx_event_stru *pst_ctx_event; oal_uint8 *pst_mac_rates_11g; /** 待补充 ***/ pst_event_mem = FRW_EVENT_ALLOC(OAL_SIZEOF(dmac_tx_event_stru)); if (OAL_UNLIKELY(OAL_PTR_NULL == pst_event_mem)) { OAL_IO_PRINT("host_test_get_chip_msg: hmac_init_event_process FRW_EVENT_ALLOC result = OAL_PTR_NULL.\n"); return OAL_FAIL; } /* 申请netbuf内存 */ pst_netbuf = OAL_MEM_NETBUF_ALLOC(OAL_NORMAL_NETBUF, WLAN_MEM_NETBUF_SIZE2, OAL_NETBUF_PRIORITY_MID); if (OAL_UNLIKELY(OAL_PTR_NULL == pst_netbuf)) { OAL_IO_PRINT("host_test_get_chip_msg: hmac_init_event_process OAL_MEM_NETBUF_ALLOC result = OAL_PTR_NULL.\n"); return OAL_FAIL; } pst_event = (frw_event_stru *)pst_event_mem->puc_data; pst_ctx_event = (dmac_tx_event_stru *)pst_event->auc_event_data; pst_ctx_event->pst_netbuf = pst_netbuf; pst_mac_rates_11g = (oal_uint8*)oal_netbuf_data(pst_ctx_event->pst_netbuf); pst_chip = (mac_chip_stru *)(pst_mac_rates_11g + sizeof(mac_data_rate_stru) * MAC_DATARATES_PHY_80211G_NUM); ul_dev_id = (oal_uint32) oal_queue_dequeue(&(g_st_mac_res.st_dev_res.st_queue)); /* 0为无效值 */ if (0 == ul_dev_id) { OAL_IO_PRINT("host_test_get_chip_msg:oal_queue_dequeue return 0!"); FRW_EVENT_FREE(pst_event_mem); return OAL_FAIL; } pst_chip->auc_device_id[0] = (oal_uint8)(ul_dev_id - 1); /* 根据ul_chip_ver,通过hal_chip_init_by_version函数获得 */ pst_chip->uc_device_nums = 1; pst_chip->uc_chip_id = 0; pst_chip->en_chip_state = OAL_TRUE; /* 由hal_chip_get_version函数得到,1102 02需要SOC提供寄存器后实现 */ pst_chip->ul_chip_ver = WLAN_CHIP_VERSION_HI1151V100H; pst_chip->pst_chip_stru = OAL_PTR_NULL; ul_return = hmac_init_event_process(pst_event_mem); if(OAL_UNLIKELY(ul_return != OAL_SUCC)) { OAL_IO_PRINT("host_test_get_chip_msg: hmac_init_event_process ul_return != OAL_SUCC\n"); FRW_EVENT_FREE(pst_event_mem); oal_netbuf_free(pst_netbuf); return OAL_FAIL; } return OAL_SUCC; }
oal_netbuf_stru* hmac_defrag_process(hmac_user_stru *pst_hmac_user, oal_netbuf_stru *pst_netbuf, oal_uint32 ul_hrdsize) { mac_ieee80211_frame_stru *pst_mac_hdr = OAL_PTR_NULL; mac_ieee80211_frame_stru *pst_last_hdr = OAL_PTR_NULL; oal_uint16 us_rx_seq = 0; oal_uint16 us_last_seq = 0; oal_uint8 uc_frag_num = 0; oal_uint8 uc_last_frag_num = 0; oal_bool_enum_uint8 en_more_frag = OAL_FALSE; oal_netbuf_stru *pst_new_buf = OAL_PTR_NULL; mac_rx_ctl_stru *pst_rx_ctl; oal_uint32 ul_ret; oal_uint8 uc_device_id; mac_device_stru *pst_mac_device; oal_uint32 ul_core_id; pst_mac_hdr = (mac_ieee80211_frame_stru *)oal_netbuf_data(pst_netbuf); us_rx_seq = pst_mac_hdr->bit_seq_num; uc_frag_num = (oal_uint8)pst_mac_hdr->bit_frag_num; en_more_frag = (oal_bool_enum_uint8)pst_mac_hdr->st_frame_control.bit_more_frag; /* 如果没有什么可以去分片的则直接返回 */ if (!en_more_frag && 0 == uc_frag_num && OAL_PTR_NULL == pst_hmac_user->pst_defrag_netbuf) { return pst_netbuf; } OAL_MEM_NETBUF_TRACE(pst_netbuf, OAL_FALSE); /* 首先检查到来的分片报文是不是属于正在重组的分片报文 */ if (pst_hmac_user->pst_defrag_netbuf) { frw_timer_restart_timer(&pst_hmac_user->st_defrag_timer, HMAC_FRAG_TIMEOUT, OAL_FALSE); pst_last_hdr = (mac_ieee80211_frame_stru *)oal_netbuf_data(pst_hmac_user->pst_defrag_netbuf); us_last_seq = pst_last_hdr->bit_seq_num; uc_last_frag_num = (oal_uint8)pst_last_hdr->bit_frag_num; /* 如果地址不匹配,序列号不匹配,分片号不匹配则释放现在正在重组的报文 */ if (us_rx_seq != us_last_seq || uc_frag_num != (uc_last_frag_num + 1) || oal_compare_mac_addr(pst_last_hdr->auc_address1, pst_mac_hdr->auc_address1) || oal_compare_mac_addr(pst_last_hdr->auc_address2, pst_mac_hdr->auc_address2)) { oal_netbuf_free(pst_hmac_user->pst_defrag_netbuf); FRW_TIMER_IMMEDIATE_DESTROY_TIMER(&pst_hmac_user->st_defrag_timer); pst_hmac_user->pst_defrag_netbuf = OAL_PTR_NULL; } } /* 判断到来的分片报文是否是第一个分片 */ if (OAL_PTR_NULL == pst_hmac_user->pst_defrag_netbuf) { /* 首片分片的分片号不为0则释放 */ if (uc_frag_num != 0) { oal_netbuf_free(pst_netbuf); OAM_STAT_VAP_INCR(pst_hmac_user->st_user_base_info.uc_vap_id, rx_defrag_process_dropped, 1); OAM_INFO_LOG3(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::The first frag_num is not Zero(%d), seq_num[%d], mor_frag[%d].}", uc_frag_num, us_rx_seq, en_more_frag); return OAL_PTR_NULL; } /* 没有分片,直接返回 */ if (0 == en_more_frag && 0 == uc_frag_num) { return pst_netbuf; } uc_device_id = pst_hmac_user->st_user_base_info.uc_device_id; pst_mac_device = mac_res_get_dev((oal_uint32)uc_device_id); if (OAL_PTR_NULL == pst_mac_device) { OAM_ERROR_LOG4(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::user index[%d] user mac:XX:XX:XX:%02X:%02X:%02X}", pst_hmac_user->st_user_base_info.us_assoc_id, pst_hmac_user->st_user_base_info.auc_user_mac_addr[3], pst_hmac_user->st_user_base_info.auc_user_mac_addr[4], pst_hmac_user->st_user_base_info.auc_user_mac_addr[5]); /* user异常,丢弃报文 */ oal_netbuf_free(pst_netbuf); OAM_STAT_VAP_INCR(pst_hmac_user->st_user_base_info.uc_vap_id, rx_defrag_process_dropped, 1); return OAL_PTR_NULL; } ul_core_id = pst_mac_device->ul_core_id; /* 启动超时定时器,超时释放重组报文 */ FRW_TIMER_CREATE_TIMER(&pst_hmac_user->st_defrag_timer, hmac_defrag_timeout_fn, HMAC_FRAG_TIMEOUT, pst_hmac_user, OAL_FALSE, OAM_MODULE_ID_HMAC, ul_core_id); /* 内存池netbuf只有1600 可能不够,参照A公司申请2500操作系统原生态报文 */ pst_new_buf = OAL_MEM_NETBUF_ALLOC(OAL_NORMAL_NETBUF, HMAC_MAX_FRAG_SIZE, OAL_NETBUF_PRIORITY_MID); if (OAL_PTR_NULL == pst_new_buf) { OAM_ERROR_LOG1(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::Alloc new_buf null,size[%d].}", HMAC_MAX_FRAG_SIZE); return OAL_PTR_NULL; } OAL_MEM_NETBUF_TRACE(pst_new_buf, OAL_FALSE); /* 将分片报文拷贝到新申请的报文中并挂接到用户结构体下,释放原有的报文 */ oal_netbuf_init(pst_new_buf, OAL_NETBUF_LEN(pst_netbuf)); oal_netbuf_copydata(pst_netbuf, 0, oal_netbuf_data(pst_new_buf), OAL_NETBUF_LEN(pst_netbuf)); oal_memcopy(OAL_NETBUF_CB(pst_new_buf), OAL_NETBUF_CB(pst_netbuf), MAC_TX_CTL_SIZE); pst_rx_ctl = (mac_rx_ctl_stru *)OAL_NETBUF_CB(pst_new_buf); pst_rx_ctl->pul_mac_hdr_start_addr = (oal_uint32 *)OAL_NETBUF_HEADER(pst_new_buf); pst_hmac_user->pst_defrag_netbuf = pst_new_buf; oal_netbuf_free(pst_netbuf); pst_netbuf = pst_new_buf; } else { if (OAL_UNLIKELY(OAL_PTR_NULL == pst_last_hdr)) { OAM_ERROR_LOG0(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::pst_last_hdr is NULL.}"); return OAL_PTR_NULL; } /* 此分片是期望的到来的分片,重启定时器,并进行重组 */ frw_timer_restart_timer(&pst_hmac_user->st_defrag_timer, HMAC_FRAG_TIMEOUT, OAL_FALSE); oal_netbuf_pull(pst_netbuf, ul_hrdsize); /* 记录最新分片报文的分片号 */ pst_last_hdr->bit_seq_num = pst_mac_hdr->bit_seq_num; pst_last_hdr->bit_frag_num = pst_mac_hdr->bit_frag_num; /*此接口内会调用dev_kfree_skb*/ oal_netbuf_concat(pst_hmac_user->pst_defrag_netbuf, pst_netbuf); } /* 判断是否重组完毕,存在更多报文返回空指针,重组完毕返回组好的报文 */ if (en_more_frag) { pst_netbuf = OAL_PTR_NULL; } else { if (OAL_UNLIKELY(OAL_PTR_NULL == pst_last_hdr)) { OAM_ERROR_LOG0(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::pst_last_hdr is NULL.}"); oal_netbuf_free(pst_netbuf); pst_hmac_user->pst_defrag_netbuf = OAL_PTR_NULL; return OAL_PTR_NULL; } pst_netbuf = pst_hmac_user->pst_defrag_netbuf; /* 对重组好的报文进行mic检查 */ ul_ret = hmac_de_mic(pst_hmac_user, pst_netbuf); if (OAL_SUCC != ul_ret) { oal_netbuf_free(pst_netbuf); OAM_STAT_VAP_INCR(pst_hmac_user->st_user_base_info.uc_vap_id, rx_de_mic_fail_dropped, 1); pst_netbuf = OAL_PTR_NULL; OAM_INFO_LOG1(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::hmac_de_mic failed[%d].}", ul_ret); } pst_hmac_user->pst_defrag_netbuf = OAL_PTR_NULL; pst_last_hdr->bit_frag_num = 0; FRW_TIMER_IMMEDIATE_DESTROY_TIMER(&pst_hmac_user->st_defrag_timer); } return pst_netbuf; }
/***************************************************************************** 函 数 名 : oam_stats_report_stat_info_to_sdt 功能描述 : 将所有维测统计信息上报SDT工具 输入参数 : 无 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年3月18日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 oam_stats_report_info_to_sdt(oam_ota_type_enum_uint8 en_ota_type) { oal_uint32 ul_tick; oal_uint16 us_skb_len; /* skb总长度 */ oal_netbuf_stru *pst_netbuf; oam_ota_stru *pst_ota_data; oal_uint32 ul_ret = OAL_SUCC; oal_uint16 us_stat_info_len; if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return OAL_ERR_CODE_PTR_NULL; } switch (en_ota_type) { case OAM_OTA_TYPE_DEV_STAT_INFO: us_stat_info_len = OAL_SIZEOF(oam_device_stat_info_stru) * WLAN_DEVICE_MAX_NUM_PER_CHIP; break; case OAM_OTA_TYPE_VAP_STAT_INFO: us_stat_info_len = (oal_uint16)(OAL_SIZEOF(oam_vap_stat_info_stru) * WLAN_VAP_SUPPORT_MAX_NUM_LIMIT); break; default: us_stat_info_len = 0; break; } if (0 == us_stat_info_len) { OAL_IO_PRINT("oam_stats_report_info_to_sdt::ota_type invalid-->%d!\n", en_ota_type); return OAL_ERR_CODE_INVALID_CONFIG; } /* 为上报统计信息申请空间,头部预留8字节,尾部预留1字节,给sdt_drv用 */ us_skb_len = us_stat_info_len + OAL_SIZEOF(oam_ota_hdr_stru); if (us_skb_len > WLAN_SDT_NETBUF_MAX_PAYLOAD) { us_skb_len = WLAN_SDT_NETBUF_MAX_PAYLOAD; us_stat_info_len = WLAN_SDT_NETBUF_MAX_PAYLOAD - OAL_SIZEOF(oam_ota_hdr_stru); } pst_netbuf = oam_alloc_data2sdt(us_skb_len); if (OAL_PTR_NULL == pst_netbuf) { return OAL_ERR_CODE_PTR_NULL; } pst_ota_data = (oam_ota_stru *)oal_netbuf_data(pst_netbuf); /* 获取系统TICK值 */ ul_tick = (oal_uint32)OAL_TIME_GET_STAMP_MS(); /* 填写ota消息头结构体 */ pst_ota_data->st_ota_hdr.ul_tick = ul_tick; pst_ota_data->st_ota_hdr.en_ota_type = en_ota_type; pst_ota_data->st_ota_hdr.uc_frame_hdr_len = 0; pst_ota_data->st_ota_hdr.us_ota_data_len = us_stat_info_len; /* 复制数据,填写ota数据 */ switch (en_ota_type) { case OAM_OTA_TYPE_DEV_STAT_INFO: oal_memcopy((oal_void *)pst_ota_data->auc_ota_data, (const oal_void *)g_st_stat_info.ast_dev_stat_info, us_stat_info_len); break; case OAM_OTA_TYPE_VAP_STAT_INFO: oal_memcopy((oal_void *)pst_ota_data->auc_ota_data, (const oal_void *)g_st_stat_info.ast_vap_stat_info, us_stat_info_len); break; default: break; } /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_netbuf, OAM_DATA_TYPE_OTA, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; }
/***************************************************************************** 函 数 名 : oam_stats_report_memblock_info_to_sdt 功能描述 : 将标准内存块的信息上报SDT 输入参数 : puc_origin_data:内存块的起始地址 uc_user_cnt :该内存块引用计数 uc_pool_id :所属的内存池id uc_subpool_id :所属的子池id us_len :该内存块长度 ul_file_id :申请该内存块的文件id ul_alloc_line_num :申请该内存块的行号 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年2月21日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 oam_stats_report_memblock_info_to_sdt( oal_uint8 *puc_origin_data, oal_uint8 uc_user_cnt, oal_uint8 uc_pool_id, oal_uint8 uc_subpool_id, oal_uint16 us_len, oal_uint32 ul_file_id, oal_uint32 ul_alloc_line_num) { oam_memblock_info_stru st_memblock_info; oal_uint16 us_memblock_info_len; oal_netbuf_stru *pst_netbuf; oam_ota_stru *pst_ota_data; oal_uint16 us_skb_len; /* skb总长度 */ oal_uint32 ul_tick; oal_uint32 ul_ret = OAL_SUCC; if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return OAL_ERR_CODE_PTR_NULL; } if (OAL_PTR_NULL == puc_origin_data) { OAL_IO_PRINT("oam_stats_report_memblock_info_to_sdt:puc_origin_data is null!\n"); return OAL_ERR_CODE_PTR_NULL; } us_memblock_info_len = OAL_SIZEOF(oam_memblock_info_stru); /* 填写要上报给sdt的内存块信息结构体 */ st_memblock_info.uc_pool_id = uc_pool_id; st_memblock_info.uc_subpool_id = uc_subpool_id; st_memblock_info.uc_user_cnt = uc_user_cnt; st_memblock_info.ul_alloc_line_num = ul_alloc_line_num; st_memblock_info.ul_file_id = ul_file_id; /* 为ota消息上报SDT申请空间,头部预留8字节,尾部预留1字节,给sdt_drv用 */ us_skb_len = us_memblock_info_len + us_len + OAL_SIZEOF(oam_ota_hdr_stru); if (us_skb_len > WLAN_SDT_NETBUF_MAX_PAYLOAD) { us_skb_len = WLAN_SDT_NETBUF_MAX_PAYLOAD; if ((us_memblock_info_len + OAL_SIZEOF(oam_ota_hdr_stru)) < us_skb_len) { us_len = us_skb_len - us_memblock_info_len - (oal_uint16)OAL_SIZEOF(oam_ota_hdr_stru); } else { us_memblock_info_len = us_skb_len - OAL_SIZEOF(oam_ota_hdr_stru); us_len = 0; } } pst_netbuf = oam_alloc_data2sdt(us_skb_len); if (OAL_PTR_NULL == pst_netbuf) { return OAL_ERR_CODE_PTR_NULL; } pst_ota_data = (oam_ota_stru *)oal_netbuf_data(pst_netbuf); /* 获取系统TICK值 */ ul_tick = (oal_uint32)OAL_TIME_GET_STAMP_MS(); /* 填写ota消息结构体 */ pst_ota_data->st_ota_hdr.ul_tick = ul_tick; pst_ota_data->st_ota_hdr.en_ota_type = OAM_OTA_TYPE_MEMBLOCK; pst_ota_data->st_ota_hdr.uc_frame_hdr_len = (oal_uint8)us_memblock_info_len; pst_ota_data->st_ota_hdr.us_ota_data_len = us_memblock_info_len + us_len; /* 填写ota数据部分,首先复制内存块的信息结构体 */ oal_memcopy((oal_void *)pst_ota_data->auc_ota_data, (const oal_void *)&st_memblock_info, (oal_uint32)us_memblock_info_len); /* 复制内存块的具体内容 *//*lint -e416*/ oal_memcopy((oal_void *)(pst_ota_data->auc_ota_data + us_memblock_info_len), (const oal_void *)puc_origin_data, (oal_uint32)us_len); /*lint +e416*/ /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_netbuf, OAM_DATA_TYPE_OTA, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; }
/***************************************************************************** 函 数 名 : sdt_drv_send_data_to_wifi 功能描述 : 从app侧接收到数据,解析该数据的头部信息,确定是数据的去向,然后 调用相应的51驱动侧接口 输入参数 : 无 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年1月27日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_int32 sdt_drv_send_data_to_wifi(oal_uint8 *puc_param, oal_int32 l_len) { oal_netbuf_stru *pst_netbuf; oal_int8 *pc_buf; oal_int i_len; /* SDIO CRC ERROR */ oal_int32 l_ret = OAL_EFAIL; oal_uint8 *puc_data; if (OAL_PTR_NULL == puc_param) { OAL_IO_PRINT("sdt_drv_send_data_to_wifi::puc_param is null!\n"); return -OAL_EFAIL; } i_len = (oal_int)l_len > 300 ? (oal_int)l_len: 300; /* 接收消息不用填充头,直接使用 */ pst_netbuf = oal_mem_sdt_netbuf_alloc((oal_uint16)i_len, OAL_TRUE); if (OAL_PTR_NULL == pst_netbuf) { return -OAL_EFAIL; } pc_buf = (oal_int8 *)oal_netbuf_put(pst_netbuf, (oal_uint32)l_len); oal_memcopy((oal_void *)pc_buf, (const oal_void *)puc_param, (oal_uint32)l_len); i_len = pc_buf[5]*MAX_NUM; i_len = pc_buf[4] + i_len; i_len = i_len - OAM_RESERVE_SKB_LEN; puc_data = oal_netbuf_data(pst_netbuf); switch(pc_buf[1]) { case OAM_DATA_TYPE_MEM_RW: if (OAL_PTR_NULL != g_st_oam_wal_func_hook.p_wal_recv_mem_data_func) { l_ret = g_st_oam_wal_func_hook.p_wal_recv_mem_data_func(&puc_data[8], (oal_uint16)i_len); } break; case OAM_DATA_TYPE_REG_RW: if (OAL_PTR_NULL != g_st_oam_wal_func_hook.p_wal_recv_reg_data_func) { l_ret = g_st_oam_wal_func_hook.p_wal_recv_reg_data_func(&puc_data[8], (oal_uint16)i_len); } break; case OAM_DATA_TYPE_CFG: if (OAL_PTR_NULL != g_st_oam_wal_func_hook.p_wal_recv_cfg_data_func) { l_ret = g_st_oam_wal_func_hook.p_wal_recv_cfg_data_func(&puc_data[8], (oal_uint16)i_len); } break; case OAM_DATA_TYPE_GVAR_RW: if (OAL_PTR_NULL != g_st_oam_wal_func_hook.p_wal_recv_global_var_func) { l_ret = g_st_oam_wal_func_hook.p_wal_recv_global_var_func(&puc_data[8], (oal_uint16)i_len); } break; default: OAL_IO_PRINT("sdt_drv_send_data_to_wifi::cmd is invalid!!-->%d\n", pc_buf[1]); break; } #if (_PRE_OS_VERSION_RAW != _PRE_OS_VERSION) oal_mem_sdt_netbuf_free(pst_netbuf, OAL_TRUE); #endif //oal_netbuf_free(pst_netbuf); return l_ret; }
/***************************************************************************** 函 数 名 : sdt_drv_netlink_send 功能描述 : SDT驱动侧通过netlink向SDT APP发送数据 记录待发送的数据与发送失败的数据;通过序列号记录 输入参数 : 无 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年1月27日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 sdt_drv_netlink_send(oal_netbuf_stru *pst_netbuf, oal_uint32 ul_len) { #if (_PRE_OS_VERSION_RAW != _PRE_OS_VERSION) #if((_PRE_TARGET_PRODUCT_TYPE_5610DMB == _PRE_CONFIG_TARGET_PRODUCT)\ ||(_PRE_TARGET_PRODUCT_TYPE_VSPM310DMB == _PRE_CONFIG_TARGET_PRODUCT)\ ||(_PRE_TARGET_PRODUCT_TYPE_WS835DMB == _PRE_CONFIG_TARGET_PRODUCT)) oal_int32 l_ret_len = 0; sdt_drv_pkt_hdr_stru *p_sdt_hdr; #endif oal_netbuf_stru *pst_copy_netbuf; oal_nlmsghdr_stru *pst_nlhdr; oal_uint32 ul_nlmsg_len; oal_int32 l_unicast_bytes = 0; /* 由上层保证参数非空 */ /* 如果没有与app建立连接,则直接返回,每500次打印一次提示信息 */ if (0 == g_st_sdt_drv_mng_entry.ul_usepid) { if (0 == (oal_atomic_read(&g_st_sdt_drv_mng_entry.ul_unconnect_cnt) % SDT_DRV_REPORT_NO_CONNECT_FREQUENCE)) { OAL_IO_PRINT("Info:waitting app_sdt start...\r\n"); oal_atomic_inc(&g_st_sdt_drv_mng_entry.ul_unconnect_cnt); } oal_mem_sdt_netbuf_free(pst_netbuf, OAL_TRUE); //oal_netbuf_free(pst_netbuf); return OAL_FAIL; } #if ((_PRE_TARGET_PRODUCT_TYPE_5610DMB == _PRE_CONFIG_TARGET_PRODUCT)\ ||(_PRE_TARGET_PRODUCT_TYPE_VSPM310DMB == _PRE_CONFIG_TARGET_PRODUCT)\ ||(_PRE_TARGET_PRODUCT_TYPE_WS835DMB == _PRE_CONFIG_TARGET_PRODUCT)) // 数据包分析 p_sdt_hdr = (sdt_drv_pkt_hdr_stru*)oal_netbuf_data(pst_netbuf); if (OAM_DATA_TYPE_LOG == p_sdt_hdr->en_msg_type || OAM_DATA_TYPE_OTA == p_sdt_hdr->en_msg_type) { if (0 == g_st_count) { ul_nlmsg_len = OAL_NLMSG_LENGTH(MAX_NLMSG_LEN); g_pst_copy_netbuf = oal_netbuf_alloc(ul_nlmsg_len, 0, WLAN_MEM_NETBUF_ALIGN); if (OAL_UNLIKELY(OAL_PTR_NULL == g_pst_copy_netbuf)) { oal_mem_sdt_netbuf_free(pst_netbuf, OAL_TRUE); //oal_netbuf_free(pst_netbuf); OAL_IO_PRINT("oal_netbuf_alloc failed. \r\n"); return OAL_FAIL; } g_pst_nlhdr = oal_nlmsg_put(g_pst_copy_netbuf, 0, 0, 0, (oal_int32)MAX_NLMSG_LEN, 0); } if (NULL != g_pst_nlhdr) { l_ret_len = MAX_NLMSG_LEN - g_buf_offset - ul_len; if (l_ret_len > 0) { oal_memcopy((oal_void *)OAL_NLMSG_DATA(g_pst_nlhdr) + g_buf_offset, (const oal_void *)oal_netbuf_data(pst_netbuf), ul_len); g_st_count++; g_buf_offset += ul_len; } } if (MAX_QUEUE_COUNT == g_st_count || g_buf_offset > MAX_CO_SIZE || l_ret_len < 0) { g_st_count = 0; g_buf_offset = 0; l_unicast_bytes = oal_netlink_unicast(g_st_sdt_drv_mng_entry.pst_nlsk, g_pst_copy_netbuf, g_st_sdt_drv_mng_entry.ul_usepid, 0); oal_msleep(300); OAM_SDT_STAT_INCR(ul_nlk_sd_cnt); if (l_unicast_bytes <= 0) { oal_mem_sdt_netbuf_free(pst_netbuf, OAL_TRUE); //oal_netbuf_free(pst_netbuf); oal_msleep(500); OAM_SDT_STAT_INCR(ul_nlk_sd_fail); return OAL_FAIL; } } oal_mem_sdt_netbuf_free(pst_netbuf, OAL_TRUE); return OAL_SUCC; } #endif /* 填写netlink消息头 */ ul_nlmsg_len = OAL_NLMSG_SPACE(ul_len); pst_copy_netbuf = oal_netbuf_alloc(ul_nlmsg_len, 0, WLAN_MEM_NETBUF_ALIGN); if (OAL_UNLIKELY(OAL_PTR_NULL == pst_copy_netbuf)) { oal_mem_sdt_netbuf_free(pst_netbuf, OAL_TRUE); //oal_netbuf_free(pst_netbuf); OAL_IO_PRINT("oal_netbuf_alloc failed. \r\n"); return OAL_FAIL; } pst_nlhdr = oal_nlmsg_put(pst_copy_netbuf, 0, 0, 0, (oal_int32)ul_len, 0); oal_memcopy((oal_void *)OAL_NLMSG_DATA(pst_nlhdr), (const oal_void *)oal_netbuf_data(pst_netbuf), ul_len); l_unicast_bytes = oal_netlink_unicast(g_st_sdt_drv_mng_entry.pst_nlsk, pst_copy_netbuf, g_st_sdt_drv_mng_entry.ul_usepid, OAL_MSG_DONTWAIT); oal_mem_sdt_netbuf_free(pst_netbuf, OAL_TRUE); //oal_netbuf_free(pst_netbuf); OAM_SDT_STAT_INCR(ul_nlk_sd_cnt); if (l_unicast_bytes <= 0) { OAM_SDT_STAT_INCR(ul_nlk_sd_fail); return OAL_FAIL; } #endif return OAL_SUCC; }
/***************************************************************************** 函 数 名 : oam_stats_report_mempool_info_to_sdt 功能描述 : 将内存池的某一个子池内存块的使用情况上报sdt 输入参数 : uc_pool_id :内存池id us_pool_total_cnt :本内存池一共多少内存块 us_pool_used_cnt :本内存池已用内存块 uc_subpool_id :子池id us_subpool_total_cnt :本子池内存块总数 us_subpool_free_cnt :本子池可用内存块个数 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2014年2月21日 作 者 : z00237171 修改内容 : 新生成函数 *****************************************************************************/ oal_uint32 oam_stats_report_mempool_info_to_sdt( oal_uint8 uc_pool_id, oal_uint16 us_pool_total_cnt, oal_uint16 us_pool_used_cnt, oal_uint8 uc_subpool_id, oal_uint16 us_subpool_total_cnt, oal_uint16 us_subpool_free_cnt) { oam_stats_mempool_stru st_device_mempool_info; oal_netbuf_stru *pst_netbuf; oam_ota_stru *pst_ota_data; oal_uint16 us_skb_len; /* skb总长度 */ oal_uint32 ul_tick; oal_uint32 ul_ret = OAL_SUCC; oal_uint16 us_stru_len; if (OAL_UNLIKELY(OAL_PTR_NULL == g_st_oam_sdt_func_hook.p_sdt_report_data_func)) { return OAL_ERR_CODE_PTR_NULL; } /* 填写要上报给sdt的内存池信息结构体 */ st_device_mempool_info.uc_mem_pool_id = uc_pool_id; st_device_mempool_info.uc_subpool_id = uc_subpool_id; st_device_mempool_info.us_mem_pool_total_cnt = us_pool_total_cnt; st_device_mempool_info.us_mem_pool_used_cnt = us_pool_used_cnt; st_device_mempool_info.us_subpool_total_cnt = us_subpool_total_cnt; st_device_mempool_info.us_subpool_free_cnt = us_subpool_free_cnt; us_stru_len = OAL_SIZEOF(oam_stats_mempool_stru); /* 为ota消息上报SDT申请空间,头部预留8字节,尾部预留1字节,给sdt_drv用 */ us_skb_len = us_stru_len + OAL_SIZEOF(oam_ota_hdr_stru); if (us_skb_len > WLAN_SDT_NETBUF_MAX_PAYLOAD) { us_skb_len = WLAN_SDT_NETBUF_MAX_PAYLOAD; us_stru_len = us_skb_len - OAL_SIZEOF(oam_ota_hdr_stru); } pst_netbuf = oam_alloc_data2sdt(us_skb_len); if (OAL_PTR_NULL == pst_netbuf) { return OAL_ERR_CODE_PTR_NULL; } pst_ota_data = (oam_ota_stru *)oal_netbuf_data(pst_netbuf); /* 获取系统TICK值 */ ul_tick = (oal_uint32)OAL_TIME_GET_STAMP_MS(); /* 填写ota消息结构体 */ pst_ota_data->st_ota_hdr.ul_tick = ul_tick; pst_ota_data->st_ota_hdr.en_ota_type = OAM_OTA_TYPE_MEMPOOL; pst_ota_data->st_ota_hdr.uc_frame_hdr_len = 0; pst_ota_data->st_ota_hdr.us_ota_data_len = us_stru_len; /* 复制数据,填写ota数据 */ oal_memcopy((oal_void *)pst_ota_data->auc_ota_data, (const oal_void *)&st_device_mempool_info, (oal_uint32)us_stru_len); /* 下发至sdt接收队列,若队列满则串口输出 */ ul_ret = oam_report_data2sdt(pst_netbuf, OAM_DATA_TYPE_OTA, OAM_PRIMID_TYPE_OUTPUT_CONTENT); return ul_ret; }