SylixOS -- 网卡驱动netdev_notify函数分析

/* if netdev detected a packet in netdev buffer, driver can call this function to receive this packet.
   notify:0 can transmit 1: can receive 
   qen:0 do not use netjob queue 1:use netjob queue */
int  netdev_notify (struct netdev *netdev, netdev_inout inout, int q_en)
{
  if (!netdev || (netdev->magic_no != NETDEV_MAGIC)) {
    return (-1);
  }
  
  if (inout != LINK_INPUT) {
    return (0);
  }
  
  if (q_en) {
    if (netJobAdd(netdev->drv->receive, netdev, 
                  (void *)netdev_netif_linkinput, 0, 0, 0, 0) == 0) {
      return (0);
    
    } else {
      return (-1);
    }
  }
  
  NETDEV_RECEIVE(netdev, netdev_netif_linkinput);
  
  return (0);
}

在网卡驱动中,当netdev检测到有数据在缓冲区时,会产生接收中断,在接收中断中通知receive函数出来这个数据。
在接收中断中,通过调用netdev_notify函数通知receive函数处理。

  1. int  netdev_notify(struct netdev *netdev, netdev_inout inout, int q_en);
复制代码
netdev_notify函数的三个参数分别为:
netdev:指向netdev结构指针
inout:传参0表示接收操作,1表示发送操作。
q_en:传参0表示不使用网络异步处理作业队列,1表示使用网络队列。

对这边的理解是:
若q_en传参1,那netdev_notify会将receive函数添加至异步处理队列,退出中断,等待CPU空闲时接收数据。有点像中断底半部。

若q_en传参0,那netdev_notify会直接调用receive函数处理,等待接收完成后再退出中断。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Evan_ZGYF丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值