【问题标题】:share data with tasklet bottom half in linux driver在 linux 驱动程序中与 tasklet 下半部分共享数据
【发布时间】:2018-01-06 18:33:47
【问题描述】:

我正在编写一个处理数据包时间戳的 linux phy 驱动程序。下半部分执行计算时间戳并将此信息发送到内核网络堆栈然后发送到用户空间的过程。下半部分需要来自 tasklet 调用者拥有的 skb(packet) 的一些信息。我很难将此 skb 传递给 takslet。 tasklet 处理函数不接受除 unsigned long 以外的任何输入。我被困在这里。下面是一段代码sn-p,供大家理解——

    static void tx_ts_task(unsigned long val)
    {
      struct phyts *phyts = container_of(&val, struct phyts, int_flags);
      //skb_copy(skb);  ///want to access skb in this tasklet but I am unable to do this.
      .
      .
     }

    int tx_timestamp(struct phyts *phyts, struct sk_buff *skb, int len)
    {
      .
      .
       tasklet_schedule(&tx_ts_tasklet);

     }

感谢您的投入。谢谢

【问题讨论】:

  • Unsigned long 完全等同于 Linux 中的 void *。

标签: linux-kernel linux-device-driver


【解决方案1】:

Tasklet 函数接收与DECLARE_TASKLET/tasklet_init 中指定的相同的data 参数。通常这是一个指向某个(大)驱动结构的指针。

所以基本上,您不能在ISRtasklet 之间直接传递运行时数据,而应该使用某种具有适当锁定的共享变量(可能是上述结构)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-13
    • 2023-03-31
    • 1970-01-01
    相关资源
    最近更新 更多