home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / internet / netlite2 / DCI / newdci < prev   
Encoding:
Text File  |  1993-04-25  |  15.1 KB  |  436 lines

  1.                       Driver Control Interface
  2.                       ========================
  3.  
  4.                       Version 3  August 1992
  5.                           CONFIDENTIAL
  6.  
  7.  
  8. 1. Introduction
  9. ---------------
  10.  
  11. This note describes the interface between a protocol module and a 
  12. device driver module used by the protocol. The interface will enable 
  13. multiple protocol stacks to control multiple different device drivers 
  14. simulataneously, if required.
  15.  
  16. The interface is optimised in its detail to handle device drivers for 
  17. Ethernet. Drivers for other types of network will need to emulate Ethernet 
  18. in these details at this interface and map "virtual Ethernet" values into 
  19. real values meaningful to the actual connected network.
  20.  
  21. Specifically:
  22.  
  23. i)  physical network addresses are 48 bit quantities.
  24.  
  25. ii) the values of physical network frames "owned" by protocol modules 
  26.     are expressed as Ethernet frame type values. Example:
  27.  
  28.         Internet owns three types of physical frame, namely frames 
  29.         containing IP, ARP and Reverse ARP protocol messages. The 
  30.         driver module will be informed via the values &800, &806 and 
  31.         &8035 respectively.
  32.  
  33. iii) At startup, driver modules must set the variable
  34.  
  35.           Inet$EtherType
  36.  
  37.      to the text string name of the controlled physical interface type 
  38.      ("et", "en", etc), with the suffix '0' (e.g "et0", "en0" etc). 
  39.      This is for compatibility with Acorn AUN and TCP/IP software. 
  40.      The name part is the same string referred to in the Driver 
  41.      Information Block.
  42.  
  43.  
  44. 2. Service calls
  45. ----------------
  46.  
  47. When loaded, a network interface driver module will perform various 
  48. internal and hardware initialisation functions. It will then announce
  49. its presence via the service call Service_NetworkDriverStatus (0) and 
  50. wait for a protocol module, such as Internet, to search for device 
  51. drivers controlling interfaces which the protocol wishes to access. 
  52. This is done via the service call Service_FindNetworkDriver. Subsequently, 
  53. if a protocol module terminates it will notify associated driver
  54. modules via Service_ProtocolDying. A terminating driver module issues
  55. Service_NetworkDriverStatus (1).
  56.  
  57.  
  58. Service_FindNetworkDriver (Service call &84)
  59.  
  60.     On entry: R1 = &84  (reason code)
  61.               R2 = pointer to name of driver sought ("et", "en", etc),
  62.                    or zero, or -1.
  63.               R3 = pointer to "Protocol Information Block" describing 
  64.                    this protocol, or zero. 
  65.               R4 = slot number, if R2 = -1 and R3 = 0
  66.  
  67.     On exit:  All registers preserved (if not claimed)
  68.  
  69.               If claimed:
  70.               R1 = 0
  71.               R2 preserved
  72.               R3 = pointer to "Driver Information Block" describing 
  73.                    available driver 
  74.  
  75.     Use:      Service_FindNetworkDriver makes a logical connection between 
  76.               a protocol module and a driver module, enabling information 
  77.               about each other to be exchanged. 
  78.  
  79.               Service_FindNetworkDriver may also be used to find out whether 
  80.               a driver module is present, without making a logical connection.
  81.               In this case R2 and R3 are zero on entry. Exit register values
  82.               are the same if claimed by a driver module.
  83.  
  84.               Service_FindNetworkDriver may also be used to find out which 
  85.               driver module controls the device located in a given backplane 
  86.               slot. In this case R2 is -1, R3 is zero and R4 contains the 
  87.               slot number (0 - 3) on entry. Exit register values are the same
  88.               if claimed by a driver module.
  89.  
  90.  
  91. Service_ProtocolDying (Service call &83)
  92.  
  93.     On entry: R1 = &83  (reason code)
  94.               R2 = ID of exiting protocol 
  95.  
  96.     On exit:  All registers preserved to pass on 
  97.  
  98.     Use:      Service_ProtocolDying is issued by a protocol module
  99.               to notify driver modules that the protocol is exiting.
  100.               The protocol ID is the same value as previously passed
  101.               to the driver in pib.pib_sccall. Driver modules must
  102.               never claim this service call.
  103.  
  104.  
  105. Service_NetworkDriverStatus (Service call &8b)
  106.  
  107.     On entry: R1 = &8b  (reason code)
  108.               R2 = status (0 = starting, 1 = terminating)
  109.               R3 = pointer to "Driver Information Block" describing 
  110.                    this driver 
  111.  
  112.     On exit:  All registers preserved. This service call should not be
  113.               claimed.
  114.  
  115.     Use:      Service_NetworkDriverStatus is issued by a network driver
  116.               module to indicate that it is starting up or terminating.
  117.  
  118.  
  119. Protocol Information Block
  120. --------------------------
  121.  
  122. struct pib {
  123.     char        pib_frtypecnt;
  124.     unsigned short pib_frtype[6];
  125.     int         pib_rxevent;
  126.     struct mbuf **pib_freeq;
  127.     int         pib_sccall;
  128.     struct mbuf **pib_lfreeq;
  129. };
  130.  
  131. pib_frtypecnt
  132.  
  133.         Number of valid fields in pib_frtype[].
  134.  
  135. pib_frtype[]
  136.  
  137.         Array of physical frame type values which are "owned"
  138.         by this protocol. The driver module will route all
  139.         incoming frames with these types to this module, via
  140.         an event sequence governed by pib_rxevent.
  141.  
  142. pib_rxevent
  143.  
  144.         Number of RISC OS event to generate when an incoming frame 
  145.         of the correct type is received. This mechanism is used to
  146.         pass incoming frames into the correct protocol module.
  147.  
  148. pib_freeq
  149.  
  150.         Address of free list of "small" data buffers owned by this
  151.         protocol module but available to the driver module
  152.         to store data associated with incoming frames of the
  153.         correct type. [Note: driver modules must never themselves
  154.         free data buffers obtained from this list.]
  155.  
  156. pib_sccall
  157.  
  158.         ID for this protocol which will be included in 
  159.         Service_ProtocolDying on module termination. Internet = 1.
  160.  
  161. pib_lfreeq
  162.  
  163.         Address of free list of "large" data buffers owned by this 
  164.         protocol module but available to the driver module
  165.         to store data associated with incoming frames of the 
  166.         correct type. These buffers should be large enough to 
  167.         accomodate a full Ethernet frame. There may only be a 
  168.         small number available so a driver module should be 
  169.         prepared to "fall back" on small buffers if no large 
  170.         buffer is available. [Note: driver modules must never
  171.         themselves free data buffers obtained from this list.]
  172.  
  173.  
  174. Driver Information Block
  175. ------------------------
  176.  
  177. struct dib {
  178.     char    *dib_name;
  179.     int     dib_units;
  180.     int     dib_swibase;
  181.     char    *dib_address[4];
  182.     char    *dib_module;
  183. };
  184.  
  185. dib_name    
  186.  
  187.         Pointer to text string name of physical interface type
  188.         controlled by this driver module ("et", "en", "ec", etc).
  189.  
  190. dib_units
  191.  
  192.         Number of accessible physical interfaces present of the
  193.         type controlled by this driver module.
  194.  
  195. dib_swibase
  196.  
  197.         Base of SWI block owned by this driver module.
  198.  
  199. dib_address[]
  200.  
  201.         Pointers to physical addresses of interface cards. Each address 
  202.         is a 48 bit (6 byte) quantity. [The array size 4 is pragmatic]
  203.  
  204. dib_module
  205.  
  206.         Pointer to title of driver module (e.g. "Ether3")
  207.  
  208. Once the startup sequence is complete, the protocol module will communicate
  209. with the driver module via SWI calls, and the driver module will interrupt
  210. the protocol module with events to indicate received frames.
  211.  
  212.  
  213. 3. SWI calls
  214. ------------
  215.  
  216. The following set of SWI calls enable a protocol module to pass data and
  217. control commands to a device driver module. Each different driver will
  218. own a unique chunk of SWI numbers whose base is passed to a protocol
  219. module at startup time via the Driver Information Block. SWI numbers
  220. offset sequentially from the SWI chunk base will correspond functionally
  221. to the commands described below.
  222.  
  223. SWI_NetworkIfStart (SWI &(dib_swibase + 0))
  224.  
  225.     Start a physical interface unit controlled by the owner of dib_swibase.
  226.  
  227.     On entry: R0 = unit number (0 - 3)
  228.  
  229.     On exit:  registers preserved
  230.  
  231.     Use:      Called by protocol module to start interface 
  232.               and enable subsequent I/O. 
  233.  
  234.  
  235. SWI_NetworkIfUp    (SWI &(dib_swibase + 1))
  236.  
  237.     Restart a physical interface unit.
  238.  
  239.     On entry: R0 = unit number (0 - 3)
  240.  
  241.     On exit:  registers preserved
  242.  
  243.     Use:      Called by protocol module to restart interface and
  244.               reenable subsequent I/O, after an earlier call of
  245.               SWI_NetworkIfDown. 
  246.  
  247.  
  248. SWI_NetworkIfDown  (SWI &(dib_swibase + 2))
  249.  
  250.     Disable a physical interface unit.
  251.  
  252.     On entry: R0 = unit number (0 - 3)
  253.  
  254.     On exit:  registers preserved
  255.  
  256.     Use:      Called by protocol module to disable indicated interface 
  257.               and disallow subsequent I/O. 
  258.  
  259.  
  260. SWI_NetworkIfSend  (SWI &(dib_swibase + 3))
  261.  
  262.     Transmit data via a physical interface unit.
  263.  
  264.     On entry: R1 = unit number (0 - 3)
  265.               R2 = frame type
  266.               R3 = pointer to destination physical address;
  267.                    48 bit (6 byte) quantity
  268.               R4 = pointer to message buffer chain containing
  269.                    transmit data.
  270.               R5 = event number to call on completion or error
  271.                    (or zero for no event required) 
  272.  
  273.     On exit:  registers preserved
  274.  
  275.     Use:      Called by protocol module to transmit data, held in
  276.               a chain of buffers. The destination physical
  277.               address and a frame type value identifying the
  278.               sending protocol are specified. If the protocol
  279.               module wishes to be notified via an event about the
  280.               status of the transmission (beyond any error value 
  281.               which may be passed back directly on SWI exit) then
  282.               the event number (> 0) will be specified.        
  283.  
  284.               If R5 = 0 then the protocol module may assume that 
  285.               it can free the associated mbuf chain immediately 
  286.               on return from the SWI call, otherwise it must wait 
  287.               for the event to occur before freeing the mbufs.
  288.  
  289.               See SWI_TxEventRequired below.
  290.  
  291.  
  292. SWI_DCIVersion  (SWI &(dib_swibase + 4))
  293.  
  294.     Return version number of DCI specification implemented.
  295.  
  296.     On entry: No parameters passed
  297.  
  298.     On exit:  R0 = Version number integer
  299.                    current version = 3
  300.  
  301.     Use:      Called by protocol module to ensure that a 
  302.               device driver module implements the version of 
  303.               DCI interface compatible with itself.
  304.  
  305.  
  306. SWI_NetworkMTU  (SWI &(dib_swibase + 5))
  307.  
  308.     Return physical MTU of supported network
  309.  
  310.     On entry: No parameters passed
  311.  
  312.     On exit:  R0 = MTU or zero
  313.  
  314.     Use:      Called by protocol module to find out the 
  315.               MTU of the underlying network, for example to 
  316.               enable efficient fragmentation of datagrams. 
  317.               Default (R0 = 0) is ETHERNET MTU (1500 octets).
  318.  
  319.  
  320. SWI_TxEventRequired  (SWI &(dib_swibase + 6))
  321.  
  322.     Return wether device driver requires an event value of TX
  323.  
  324.     On entry: No parameters passed
  325.  
  326.     On exit:  R0 = 1 tx event number required
  327.                    0 tx event number not required
  328.  
  329.     Use:      Called by protocol module to find out wether 
  330.               the transmission strategy used by the device 
  331.               driver module requires the protocol module to 
  332.               supply a txevent value with every transmission 
  333.               SWI call (SWI_NetworkIfSend) - i.e transmission 
  334.               synchronous to SWI_NetworkIfSend cannot be 
  335.               guaranteed on request. (NB This may impact on 
  336.               performance optimisations within the protocol 
  337.               module.)
  338.  
  339.  
  340. 4. Events
  341. ---------
  342.  
  343. An event may be generated by a driver module to indicate that 
  344. a data transmission request has been processed or that a frame 
  345. has been received from the network. Different event numbers are 
  346. owned by different protocol modules, and are supplied to driver 
  347. modules via SWI_NetworkIfSend (for tx) and Service_FindNetworkDriver 
  348. (for rx) calls.
  349.  
  350. TX Event
  351. --------
  352.  
  353. On entry to event handler:  
  354.  
  355.                R0 = tx event number (specified by protocol module)
  356.                R1 = pointer to data buffer chain containing
  357.                     tx data
  358.                R2 = pointer to name of interface controlled by
  359.                     this driver ("ea", "en", etc)
  360.                R3 = physical unit number (0 - 3)
  361.                R4 = error number (driver specific) or zero = ok
  362.  
  363. A transmission event does not necessarily imply that a frame has been 
  364. successfully transmitted and received by the target host, merely that 
  365. the local operation has been completed - either with or without a 
  366. detected hardware error - and so the protocol module may free the 
  367. addressed message buffer chain. A protocol module has the option
  368. of requesting an event or no event with each SWI call to transmit data 
  369. (see above).
  370.  
  371. RX Event
  372. --------
  373.  
  374. On entry to event handler: 
  375.  
  376.                R0 = rx event number (protocol specified)
  377.                R1 = pointer to data buffer chain containing
  378.                     rx data
  379.                R2 = pointer to name of interface controlled by
  380.                     this driver ("ea", "en", etc)
  381.                R3 = physical unit number (0 - 3)
  382.                R4 = rx frame type
  383.  
  384. A receive event means that an incoming frame "addressed" (via the frame
  385. type field) to a protocol module has been received and stored within
  386. the addressed data buffers obtained for this purpose from the protocol 
  387. module's freelist. Once the event is generated, the driver module must 
  388. forget about the associated data buffers. These will be received by the 
  389. protocol module's event handler and in due course returned by the protocol 
  390. module to its own freelist. Data buffers comprising an individual frame 
  391. are chained together via the m_next field (see below).
  392.  
  393. If the frame type field is zero, then the driver module intends that 
  394. the protocol module should free the returned data buffers immediately 
  395. (ie reception aborted).
  396.  
  397. The first buffer in each frame chain does not contain frame data. The
  398. first four bytes contains a pointer to a Driver Information Block describing
  399. this driver. The next six bytes contain the 48-bit physical address of the
  400. source of the received frame.
  401.  
  402.  
  403. 5. Data buffers
  404. ---------------
  405.  
  406. Data passes across the interface between the protocol and driver modules 
  407. in "mbufs". These are the similar to the data structure as used internally 
  408. within the BSD UNIX kernel, and also within the RISC OS Internet module, 
  409. for handling network data. Mbufs are aligned on 128 byte boundaries and 
  410. can either store internally up to 112 data bytes, or else reference 
  411. an external block of data. The format is:
  412.  
  413. #define MSIZE   128
  414. #define MMINOFF  12
  415. #define MTAIL     4
  416. #define MLEN     (MSIZE-MMINOFF-MTAIL)
  417.  
  418. struct mbuf { 
  419.         struct  mbuf *m_next;           /* next buffer in chain */
  420.         u_long  m_off;                  /* offset of data */
  421.         short   m_len;                  /* amount of data */
  422.         char    m_type;                 /* mbuf type */
  423.         char    m_indir;                /* data is indirect */
  424.         union {
  425.                 u_char  mun_dat[MLEN];  /* data storage */
  426.                 char   *mun_datp;       /* indirect data pointer */
  427.         } m_un;
  428.         struct  mbuf *m_act;            /*  must be zero */
  429. };
  430.  
  431. #define m_dat     m_un.mun_dat
  432. #define m_datp    m_un.mun_datp
  433.  
  434. If the data is indirect then the device driver module must make no 
  435. assumptions about the actual locations of the referenced data.
  436.