xref: /OK3568_Linux_fs/kernel/Documentation/driver-api/rapidio/rio_cm.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun==========================================================================
2*4882a593SmuzhiyunRapidIO subsystem Channelized Messaging character device driver (rio_cm.c)
3*4882a593Smuzhiyun==========================================================================
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun1. Overview
7*4882a593Smuzhiyun===========
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunThis device driver is the result of collaboration within the RapidIO.org
10*4882a593SmuzhiyunSoftware Task Group (STG) between Texas Instruments, Prodrive Technologies,
11*4882a593SmuzhiyunNokia Networks, BAE and IDT.  Additional input was received from other members
12*4882a593Smuzhiyunof RapidIO.org.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunThe objective was to create a character mode driver interface which exposes
15*4882a593Smuzhiyunmessaging capabilities of RapidIO endpoint devices (mports) directly
16*4882a593Smuzhiyunto applications, in a manner that allows the numerous and varied RapidIO
17*4882a593Smuzhiyunimplementations to interoperate.
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunThis driver (RIO_CM) provides to user-space applications shared access to
20*4882a593SmuzhiyunRapidIO mailbox messaging resources.
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunRapidIO specification (Part 2) defines that endpoint devices may have up to four
23*4882a593Smuzhiyunmessaging mailboxes in case of multi-packet message (up to 4KB) and
24*4882a593Smuzhiyunup to 64 mailboxes if single-packet messages (up to 256 B) are used. In addition
25*4882a593Smuzhiyunto protocol definition limitations, a particular hardware implementation can
26*4882a593Smuzhiyunhave reduced number of messaging mailboxes.  RapidIO aware applications must
27*4882a593Smuzhiyuntherefore share the messaging resources of a RapidIO endpoint.
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunMain purpose of this device driver is to provide RapidIO mailbox messaging
30*4882a593Smuzhiyuncapability to large number of user-space processes by introducing socket-like
31*4882a593Smuzhiyunoperations using a single messaging mailbox.  This allows applications to
32*4882a593Smuzhiyunuse the limited RapidIO messaging hardware resources efficiently.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunMost of device driver's operations are supported through 'ioctl' system calls.
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunWhen loaded this device driver creates a single file system node named rio_cm
37*4882a593Smuzhiyunin /dev directory common for all registered RapidIO mport devices.
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunFollowing ioctl commands are available to user-space applications:
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun- RIO_CM_MPORT_GET_LIST:
42*4882a593Smuzhiyun    Returns to caller list of local mport devices that
43*4882a593Smuzhiyun    support messaging operations (number of entries up to RIO_MAX_MPORTS).
44*4882a593Smuzhiyun    Each list entry is combination of mport's index in the system and RapidIO
45*4882a593Smuzhiyun    destination ID assigned to the port.
46*4882a593Smuzhiyun- RIO_CM_EP_GET_LIST_SIZE:
47*4882a593Smuzhiyun    Returns number of messaging capable remote endpoints
48*4882a593Smuzhiyun    in a RapidIO network associated with the specified mport device.
49*4882a593Smuzhiyun- RIO_CM_EP_GET_LIST:
50*4882a593Smuzhiyun    Returns list of RapidIO destination IDs for messaging
51*4882a593Smuzhiyun    capable remote endpoints (peers) available in a RapidIO network associated
52*4882a593Smuzhiyun    with the specified mport device.
53*4882a593Smuzhiyun- RIO_CM_CHAN_CREATE:
54*4882a593Smuzhiyun    Creates RapidIO message exchange channel data structure
55*4882a593Smuzhiyun    with channel ID assigned automatically or as requested by a caller.
56*4882a593Smuzhiyun- RIO_CM_CHAN_BIND:
57*4882a593Smuzhiyun    Binds the specified channel data structure to the specified
58*4882a593Smuzhiyun    mport device.
59*4882a593Smuzhiyun- RIO_CM_CHAN_LISTEN:
60*4882a593Smuzhiyun    Enables listening for connection requests on the specified
61*4882a593Smuzhiyun    channel.
62*4882a593Smuzhiyun- RIO_CM_CHAN_ACCEPT:
63*4882a593Smuzhiyun    Accepts a connection request from peer on the specified
64*4882a593Smuzhiyun    channel. If wait timeout for this request is specified by a caller it is
65*4882a593Smuzhiyun    a blocking call. If timeout set to 0 this is non-blocking call - ioctl
66*4882a593Smuzhiyun    handler checks for a pending connection request and if one is not available
67*4882a593Smuzhiyun    exits with -EGAIN error status immediately.
68*4882a593Smuzhiyun- RIO_CM_CHAN_CONNECT:
69*4882a593Smuzhiyun    Sends a connection request to a remote peer/channel.
70*4882a593Smuzhiyun- RIO_CM_CHAN_SEND:
71*4882a593Smuzhiyun    Sends a data message through the specified channel.
72*4882a593Smuzhiyun    The handler for this request assumes that message buffer specified by
73*4882a593Smuzhiyun    a caller includes the reserved space for a packet header required by
74*4882a593Smuzhiyun    this driver.
75*4882a593Smuzhiyun- RIO_CM_CHAN_RECEIVE:
76*4882a593Smuzhiyun    Receives a data message through a connected channel.
77*4882a593Smuzhiyun    If the channel does not have an incoming message ready to return this ioctl
78*4882a593Smuzhiyun    handler will wait for new message until timeout specified by a caller
79*4882a593Smuzhiyun    expires. If timeout value is set to 0, ioctl handler uses a default value
80*4882a593Smuzhiyun    defined by MAX_SCHEDULE_TIMEOUT.
81*4882a593Smuzhiyun- RIO_CM_CHAN_CLOSE:
82*4882a593Smuzhiyun    Closes a specified channel and frees associated buffers.
83*4882a593Smuzhiyun    If the specified channel is in the CONNECTED state, sends close notification
84*4882a593Smuzhiyun    to the remote peer.
85*4882a593Smuzhiyun
86*4882a593SmuzhiyunThe ioctl command codes and corresponding data structures intended for use by
87*4882a593Smuzhiyunuser-space applications are defined in 'include/uapi/linux/rio_cm_cdev.h'.
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun2. Hardware Compatibility
90*4882a593Smuzhiyun=========================
91*4882a593Smuzhiyun
92*4882a593SmuzhiyunThis device driver uses standard interfaces defined by kernel RapidIO subsystem
93*4882a593Smuzhiyunand therefore it can be used with any mport device driver registered by RapidIO
94*4882a593Smuzhiyunsubsystem with limitations set by available mport HW implementation of messaging
95*4882a593Smuzhiyunmailboxes.
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun3. Module parameters
98*4882a593Smuzhiyun====================
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun- 'dbg_level'
101*4882a593Smuzhiyun      - This parameter allows to control amount of debug information
102*4882a593Smuzhiyun        generated by this device driver. This parameter is formed by set of
103*4882a593Smuzhiyun        bit masks that correspond to the specific functional block.
104*4882a593Smuzhiyun        For mask definitions see 'drivers/rapidio/devices/rio_cm.c'
105*4882a593Smuzhiyun        This parameter can be changed dynamically.
106*4882a593Smuzhiyun        Use CONFIG_RAPIDIO_DEBUG=y to enable debug output at the top level.
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun- 'cmbox'
109*4882a593Smuzhiyun      - Number of RapidIO mailbox to use (default value is 1).
110*4882a593Smuzhiyun        This parameter allows to set messaging mailbox number that will be used
111*4882a593Smuzhiyun        within entire RapidIO network. It can be used when default mailbox is
112*4882a593Smuzhiyun        used by other device drivers or is not supported by some nodes in the
113*4882a593Smuzhiyun        RapidIO network.
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun- 'chstart'
116*4882a593Smuzhiyun      - Start channel number for dynamic assignment. Default value - 256.
117*4882a593Smuzhiyun        Allows to exclude channel numbers below this parameter from dynamic
118*4882a593Smuzhiyun        allocation to avoid conflicts with software components that use
119*4882a593Smuzhiyun        reserved predefined channel numbers.
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun4. Known problems
122*4882a593Smuzhiyun=================
123*4882a593Smuzhiyun
124*4882a593Smuzhiyun  None.
125*4882a593Smuzhiyun
126*4882a593Smuzhiyun5. User-space Applications and API Library
127*4882a593Smuzhiyun==========================================
128*4882a593Smuzhiyun
129*4882a593SmuzhiyunMessaging API library and applications that use this device driver are available
130*4882a593Smuzhiyunfrom RapidIO.org.
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun6. TODO List
133*4882a593Smuzhiyun============
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun- Add support for system notification messages (reserved channel 0).
136