コード例 #1
0
ファイル: misoc_net.c プロジェクト: AlexShiLucky/NuttX
static void misoc_net_poll_work(FAR void *arg)
{
  FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg;

  /* Perform the poll */

  net_lock();

  /* Check if there is room in the send another TX packet.  We cannot perform
   * the TX poll if he are unable to accept another packet for transmission.
   */

  /* If so, update TCP timing states and poll the network for new XMIT data.
   * Hmmm.. might be bug here.  Does this mean if there is a transmit in
   * progress, we will missing TCP time state updates?
   */

  (void)devif_timer(&priv->misoc_net_dev, misoc_net_txpoll);

  /* Setup the watchdog poll timer again */

  (void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, misoc_net_poll_expiry, 1,
                 (wdparm_t)priv);

  net_unlock();
}
コード例 #2
0
ファイル: e1000.c プロジェクト: bherrera/NuttX
static void e1000_polltimer(int argc, uint32_t arg, ...)
{
    struct e1000_dev *e1000 = (struct e1000_dev *)arg;
    int tail = e1000->tx_ring.tail;

    /* Check if there is room in the send another TX packet.  We cannot perform
     * the TX poll if he are unable to accept another packet for transmission.
     */

    if (!e1000->tx_ring.desc[tail].desc_status)
    {
        return;
    }

    /* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
     * might be bug here.  Does this mean if there is a transmit in progress,
     * we will missing TCP time state updates?
     */

    (void)devif_timer(&e1000->netdev, e1000_txpoll, E1000_POLLHSEC);

    /* Setup the watchdog poll timer again */

    (void)wd_start(e1000->txpoll, E1000_WDDELAY, e1000_polltimer, 1, arg);
}
コード例 #3
0
ファイル: loopback.c プロジェクト: acassis/ros2_nuttx
static void lo_poll_work(FAR void *arg)
{
  FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)arg;
  net_lock_t state;

  /* Perform the poll */

  state = net_lock();
  priv->lo_txdone = false;
  (void)devif_timer(&priv->lo_dev, lo_txpoll);

  /* Was something received and looped back? */

  while (priv->lo_txdone)
    {
      /* Yes, poll again for more TX data */

      priv->lo_txdone = false;
      (void)devif_poll(&priv->lo_dev, lo_txpoll);
    }

  /* Setup the watchdog poll timer again */

  (void)wd_start(priv->lo_polldog, LO_WDDELAY, lo_poll_expiry, 1, priv);
  net_unlock(state);
}
コード例 #4
0
ファイル: vnet.c プロジェクト: acassis/ros2_nuttx
static void vnet_polltimer(int argc, uint32_t arg, ...)
{
  FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;

  /* Check if there is room in the send another TX packet.  We cannot perform
   * the TX poll if he are unable to accept another packet for transmission.
   */

  if (vnet_is_txbuff_full(vnet->vnet))
    {
#ifdef CONFIG_DEBUG
      cprintf("VNET: TX buffer is full\n");
#endif
      return;
    }

  /* If so, update TCP timing states and poll the network for new XMIT data.
   * Hmmm..  might be bug here.  Does this mean if there is a transmit in
   * progress, we will missing TCP time state updates?
   */

  (void)devif_timer(&vnet->sk_dev, vnet_txpoll);

  /* Setup the watchdog poll timer again */

  (void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1,
                 (wdparm_t)arg);
}
コード例 #5
0
ファイル: skeleton.c プロジェクト: rohiniku/NuttX-nuttx
static inline void skel_poll_process(FAR struct skel_driver_s *priv)
{
  /* Check if there is room in the send another TX packet.  We cannot perform
   * the TX poll if he are unable to accept another packet for transmission.
   */

  /* If so, update TCP timing states and poll the network for new XMIT data.
   * Hmmm.. might be bug here.  Does this mean if there is a transmit in
   * progress, we will missing TCP time state updates?
   */

  (void)devif_timer(&priv->sk_dev, skel_txpoll);

  /* Setup the watchdog poll timer again */

  (void)wd_start(priv->sk_txpoll, skeleton_WDDELAY, skel_poll_expiry, 1,
                 (wdparm_t)priv);
}
コード例 #6
0
static void emac_polltimer(int argc, uint32_t arg, ...)
{
  FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)arg;

  /* Check if there is room in the send another TX packet.  We cannot perform
   * the TX poll if he are unable to accept another packet for transmission.
   */

  /* If so, update TCP timing states and poll the network for new XMIT data. Hmmm..
   * might be bug here.  Does this mean if there is a transmit in progress,
   * we will missing TCP time state updates?
   */

  (void)devif_timer(&priv->d_dev, emac_txpoll);

  /* Setup the watchdog poll timer again */

  (void)wd_start(priv->d_txpoll, HCS12_WDDELAY, emac_polltimer, 1, arg);
}
コード例 #7
0
ファイル: bcmf_netdev.c プロジェクト: AlexShiLucky/NuttX
static void bcmf_poll_work(FAR void *arg)
{
  // wlinfo("Entry\n");
  FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg;

  /* Lock the network and serialize driver operations if necessary.
   * NOTE: Serialization is only required in the case where the driver work
   * is performed on an LP worker thread and where more than one LP worker
   * thread has been configured.
   */

  net_lock();

  /* Perform the poll */

  /* Check if there is room in the send another TX packet.  We cannot perform
   * the TX poll if he are unable to accept another packet for transmission.
   */

  if (bcmf_netdev_alloc_tx_frame(priv))
    {
      goto exit_unlock;
    }

  /* If so, update TCP timing states and poll the network for new XMIT data.
   * Hmmm.. might be bug here.  Does this mean if there is a transmit in
   * progress, we will missing TCP time state updates?
   */

  priv->bc_dev.d_buf = priv->cur_tx_frame->data;
  priv->bc_dev.d_len = 0;
  (void)devif_timer(&priv->bc_dev, bcmf_txpoll);

  /* Setup the watchdog poll timer again */

  (void)wd_start(priv->bc_txpoll, BCMF_WDDELAY, bcmf_poll_expiry, 1,
                 (wdparm_t)priv);
exit_unlock:
  net_unlock();
}
コード例 #8
0
ファイル: up_netdriver.c プロジェクト: AlexShiLucky/NuttX
void netdriver_loop(void)
{
  FAR struct eth_hdr_s *eth;

  /* Check for new frames.  If so, then poll the network for new XMIT data */

  net_lock();
  (void)devif_poll(&g_sim_dev, sim_txpoll);
  net_unlock();

  /* netdev_read will return 0 on a timeout event and >0 on a data received event */

  g_sim_dev.d_len = netdev_read((FAR unsigned char *)g_sim_dev.d_buf,
                                CONFIG_NET_ETH_MTU);

  /* Disable preemption through to the following so that it behaves a little more
   * like an interrupt (otherwise, the following logic gets pre-empted an behaves
   * oddly.
   */

  sched_lock();
  if (g_sim_dev.d_len > 0)
    {
      /* Data received event.  Check for valid Ethernet header with destination == our
       * MAC address
       */

      eth = BUF;
      if (g_sim_dev.d_len > ETH_HDRLEN)
        {
         int is_ours;

         /* Figure out if this ethernet frame is addressed to us.  This affects
           * what we're willing to receive.   Note that in promiscuous mode, the
           * up_comparemac will always return 0.
           */

         is_ours = (up_comparemac(eth->dest, &g_sim_dev.d_mac.ether) == 0);

#ifdef CONFIG_NET_PKT
          /* When packet sockets are enabled, feed the frame into the packet
           * tap.
           */

          if (is_ours)
            {
              pkt_input(&g_sim_dev);
            }
#endif /* CONFIG_NET_PKT */

          /* We only accept IP packets of the configured type and ARP packets */

#ifdef CONFIG_NET_IPv4
          if (eth->type == HTONS(ETHTYPE_IP) && is_ours)
            {
              ninfo("IPv4 frame\n");

              /* Handle ARP on input then give the IPv4 packet to the network
               * layer
               */

              arp_ipin(&g_sim_dev);
              ipv4_input(&g_sim_dev);

              /* If the above function invocation resulted in data that
               * should be sent out on the network, the global variable
               * d_len is set to a value > 0.
               */

              if (g_sim_dev.d_len > 0)
                {
                  /* Update the Ethernet header with the correct MAC address */

#ifdef CONFIG_NET_IPv6
                  if (IFF_IS_IPv4(g_sim_dev.d_flags))
#endif
                    {
                      arp_out(&g_sim_dev);
                    }
#ifdef CONFIG_NET_IPv6
                  else
                    {
                      neighbor_out(&g_sim_dev);
                    }
#endif

                  /* And send the packet */

                  netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
                }
            }
          else
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
          if (eth->type == HTONS(ETHTYPE_IP6) && is_ours)
            {
              ninfo("Iv6 frame\n");

              /* Give the IPv6 packet to the network layer */

              ipv6_input(&g_sim_dev);

              /* If the above function invocation resulted in data that
               * should be sent out on the network, the global variable
               * d_len is set to a value > 0.
               */

              if (g_sim_dev.d_len > 0)
               {
                  /* Update the Ethernet header with the correct MAC address */

#ifdef CONFIG_NET_IPv4
                  if (IFF_IS_IPv4(g_sim_dev.d_flags))
                    {
                      arp_out(&g_sim_dev);
                    }
                  else
#endif
#ifdef CONFIG_NET_IPv6
                    {
                      neighbor_out(&g_sim_dev);
                    }
#endif /* CONFIG_NET_IPv6 */

                  /* And send the packet */

                  netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
                }
            }
          else
#endif/* CONFIG_NET_IPv6 */
#ifdef CONFIG_NET_ARP
          if (eth->type == htons(ETHTYPE_ARP))
            {
              arp_arpin(&g_sim_dev);

              /* If the above function invocation resulted in data that
               * should be sent out on the network, the global variable
               * d_len is set to a value > 0.
               */

              if (g_sim_dev.d_len > 0)
                {
                  netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
                }
            }
          else
#endif
           {
             nwarn("WARNING: Unsupported Ethernet type %u\n", eth->type);
           }
        }
    }

  /* Otherwise, it must be a timeout event */

  else if (timer_expired(&g_periodic_timer))
    {
      timer_reset(&g_periodic_timer);
      devif_timer(&g_sim_dev, sim_txpoll);
    }

  sched_unlock();
}
コード例 #9
0
ファイル: slip.c プロジェクト: hll4fork/NuttX
static void slip_txtask(int argc, FAR char *argv[])
{
  FAR struct slip_driver_s *priv;
  unsigned int index = *(argv[1]) - '0';
  net_lock_t flags;
  systime_t msec_start;
  systime_t msec_now;
  unsigned int hsec;

  nerr("index: %d\n", index);
  DEBUGASSERT(index < CONFIG_NET_SLIP_NINTERFACES);

  /* Get our private data structure instance and wake up the waiting
   * initialization logic.
   */

  priv = &g_slip[index];
  slip_semgive(priv);

  /* Loop forever */

  msec_start = clock_systimer() * MSEC_PER_TICK;
  for (;  ; )
    {
      /* Wait for the timeout to expire (or until we are signaled by by  */

      slip_semtake(priv);
      if (!priv->txnodelay)
        {
          slip_semgive(priv);
          usleep(SLIP_WDDELAY);
        }
      else
        {
          priv->txnodelay = false;
          slip_semgive(priv);
        }

      /* Is the interface up? */

      if (priv->bifup)
        {
          /* Get exclusive access to the network (if it it is already being used
           * slip_rxtask, then we have to wait).
           */

          slip_semtake(priv);

          /* Poll the networking layer for new XMIT data. */

          flags = net_lock();
          priv->dev.d_buf = priv->txbuf;

          /* Has a half second elapsed since the last timer poll? */

          msec_now = clock_systimer() * MSEC_PER_TICK;
          hsec = (unsigned int)(msec_now - msec_start) / (MSEC_PER_SEC / 2);
          if (hsec)
            {
              /* Yes, perform the timer poll */

              (void)devif_timer(&priv->dev, slip_txpoll);
              msec_start += hsec * (MSEC_PER_SEC / 2);
            }
          else
            {
              /* No, perform the normal TX poll */

              (void)devif_poll(&priv->dev, slip_txpoll);
            }

          net_unlock(flags);
          slip_semgive(priv);
        }
    }
}
コード例 #10
0
ファイル: up_netdriver.c プロジェクト: FreddieChopin/NuttX
void netdriver_loop(void)
{
  /* netdev_read will return 0 on a timeout event and >0 on a data received event */

  g_sim_dev.d_len = netdev_read((unsigned char*)g_sim_dev.d_buf, CONFIG_NET_ETH_MTU);

  /* Disable preemption through to the following so that it behaves a little more
   * like an interrupt (otherwise, the following logic gets pre-empted an behaves
   * oddly.
   */

  sched_lock();
  if (g_sim_dev.d_len > 0)
    {
      /* Data received event.  Check for valid Ethernet header with destination == our
       * MAC address
       */

      if (g_sim_dev.d_len > ETH_HDRLEN && up_comparemac(BUF->ether_dhost, &g_sim_dev.d_mac) == 0)
        {
          /* We only accept IP packets of the configured type and ARP packets */

#ifdef CONFIG_NET_IPv6
          if (BUF->ether_type == htons(ETHTYPE_IP6))
#else
          if (BUF->ether_type == htons(ETHTYPE_IP))
#endif
            {
              arp_ipin(&g_sim_dev);
              devif_input(&g_sim_dev);

             /* If the above function invocation resulted in data that
              * should be sent out on the network, the global variable
              * d_len is set to a value > 0.
              */

              if (g_sim_dev.d_len > 0)
                {
                  arp_out(&g_sim_dev);
                  netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
                }
            }
          else if (BUF->ether_type == htons(ETHTYPE_ARP))
            {
              arp_arpin(&g_sim_dev);

              /* If the above function invocation resulted in data that
               * should be sent out on the network, the global variable
               * d_len is set to a value > 0.
               */

              if (g_sim_dev.d_len > 0)
                {
                  netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
                }
            }
        }
    }

  /* Otherwise, it must be a timeout event */

  else if (timer_expired(&g_periodic_timer))
    {
      timer_reset(&g_periodic_timer);
      devif_timer(&g_sim_dev, sim_txpoll, 1);
    }
  sched_unlock();
}