[OAI][Layer2]OAI UE_IP模块

for S1 mode

loads the ue_ip module and sets up IP for the UE

编译规则

基础知识

linux网络驱动程序

http://www.xml.com/ldd/chapter/book/ch14.html

网络设备驱动程序在连接到外部系统的硬件接口上接收和传输数据包,并提供网络协议可以访问的统一接口。在Linux中,这些驱动程序是从网络适配器本身的硬件实现中抽象出来的,其实现隐藏了底层的第1层和第2层协议。

网络驱动程序的大多数回调例程必须在内核中注册,以允许内核在数据到达网络端口时或内核需要在网络端口上发送数据时执行它们。与字符驱动程序一样,网络驱动程序不访问物理上可寻址的存储介质或支持文件系统访问。与块和字符设备驱动程序不同,网络驱动程序下没有设备文件 /dev。相反,您使用 net_device结构来定义网络接口的功能,并且当您使用诸如ip之类的命令来配置接口时,内核会更新此结构的成员。

net_device_ops定义的网络设备 的结构<linux/netdevice.h>包含一组方法指针,用于指定系统如何与设备交互。

https://elixir.bootlin.com/linux/v4.2/source/include/linux/netdevice.h#L1045

OAI代码分析

ue_ip called by layer2_top.c(MAC) & mesh_top.c(RRC)

device.c

void ue_ip_init(struct net_device *dev_pP)

int init_module (void)

void cleanup_module(void)

common.c

void ue_ip_common_class_wireless2ip(sdu_size_t data_lenP,void *pdcp_sdu_pP,int instP,rb_id_t rb_idP)

void ue_ip_common_ip2wireless_drop(struct sk_buff *skb_pP,  int instP) // Delete the data

void ue_ip_common_ip2wireless(struct sk_buff *skb_pP,int instP) // Request the transfer of data (QoS SAP)

void ue_ip_common_wireless2ip(struct nlmsghdr *nlh_pP) //Retrieve PDU from PDCP through RT-fifos for delivery to the IP stack.

主要调用函数

struct net_device *ue_ip_dev[UE_IP_NB_INSTANCES_MAX];

int init_module (void)
----ue_ip_dev[inst] = alloc_netdev(sizeof(ue_ip_priv_t),devicename, ue_ip_init);
--------dev_pP->netdev_ops = &ue_ip_netdev_ops;(ue_ip_init)
----register_netdev(ue_ip_dev[inst]);
----ue_ip_netlink_init()
--------cfg.input = nas_nl_data_ready;
--------cfg.cb_mutex = &nasmesh_mutex;
--------nas_nl_sk = netlink_kernel_create(&init_net,OAI_IP_DRIVER_NETLINK_ID,&cfg);
------------ue_ip_common_wireless2ip(nas_nl_data_ready)
----------------priv = netdev_priv(oai_nw_drv_dev[pdcph->inst]);
----------------oai_nw_drv_common_class_wireless2ip
--------------------skb = dev_alloc_skb( dlen + 2 );
--------------------memcpy(skb_put(skb, dlen), pdcp_sdu,dlen);
--------------------skb->dev = oai_nw_drv_dev[inst];
--------------------netif_rx(skb);

猜你喜欢

转载自www.cnblogs.com/LearnFromNow/p/9660382.html