📄 readme.concap
字号:
Description of the "concap" encapsulation protocol interface============================================================The "concap" interface is intended to be used by network devicedrivers that need to process an encapsulation protocol. It is assumed that the protocol interacts with a linux network device by- data transmission- connection control (establish, release)Thus, the mnemonic: "CONnection CONtrolling eNCAPsulation Protocol".This is currently only used inside the isdn subsystem. But it mightalso be useful to other kinds of network devices. Thus, if you wantto suggest changes that improve usability or performance of theinterface, please let me know. I'm willing to include them in futurereleases (even if I needed to adapt the current isdn code to thechanged interface).Why is this useful?===================The encapsulation protocol used on top of WAN connections or permanentpoint-to-point links are frequently chosen upon bilateral agreement.Thus, a device driver for a certain type of hardware must supportseveral different encapsulation protocols at once.The isdn device driver did already support several differentencapsulation protocols. The encapsulation protocol is configured by auser space utility (isdnctrl). The isdn network interface code thenuses several case statements which select appropriate actionsdepending on the currently configured encapsulation protocol.In contrast, LAN network interfaces always used a single encapsulationprotocol which is unique to the hardware type of the interface. The LANencapsulation is usually done by just sticking a header on the data. Thus,traditional linux network device drivers used to process theencapsulation protocol directly (usually by just providing a hard_header()method in the device structure) using some hardware type specific supportfunctions. This is simple, direct and efficient. But it doesn't fit allthe requirements for complex WAN encapsulations. The configurability of the encapsulation protocol to be used makes isdn network interfaces more flexible, but also much more complex than traditional lan network interfaces.Many Encapsulation protocols used on top of WAN connections will not juststick a header on the data. They also might need to set up or releasethe WAN connection. They also might want to send other data for theirprivate purpose over the wire, e.g. ppp does a lot of link levelnegotiation before the first piece of user data can be transmitted.Such encapsulation protocols for WAN devices are typically more complexthan encapsulation protocols for lan devices. Thus, network interfacecode for typical WAN devices also tends to be more complex.In order to support Linux' x25 PLP implementation on top ofisdn network interfaces I could have introduced yet another branch tothe various case statements inside drivers/isdn/isdn_net.c.This eventually made isdn_net.c even more complex. In addition, it madeisdn_net.c harder to maintain. Thus, by identifying an abstractinterface between the network interface code and the encapsulationprotocol, complexity could be reduced and maintainability could beincreased.Likewise, a similar encapsulation protocol will frequently be needed byseveral different interfaces of even different hardware type, e.g. thesynchronous ppp implementation used by the isdn driver and theasynchronous ppp implementation used by the ppp driver have a lot ofsimilar code in them. By cleanly separating the encapsulation protocolfrom the hardware specific interface stuff such code could be sharedbetter in future.When operating over dial-up-connections (e.g. telephone lines via modem,non-permanent virtual circuits of wide area networks, ISDN) manyencapsulation protocols will need to control the connection. Therefore,some basic connection control primitives are supported. The type andsemantics of the connection (i.e the ISO layer where connection serviceis provided) is outside our scope and might be different depending onthe encapsulation protocol used, e.g. for a ppp module using our serviceon top of a modem connection a connect_request will result in dialinga (somewhere else configured) remote phone number. For an X25-interfacemodule (LAPB semantics, as defined in Documentation/networking/x25-iface.txt)a connect_request will ask for establishing a reliable lapbdatalink connection.The encapsulation protocol currently provides the followingservice primitives to the network device.- create a new encapsulation protocol instance- delete encapsulation protocol instance and free all its resources- initialize (open) the encapsulation protocol instance for use.- deactivate (close) an encapsulation protocol instance.- process (xmit) data handed down by upper protocol layer- receive data from lower (hardware) layer- process connect indication from lower (hardware) layer- process disconnect indication from lower (hardware) layerThe network interface driver accesses those primitives via callbacksprovided by the encapsulation protocol instance within astruct concap_proto_ops.struct concap_proto_ops{ /* create a new encapsulation protocol instance of same type */ struct concap_proto * (*proto_new) (void); /* delete encapsulation protocol instance and free all its resources. cprot may no loger be referenced after calling this */ void (*proto_del)(struct concap_proto *cprot); /* initialize the protocol's data. To be called at interface startup or when the device driver resets the interface. All services of the encapsulation protocol may be used after this*/ int (*restart)(struct concap_proto *cprot, struct net_device *ndev, struct concap_device_ops *dops); /* deactivate an encapsulation protocol instance. The encapsulation protocol may not call any *dops methods after this. */ int (*close)(struct concap_proto *cprot); /* process a frame handed down to us by upper layer */ int (*encap_and_xmit)(struct concap_proto *cprot, struct sk_buff *skb); /* to be called for each data entity received from lower layer*/ int (*data_ind)(struct concap_proto *cprot, struct sk_buff *skb); /* to be called when a connection was set up/down. Protocols that don't process these primitives might fill in dummy methods here */ int (*connect_ind)(struct concap_proto *cprot); int (*disconn_ind)(struct concap_proto *cprot);};The data structures are defined in the header file include/linux/concap.h.A Network interface using encapsulation protocols must also providesome service primitives to the encapsulation protocol:- request data being submitted by lower layer (device hardware) - request a connection being set up by lower layer - request a connection being released by lower layerThe encapsulation protocol accesses those primitives via callbacksprovided by the network interface within a struct concap_device_ops.struct concap_device_ops{ /* to request data be submitted by device */ int (*data_req)(struct concap_proto *, struct sk_buff *); /* Control methods must be set to NULL by devices which do not support connection control. */ /* to request a connection be set up */ int (*connect_req)(struct concap_proto *); /* to request a connection be released */ int (*disconn_req)(struct concap_proto *); };The network interface does not explicitly provide a receive servicebecause the encapsulation protocol directly calls netif_rx(). An encapsulation protocol itself is actually thestruct concap_proto{ struct net_device *net_dev; /* net device using our service */ struct concap_device_ops *dops; /* callbacks provided by device */ struct concap_proto_ops *pops; /* callbacks provided by us */ int flags; void *proto_data; /* protocol specific private data, to be accessed via *pops methods only*/ /* : whatever : */};Most of this is filled in when the device requests the protocol to be reset (opend). The network interface must provide the net_dev anddops pointers. Other concap_proto members should be considered privatedata that are only accessed by the pops callback functions. Likewise,a concap proto should access the network device's private dataonly by means of the callbacks referred to by the dops pointer.A possible extended device structure which uses the connection controllingencapsulation services could look like this:struct concap_device{ struct net_device net_dev; struct my_priv /* device->local stuff */ /* the my_priv struct might contain a struct concap_device_ops *dops; to provide the device specific callbacks */ struct concap_proto *cprot; /* callbacks provided by protocol */};Misc Thoughts=============The concept of the concap proto might help to reuse protocol code andreduce the complexity of certain network interface implementations.The trade off is that it introduces yet another procedure call layerwhen processing the protocol. This has of course some impact onperformance. However, typically the concap interface will be used bydevices attached to slow lines (like telephone, isdn, leased synchronouslines). For such slow lines, the overhead is probably negligible.This might no longer hold for certain high speed WAN links (likeATM).If general linux network interfaces explicitly supported concapprotocols (e.g. by a member struct concap_proto* in struct net_device)then the interface of the service function could be changedby passing a pointer of type (struct net_device*) instead oftype (struct concap_proto*). Doing so would make many of the servicefunctions compatible to network device support functions.e.g. instead of the concap protocol's service function int (*encap_and_xmit)(struct concap_proto *cprot, struct sk_buff *skb);we could have int (*encap_and_xmit)(struct net_device *ndev, struct sk_buff *skb);As this is compatible to the dev->hard_start_xmit() method, the devicedriver could directly register the concap protocol's encap_and_xmit()function as its hard_start_xmit() method. This would eliminate oneprocedure call layer.The device's data request function could also be defined as int (*data_req)(struct net_device *ndev, struct sk_buff *skb);This might even allow for some protocol stacking. And the networkinterface might even register the same data_req() function directlyas its hard_start_xmit() method when a zero layer encapsulationprotocol is configured. Thus, eliminating the performance penaltyof the concap interface when a trivial concap protocol is used.Nevertheless, the device remains able to support encapsulationprotocol configuration.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -