Ejemplo n.º 1
0
static void ul_fill_ra_mcs(srslte_ra_tb_t* tb, srslte_ra_tb_t* last_tb, uint32_t L_prb, bool cqi_request)
{
  // 8.6.2 First paragraph
  if (tb->mcs_idx <= 28) {
    /* Table 8.6.1-1 on 36.213 */
    if (tb->mcs_idx < 11) {
      tb->mod = SRSLTE_MOD_QPSK;
      tb->tbs = srslte_ra_tbs_from_idx(tb->mcs_idx, L_prb);
    } else if (tb->mcs_idx < 21) {
      tb->mod = SRSLTE_MOD_16QAM;
      tb->tbs = srslte_ra_tbs_from_idx(tb->mcs_idx - 1, L_prb);
    } else if (tb->mcs_idx < 29) {
      tb->mod = SRSLTE_MOD_64QAM;
      tb->tbs = srslte_ra_tbs_from_idx(tb->mcs_idx - 2, L_prb);
    } else {
      ERROR("Invalid MCS index %d\n", tb->mcs_idx);
    }
  } else if (tb->mcs_idx == 29 && cqi_request && L_prb <= 4) {
    // 8.6.1 and 8.6.2 36.213 second paragraph
    tb->mod = SRSLTE_MOD_QPSK;
    tb->tbs = 0;
    tb->rv  = 1;
  } else if (tb->mcs_idx >= 29) {
    // Else use last TBS/Modulation and use mcs to obtain rv_idx
    tb->tbs = last_tb->tbs;
    tb->mod = last_tb->mod;
    tb->rv  = tb->mcs_idx - 28;
  }
}
Ejemplo n.º 2
0
int srslte_softbuffer_tx_init(srslte_softbuffer_tx_t *q, uint32_t nof_prb) {
  int ret = SRSLTE_ERROR_INVALID_INPUTS;
  
  if (q != NULL) {    
    ret = SRSLTE_ERROR; 
    
    bzero(q, sizeof(srslte_softbuffer_tx_t));
    
    ret = srslte_ra_tbs_from_idx(26, nof_prb);
    if (ret != SRSLTE_ERROR) {
      q->max_cb =  (uint32_t) ret / (SRSLTE_TCOD_MAX_LEN_CB - 24) + 1; 
      
      q->buffer_b = srslte_vec_malloc(sizeof(uint8_t*) * q->max_cb);
      if (!q->buffer_b) {
        perror("malloc");
        return SRSLTE_ERROR;
      }
     
      // FIXME: Use HARQ buffer limitation based on UE category
      for (uint32_t i=0;i<q->max_cb;i++) {
        q->buffer_b[i] = srslte_vec_malloc(sizeof(float) * SOFTBUFFER_SIZE);
        if (!q->buffer_b[i]) {
          perror("malloc");
          return SRSLTE_ERROR;
        }
      }      
      srslte_softbuffer_tx_reset(q);
      ret = SRSLTE_SUCCESS;
    }
  }
  return ret;
}
Ejemplo n.º 3
0
int srslte_softbuffer_rx_init(srslte_softbuffer_rx_t *q, uint32_t nof_prb) {
  int ret = SRSLTE_ERROR_INVALID_INPUTS;
  
  if (q != NULL) {    
    bzero(q, sizeof(srslte_softbuffer_rx_t));
    
    ret = srslte_ra_tbs_from_idx(26, nof_prb);
    if (ret != SRSLTE_ERROR) {
      q->max_cb =  (uint32_t) ret / (SRSLTE_TCOD_MAX_LEN_CB - 24) + 1; 
      ret = SRSLTE_ERROR;
      
      q->buffer_f = srslte_vec_malloc(sizeof(int16_t*) * q->max_cb);
      if (!q->buffer_f) {
        perror("malloc");
        goto clean_exit;
      }
      
      q->data = srslte_vec_malloc(sizeof(uint8_t*) * q->max_cb);
      if (!q->data) {
        perror("malloc");
        goto clean_exit;
      }

      q->cb_crc = srslte_vec_malloc(sizeof(bool) * q->max_cb);
      if (!q->cb_crc) {
        perror("malloc");
        goto clean_exit;
      }
      bzero(q->cb_crc, sizeof(bool) * q->max_cb);

      // FIXME: Use HARQ buffer limitation based on UE category
      for (uint32_t i=0;i<q->max_cb;i++) {
        q->buffer_f[i] = srslte_vec_malloc(sizeof(int16_t) * SOFTBUFFER_SIZE);
        if (!q->buffer_f[i]) {
          perror("malloc");
          goto clean_exit;
        }

        q->data[i] = srslte_vec_malloc(sizeof(uint8_t) * 6144/8);
        if (!q->data[i]) {
          perror("malloc");
          goto clean_exit;
        }
      }      
      //srslte_softbuffer_rx_reset(q);
      ret = SRSLTE_SUCCESS;
    }
  }

  clean_exit:
  if (ret != SRSLTE_SUCCESS) {
    srslte_softbuffer_rx_free(q);
  }

  return ret;
}