int mac_process_pdu(rlc_entity_um_rx_t *umrx, u8 *mac_pdu, u32 pdu_len) { u32 lc_id; u32 i, l = 0; u32 ret = 0; u32 n_sdu = 0; int left_len = pdu_len; u8 *mac_sdu = NULL; mac_pdu_subhead_t *subhead_ptr = (mac_pdu_subhead_t *)mac_pdu; mac_pdu_subhead_t subhead[32]; /* parse subhead */ while(left_len > 0) { if(subhead_ptr->e == 0) { subhead[n_sdu].lc_id = subhead_ptr->lc_id; subhead[n_sdu].l = left_len-1; mac_sdu = (u8 *)subhead_ptr + 1; //this first SDU pointer n_sdu ++; left_len = 0; break; } else { /* this should not happen! */ ZLOG_ERR("this should not happen!\n"); assert(0); } } if(mac_sdu == NULL || n_sdu == 0 || left_len != 0) { ZLOG_ERR("mac_sdu=0x%p n_sdu=%u left_len=%d.\n", mac_sdu, n_sdu, left_len); return -1; } for(i=0; i<n_sdu; i++) { lc_id = subhead[i].lc_id; l = subhead[i].l; //dump MAC sub-header ZLOG_DEBUG("Rx MAC PDU sub-header: LCID=%u L=%u.\n", lc_id, l); /* process special LCID */ switch(lc_id) { default: //Identity of the logical channel { assert(l > 0); if(rlc_um_rx_process_pdu(umrx, mac_sdu, l, mac_pdu) != 0) ZLOG_WARN("rlc_um_rx_process_pdu() failure.\n"); } } //to next SDU mac_sdu += l; } return ret; }
void ptimer_start(ptimer_table_t *table, ptimer_t *timer, u32 timeval) { u32 slot; if(table == NULL || timer == NULL) return; if(timer->flags & PTIMER_FLAG_RUNNING) { /* avoid timer is started multiple times */ ZLOG_WARN("timer is running, ignore it: 0x%p timeval=%d\n", timer, timeval); return; } timer->flags |= PTIMER_FLAG_RUNNING; timer->duration = timeval; if(timeval >= table->allslots) { timer->remainder = timeval - table->allslots + 1; slot = (table->curslot + table->allslots - 1) & (table->allslots - 1); } else { timer->remainder = 0; /* find register slot */ slot = (table->curslot + timeval) & (table->allslots - 1); } dllist_append(&table->table[slot], (dllist_node_t *)timer); // ZLOG_DEBUG("start timer: 0x%p timeval=%u, curslot=%u target_slot=%u\n", timer, timeval, table->curslot, slot); }