Beispiel #1
0
/***
 *	alloc_rtskb
 *	@size: i will need it later.
 */
struct rtskb *alloc_rtskb(unsigned int size) 
{
        struct rtskb *skb;

	if ( rtskb_pool.qlen>0 ) 
		skb = rtskb_dequeue(&rtskb_pool);
        else {
	  //	        skb = new_rtskb(); /* might return NULL and not be safe in this context */
		rt_pend_linux_srq(inc_pool_srq);
		return NULL;
	}

	/* Load the data pointers. */
	skb->data = skb->buf_start;
	skb->tail = skb->buf_start;
	skb->end  = skb->buf_start + size;
	
	/* Set up other state */
	skb->len = 0;
	skb->cloned = 0;
	skb->data_len = 0;

        skb->users = 1;
		
	if ( rtskb_pool.qlen<rtskb_pool_min )
		rt_pend_linux_srq(inc_pool_srq);

	return (skb);
}
int rt_signal_linux_task(struct task_struct *lxt, int sig, RT_TASK *rtt)
{
	rt_global_cli();
	sigsysrq.waitq[sigsysrq.in].tsk     = lxt;
	sigsysrq.waitq[sigsysrq.in].sig     = sig ;
	sigsysrq.waitq[sigsysrq.in].rt_task = rtt;
	sigsysrq.in = (sigsysrq.in + 1) & (MAX_SRQ - 1);
	rt_global_sti();
	rt_pend_linux_srq(sigsysrq.srq);
	return 0;
}
Beispiel #3
0
static void rt_timer_handler(unsigned long none)
{
#if 0 // diagnose and see if interrupts are coming in
	static int cnt[NR_RT_CPUS];
	int cpuid = rtai_cpuid();
	rt_printk("TIMER TICK: CPU %d, %d\n", cpuid, ++cnt[cpuid]);
#endif
	rt_pend_linux_srq(srq);
	mod_timer(&timer, jiffies + (HZ/TIMER_FREQ));
	return;
}
Beispiel #4
0
/***
 *	kfree_rtskb
 *	@skb	rtskb
 */
void kfree_rtskb(struct rtskb *skb) 
{
	if ( skb ) {
		skb->users = 0; 
		memset(skb->buf_start, 0, skb->buf_len);
		
		rtskb_queue_tail(&rtskb_pool, skb);
		
		if ( rtskb_pool.qlen>rtskb_pool_max )
			rt_pend_linux_srq(dec_pool_srq);
	}
}
/* ************************************************************************
 * This function runs in rtai context.
 *
 * It is called from inside rtnet whenever a packet has been received that
 * has to be processed by rtnetproxy.
 * ************************************************************************ */
static int rtnetproxy_recv(struct rtskb *rtskb)
{

    /* Place the rtskb in the ringbuffer: */
    if (write_to_ringbuffer(&ring_rtskb_rtnet_kernel, rtskb))
    {
        /* Switch over to kernel context: */
        rt_pend_linux_srq(rtnetproxy_srq);
    }
    else
    {
        /* No space in ringbuffer => Free rtskb here... */
        rt_printk("rtnetproxy_recv: No space in queue\n");
        kfree_rtskb(rtskb);
    }

    return 0;
}
int rtmac_vnic_rx(struct rtskb *skb, u16 type)
{
    struct rtmac_priv *mac_priv = skb->rtdev->mac_priv;
    struct rtskb_queue *pool = &mac_priv->vnic_skb_pool;


    if (rtskb_acquire(skb, pool) != 0) {
        mac_priv->vnic_stats.rx_dropped++;
        kfree_rtskb(skb);
        return -1;
    }

    skb->protocol = type;

    rtskb_queue_tail(&rx_queue, skb);
    rt_pend_linux_srq(vnic_srq);

    return 0;
}
//-----------------------------------------------------------------------------
int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const  ctxt_pP)
{
  //-----------------------------------------------------------------------------

  mem_block_t     *sdu_p            = list_get_head (&pdcp_sdu_list);
  int              bytes_wrote      = 0;
  int              pdcp_nb_sdu_sent = 0;
  uint8_t          cont             = 1;
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
  //MessageDef      *message_p        = NULL;
#endif

#if defined(PDCP_USE_NETLINK) && defined(LINUX)
  int ret = 0;
#endif

  while (sdu_p && cont) {

#if ! defined(OAI_EMU)
    ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
#endif

#if defined(LINK_ENB_PDCP_TO_GTPV1U)

    if (ctxt_pP->enb_flag) {
      AssertFatal(0, "Now execution should not go here");
      LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
      gtpv1u_new_data_req(
        ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p,
        ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID
        ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4,
        &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]),
        ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);

      list_remove_head (&pdcp_sdu_list);
      free_mem_block (sdu_p);
      cont = 1;
      pdcp_nb_sdu_sent += 1;
      sdu_p = list_get_head (&pdcp_sdu_list);
      LOG_D(OTG,"After  GTPV1U\n");
      continue; // loop again
    }

#endif /* defined(ENABLE_USE_MME) */
#ifdef PDCP_DEBUG
    LOG_D(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n",
          ctxt_pP->frame, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
          ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
#endif //PDCP_DEBUG
    cont = 0;

    if (!pdcp_output_sdu_bytes_to_write) {
      if (!pdcp_output_header_bytes_to_write) {
        pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t);
      }

#ifdef PDCP_USE_RT_FIFO
      bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO,
                             &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
                             pdcp_output_header_bytes_to_write);

#else
#ifdef PDCP_USE_NETLINK
#ifdef LINUX
      memcpy(NLMSG_DATA(nas_nlh_tx), &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
             pdcp_output_header_bytes_to_write);
      nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write;
#endif //LINUX
#endif //PDCP_USE_NETLINK

      bytes_wrote = pdcp_output_header_bytes_to_write;
#endif //PDCP_USE_RT_FIFO

#ifdef PDCP_DEBUG
      LOG_D(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n",
            ctxt_pP->frame,
            bytes_wrote);
#endif //PDCP_DEBUG

      if (bytes_wrote > 0) {
        pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote;

        if (!pdcp_output_header_bytes_to_write) { // continue with sdu
          pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size;

#ifdef PDCP_USE_RT_FIFO
          bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
#else

#ifdef PDCP_USE_NETLINK
#ifdef LINUX
          memcpy(NLMSG_DATA(nas_nlh_tx)+sizeof(pdcp_data_ind_header_t), &(sdu_p->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
          nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write;
          ret = sendmsg(nas_sock_fd,&nas_msg_tx,0);

          if (ret<0) {
            LOG_D(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno);
      	    MSC_LOG_TX_MESSAGE_FAILED(
      	      (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
      	      (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
      	      NULL,
      	      0,
      	      MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u",
      	      MSC_AS_TIME_ARGS(ctxt_pP),
      	      ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
      	      ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
           mac_xface->macphy_exit("sendmsg failed for nas_sock_fd\n");
            break;
          } else {
        	  MSC_LOG_TX_MESSAGE(
        	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
        	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
        	    NULL,
        	    0,
        	    MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u",
        	    MSC_AS_TIME_ARGS(ctxt_pP),
        	    ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
        	    ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
          }

#endif // LINUX
#endif //PDCP_USE_NETLINK
          bytes_wrote= pdcp_output_sdu_bytes_to_write;
#endif // PDCP_USE_RT_FIFO

#ifdef PDCP_DEBUG
          LOG_D(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to higher layers\n",
                ctxt_pP->frame,
                ((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
                bytes_wrote,
                ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
#endif //PDCP_DEBUG

          if (bytes_wrote > 0) {
            pdcp_output_sdu_bytes_to_write -= bytes_wrote;

            if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU
              // LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP);
              LOG_D(PDCP,
                    "[FRAME %05d][xxx][PDCP][MOD xx/xx][RB %u][--- PDCP_DATA_IND / %d Bytes --->][IP][INSTANCE %u][RB %u]\n",
                    ctxt_pP->frame,
                    ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
                    ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size,
                    ((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
                    ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);

              list_remove_head (&pdcp_sdu_list);
              free_mem_block (sdu_p);
              cont = 1;
              pdcp_nb_sdu_sent += 1;
              sdu_p = list_get_head (&pdcp_sdu_list);
            }
          } else {
            LOG_W(PDCP, "RADIO->IP SEND SDU CONGESTION!\n");
          }
        } else {
          LOG_W(PDCP, "RADIO->IP SEND SDU CONGESTION!\n");
        }
      }
    } else {
      // continue writing sdu
#ifdef PDCP_USE_RT_FIFO
      bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO,
                             (uint8_t *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])),
                             pdcp_output_sdu_bytes_to_write);
#else  // PDCP_USE_RT_FIFO
      bytes_wrote = pdcp_output_sdu_bytes_to_write;
#endif  // PDCP_USE_RT_FIFO

      if (bytes_wrote > 0) {
        pdcp_output_sdu_bytes_to_write -= bytes_wrote;

        if (!pdcp_output_sdu_bytes_to_write) {     // OK finish with this SDU
          //PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n");
          list_remove_head (&pdcp_sdu_list);
          free_mem_block (sdu_p);
          cont = 1;
          pdcp_nb_sdu_sent += 1;
          sdu_p = list_get_head (&pdcp_sdu_list);
          // LOG_D(PDCP, "rb sent a sdu from rab\n");
        }
      }
    }
  }

#ifdef PDCP_USE_RT_FIFO

  if ((pdcp_nb_sdu_sent)) {
    if ((pdcp_2_nas_irq > 0)) {
#ifdef PDCP_DEBUG
      LOG_D(PDCP, "Frame %d : Trigger NAS RX interrupt\n",
            ctxt_pP->frame);
#endif //PDCP_DEBUG
      rt_pend_linux_srq (pdcp_2_nas_irq);

    } else {
      LOG_E(PDCP, "Frame %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n",
            ctxt_pP->frame,
            pdcp_2_nas_irq);
    }
  }

#endif  //PDCP_USE_RT_FIFO

  return pdcp_nb_sdu_sent;
}
Beispiel #8
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int
pdcp_fifo_flush_sdus ()
{
//-----------------------------------------------------------------------------

  mem_block_t     *sdu = list_get_head (&pdcp_sdu_list);
  int             bytes_wrote = 0;
  int             pdcp_nb_sdu_sent = 0;
  uint8_t              cont = 1;
  int ret;


  while ((sdu) && (cont)) {

#ifdef USER_MODE
    // asjust the instance id when passing sdu to IP
    ((pdcp_data_ind_header_t *)(sdu->data))->inst = (((pdcp_data_ind_header_t *)(sdu->data))->inst >= NB_eNB_INST) ?
      ((pdcp_data_ind_header_t *)(sdu->data))->inst - NB_eNB_INST +oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local :// UE
      ((pdcp_data_ind_header_t *)(sdu->data))->inst - oai_emulation.info.first_ue_local; // ENB
#else
    ((pdcp_data_ind_header_t *)(sdu->data))->inst = 0;
#endif

#ifdef PDCP_DEBUG
	  msg("[PDCP][INFO] PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n",
	      Mac_rlc_xface->frame,
	      ((pdcp_data_ind_header_t *)(sdu->data))->inst,
	      ((pdcp_data_ind_header_t *)(sdu->data))->data_size,
	      ((pdcp_data_ind_header_t *)(sdu->data))->rb_id);
#endif //PDCP_DEBUG

    cont = 0;

    if (!pdcp_output_sdu_bytes_to_write) {
      if (!pdcp_output_header_bytes_to_write) {
        pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t);
      }

#ifndef USER_MODE
      bytes_wrote = rtf_put (PDCP2NAS_FIFO,
			     &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
			     pdcp_output_header_bytes_to_write);

#else
#ifdef NAS_NETLINK
#ifdef LINUX
      memcpy(NLMSG_DATA(nas_nlh), &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
                             pdcp_output_header_bytes_to_write);
      nas_nlh->nlmsg_len = pdcp_output_header_bytes_to_write;
#endif //LINUX
#endif //NAS_NETLINK

      bytes_wrote = pdcp_output_header_bytes_to_write;
#endif //USER_MODE


#ifdef PDCP_DEBUG
      msg("[PDCP][INFO] TTI %d Sent %d Bytes of header to Nas_mesh\n",
	  Mac_rlc_xface->frame,
	  bytes_wrote);
#endif //PDCP_DEBUG

      if (bytes_wrote > 0) {
        pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote;

        if (!pdcp_output_header_bytes_to_write) { // continue with sdu

          pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu->data)->data_size;

#ifndef USER_MODE
          bytes_wrote = rtf_put (PDCP2NAS_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
#else

#ifdef NAS_NETLINK
#ifdef LINUX
	  memcpy(NLMSG_DATA(nas_nlh)+sizeof(pdcp_data_ind_header_t), &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
	  nas_nlh->nlmsg_len += pdcp_output_sdu_bytes_to_write;
	  ret = sendmsg(nas_sock_fd,&nas_msg,0);
	  if (ret<0) {
	    msg("[PDCP_FIFOS] sendmsg returns %d\n",ret);
	    perror("error code:");
	    mac_xface->macphy_exit("");
	    break;
	  }
#endif // LINUX
#endif //NAS_NETLINK
	  bytes_wrote= pdcp_output_sdu_bytes_to_write;
#endif // USER_MODE

#ifdef PDCP_DEBUG
	  msg("[PDCP][INFO] PDCP->IP TTI %d INST %d: Sent %d Bytes of data from rab %d to Nas_mesh\n",
	      Mac_rlc_xface->frame,
	      ((pdcp_data_ind_header_t *)(sdu->data))->inst,
	      bytes_wrote,
	      ((pdcp_data_ind_header_t *)(sdu->data))->rb_id);
#endif //PDCP_DEBUG
          if (bytes_wrote > 0) {
            pdcp_output_sdu_bytes_to_write -= bytes_wrote;

            if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU
	      // msg("rb sent a sdu qos_sap %d\n",sapiP);

              list_remove_head (&pdcp_sdu_list);
              free_mem_block (sdu);
              cont = 1;
              pdcp_nb_sdu_sent += 1;
              sdu = list_get_head (&pdcp_sdu_list);
            }
          } else {
            msg ("[PDCP] RADIO->IP SEND SDU CONGESTION!\n");
          }
        } else {
          msg ("[PDCP] RADIO->IP SEND SDU CONGESTION!\n");
        }
      }
    } else {
      // continue writing sdu
#ifndef USER_MODE
      bytes_wrote = rtf_put (PDCP2NAS_FIFO,
                             (uint8_t *) (&(sdu->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu->data)->data_size - pdcp_output_sdu_bytes_to_write])),
                             pdcp_output_sdu_bytes_to_write);
#else  // USER_MODE
      bytes_wrote = pdcp_output_sdu_bytes_to_write;
#endif  // USER_MODE

      if (bytes_wrote > 0) {
        pdcp_output_sdu_bytes_to_write -= bytes_wrote;

        if (!pdcp_output_sdu_bytes_to_write) {     // OK finish with this SDU
          //PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n");
          list_remove_head (&pdcp_sdu_list);
          free_mem_block (sdu);
          cont = 1;
          pdcp_nb_sdu_sent += 1;
          sdu = list_get_head (&pdcp_sdu_list);
	  // msg("rb sent a sdu from rab\n");
        }
      }
    }
  }
#ifndef USER_MODE
    if ((pdcp_nb_sdu_sent)) {
      if ((pdcp_2_nas_irq > 0)) {
#ifdef PDCP_DEBUG
	msg("[PDCP][INFO] TTI %d : Trigger NAS RX interrupt\n",
	    Mac_rlc_xface->frame);
#endif //PDCP_DEBUG

           rt_pend_linux_srq (pdcp_2_nas_irq);
      } else {
        msg ("[PDCP] TTI %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n",
	     Mac_rlc_xface->frame,
	     pdcp_2_nas_irq);
      }
    }
#endif  //USER_MODE

  return pdcp_nb_sdu_sent;
}