/***************************************************************************** 函 数 名 : 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; }
OAL_STATIC oal_uint32 hmac_frag_process(hmac_vap_stru *pst_hmac_vap, oal_netbuf_stru *pst_netbuf_original, mac_tx_ctl_stru *pst_tx_ctl, oal_uint32 ul_cip_hdrsize, oal_uint32 ul_max_tx_unit) { mac_ieee80211_frame_stru *pst_mac_header; mac_ieee80211_frame_stru *pst_frag_header; oal_netbuf_stru *pst_netbuf; oal_netbuf_stru *pst_netbuf_prev; oal_uint32 ul_total_hdrsize; oal_uint32 ul_frag_num; oal_uint32 ul_frag_size; oal_int32 l_remainder; oal_uint32 ul_payload = 0; oal_uint32 ul_offset; mac_tx_ctl_stru *pst_tx_ctl_copy; oal_uint32 ul_mac_hdr_size; ul_mac_hdr_size = MAC_80211_QOS_HTC_4ADDR_FRAME_LEN; pst_mac_header = pst_tx_ctl->pst_frame_header; pst_mac_header->st_frame_control.bit_more_frag = OAL_TRUE; ul_total_hdrsize = ul_mac_hdr_size + ul_cip_hdrsize; ul_frag_num = 1; /* 加密字节数包含在分片门限中,预留加密字节长度,由硬件填写加密头 */ ul_offset = ul_max_tx_unit - ul_cip_hdrsize - ul_mac_hdr_size; l_remainder = (oal_int32)(OAL_NETBUF_LEN(pst_netbuf_original) - ul_offset - ul_mac_hdr_size); pst_netbuf_prev = pst_netbuf_original; do { ul_frag_size = ul_total_hdrsize + (oal_uint32)l_remainder; /* 判断是否还有更多的分片 */ if (ul_frag_size > ul_max_tx_unit) { ul_frag_size = ul_max_tx_unit; } pst_netbuf = oal_netbuf_alloc(ul_frag_size + MAC_80211_QOS_HTC_4ADDR_FRAME_LEN, MAC_80211_QOS_HTC_4ADDR_FRAME_LEN, 4); if (OAL_PTR_NULL == pst_netbuf) { /* 在外部释放之前申请的报文 */ OAM_ERROR_LOG0(pst_hmac_vap->st_vap_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_frag_process::pst_netbuf null.}"); return OAL_ERR_CODE_PTR_NULL; } pst_tx_ctl_copy = (mac_tx_ctl_stru *)OAL_NETBUF_CB(pst_netbuf); /* 拷贝cb字段 */ oal_memcopy(pst_tx_ctl_copy, pst_tx_ctl, MAC_TX_CTL_SIZE); oal_netbuf_copy_queue_mapping(pst_netbuf, pst_netbuf_original); /*netbuf的headroom大于802.11 mac头长度*/ pst_frag_header = (mac_ieee80211_frame_stru *)(OAL_NETBUF_PAYLOAD(pst_netbuf)- MAC_80211_QOS_HTC_4ADDR_FRAME_LEN); pst_tx_ctl_copy->bit_80211_mac_head_type = 1; /*指示mac头部在skb中*/ /* 拷贝帧头内容 */ oal_memcopy(pst_frag_header, pst_mac_header, pst_tx_ctl->uc_frame_header_length); /* 赋值分片号 */ pst_frag_header->bit_frag_num = ul_frag_num; ul_frag_num++; /* 计算分片报文帧体长度 */ ul_payload = ul_frag_size - ul_total_hdrsize; oal_netbuf_copydata(pst_netbuf_original, (ul_offset+ul_mac_hdr_size), OAL_NETBUF_PAYLOAD(pst_netbuf), ul_payload); oal_netbuf_set_len(pst_netbuf, ul_payload); ((mac_tx_ctl_stru *)OAL_NETBUF_CB(pst_netbuf))->pst_frame_header = pst_frag_header; ((mac_tx_ctl_stru *)OAL_NETBUF_CB(pst_netbuf))->us_mpdu_len = (oal_uint16)ul_payload; OAL_NETBUF_NEXT(pst_netbuf_prev) = pst_netbuf; pst_netbuf_prev = pst_netbuf; if (pst_tx_ctl_copy->bit_80211_mac_head_type == 1) { oal_netbuf_push(pst_netbuf, MAC_80211_QOS_HTC_4ADDR_FRAME_LEN); } /* 计算下一个分片报文的长度和偏移 */ l_remainder -= (oal_int32)ul_payload; ul_offset += ul_payload; }while(l_remainder > 0); pst_frag_header->st_frame_control.bit_more_frag = OAL_FALSE; OAL_NETBUF_NEXT(pst_netbuf) = OAL_PTR_NULL; /* 原始报文作为分片报文的第一个 */ oal_netbuf_trim(pst_netbuf_original, OAL_NETBUF_LEN(pst_netbuf_original) - (ul_max_tx_unit - ul_cip_hdrsize)); pst_tx_ctl->us_mpdu_len = (oal_uint16)(OAL_NETBUF_LEN(pst_netbuf_original) - ul_mac_hdr_size); return OAL_SUCC; }