end.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:16k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* end.h - Structure for the MUX and END API*/
  2. /* Copyright 1984 - 2001 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 03g,23oct01,rae  merge from truestack (fix some ioctl values)
  7. 03f,16oct01,rcs  added END_ERR_NO_BUF flag to notify mux of driver cluster
  8.                  exhaustion. SPR# 70545
  9. 01z,13jul01,ann  added a flag for RFC2233 driver support to eliminate the
  10.                  global mibStyle variable
  11. 03e,09nov00,spm  removed pNptCookie from END_OBJ for binary compatibility
  12. 03d,07nov00,spm  removed nptFlag from END_OBJ for T2 END binary compatibility
  13. 03d,25oct00,niq  Merge RFC2233 changes from open_stack-p1-r1 branch
  14.                  03c,10mar00,ead  Modifed the END object to support RFC 
  15.                  variables
  16. 03c,16oct00,spm  merged version 01v from tor3_0_x branch (base version 01r):
  17.                  adds backward compatibility fixes and support for multiple
  18.                  snarf protocols and link-level broadcasts
  19. 03b,29apr99,pul  Upgraded NPT phase3 code to tor2.0.0
  20. 03a,29mar99,pul  altered END_QUERY struct to conform to WRS coding standard
  21. 02z,24mar99,sj   NET_PROTOCOL flags field is used by MUX
  22. 02y,05mar99,sj   added END_QUERY; added END_ERR_FLAGS
  23. 02x,02mar99,sj   fixed IOCTL values so that last byte of IOCTL cmd is <255
  24. 02w,22feb99,sj   added EIOCGBCASTADDR, EIOCGADDRLEN, EIOCGBIND ioctls
  25. 01v,15oct98,pul  changed the call back routines not to specify argument list 
  26. 01u,08oct98,sj   EIOCGNPT ioctl command for NPT
  27. 01t,29sep98,fle  doc : made it refgen parsable
  28. 01s,10sep98,pul  added endBind  and EIOCGNPT command
  29. 01r,25aug98,n_s  update comments for DEV_OBJ. spr 21546.
  30. 01q,17jan98,gnn  fixed a bug in output filtering.
  31. 01p,08dec97,gnn  END code review fixes.
  32. 01o,17oct97,vin  added llHdrInfo, changed prototypes.
  33. 01n,03oct97,gnn  fixed SPR 8986, added proper function prototypes
  34. 01m,25sep97,gnn  SENS beta feedback fixes
  35. 01l,19aug97,gnn  changes due to new buffering scheme.
  36. 01k,12aug97,gnn  changes necessitated by MUX/END update.
  37. 01j,02jun97,gnn  added EIOCGMWIDTH to get memory width from driver.
  38. 01i,15may97,gnn  added outputFilter element to device structure.
  39. 01h,07apr97,gnn  added END_TBL_ENTRY for new boot loading code.
  40. 01g,26feb97,gnn  Added END_BUF_MUX and END_BUF_DRIVER defines.
  41. 01f,21jan97,gnn  removed all buffer loaning stuff.
  42.                  added buffer pool variables and calls.
  43.                  added a IOCTL to get the minimumb first buffer in a
  44.                  scatter/gather system.
  45. 01e,27nov96,gnn  added MIB 2 Ioctl.
  46. 01d,07nov96,gnn  fixed the flags fields to be int.
  47. 01c,23oct96,gnn  name changes to follow coding standards.
  48. 01b,22oct96,gnn  added pragmas for the i960.
  49.                  removed netVector structure and added a pNext pointer
  50.                  to the NET_BUFFER.
  51.                  added function pointers for the start and stop routines.
  52.                  changed the ioctls to be noun->verb
  53. 01a,18apr96,gnn  written.
  54. */
  55.  
  56. /*
  57. DESCRIPTION
  58. This file defines all the structures uses by the MUX and any END.  These
  59. structures are either passed by functions in either the MUX or END
  60. or stored by the MUX.
  61. */
  62. #ifndef __INCendh
  63. #define __INCendh
  64. #ifdef __cplusplus
  65. extern "C" {
  66. #endif
  67. #include "vxWorks.h"
  68. #include "semLib.h"
  69. #include "m2Lib.h" /* For MIBII counters. */
  70. #include "lstLib.h" /* List library for linked structures. */
  71. #include "memLib.h"
  72. #include "netBufLib.h"
  73. #include "net/if_llc.h"
  74. #if CPU_FAMILY==I960
  75. #pragma align 1 /* tell gcc960 not to optimize alignments */
  76. #endif /* CPU_FAMILY==I960 */
  77. /*
  78.  * 
  79.  * Flags defined for the END.
  80.  *
  81.  */
  82. #define END_DEBUG 0x1000
  83. /*
  84.  * Flags for the type of a receive buffer that we've got.
  85.  */
  86. #define END_BUF_COPY  0x1 /* Protocol must copy data. */
  87. #define END_BUF_LOAN  0x2 /* We're loaning this buf. */
  88. /*
  89.  * Flags for buffers that are to be sent.
  90.  */
  91. #define END_BUF_VECTOR 0x4      /* The NET_BUFFER contains a pointer to an */
  92.                                 /* array of NET_BUFFERS and not just one. */
  93. #define END_BUF_MUX    0x8      /* The NET_BUFFER was allocated by the MUX */
  94. #define END_BUF_DRIVER 0x10     /* The NET_BUFFER was allocated by the */
  95.                                 /* driver. */
  96. /* Flag denoting the support for RFC 2233 MIB variables */
  97. #define END_MIB_2233   0x10000  /* Set if RFC 2233 counters are supported */
  98. #define END_INIT_STR_MAX 255
  99. #define END_PROTO_NAME_MAX 32
  100. #define END_NAME_MAX 8          /* The maximum length of a device name */
  101. #define END_DESC_MAX 80         /* The maximum length of device desription. */
  102. /*
  103.  * ERROR Return for device blocked on transmit.
  104.  */
  105. #define END_ERR_BLOCK -2
  106. /*
  107.  * ERROR protocol defines.  These are stored in a 32 bit word in the
  108.  * end_err structure.  User apps can have the upper 16 bits, we get the
  109.  * lower 16.
  110.  */
  111. #define END_ERR_INFO     1   /* Information only */
  112. #define END_ERR_WARN     2   /* Warning */
  113. #define END_ERR_RESET    3   /* Device has reset. */
  114. #define END_ERR_DOWN     4   /* Device has gone down. */
  115. #define END_ERR_UP       5   /* Device has come back on line. */
  116. #define END_ERR_FLAGS  6   /* Device flags changed */
  117. #define END_ERR_NO_BUF   7   /* Device's cluster pool exhausted. */ 
  118. typedef struct end_err
  119.     {
  120.     INT32 errCode;           /* Error code, see above. */
  121.     char* pMesg;             /* NULL terminated error message */
  122.     void* pSpare;            /* Pointer to user defined data. */
  123.     } END_ERR;
  124.     
  125. /* A specific instance of an Ethernet multicast address. */
  126. typedef struct 
  127.     {
  128.     NODE node;      /* How we stay in a list. */
  129.     char  addr[6];      /* address */
  130.     long   refcount;      /* no. claims to this addr*/
  131.     } ETHER_MULTI; 
  132. typedef struct 
  133.     {
  134.     long len; /* Length of table in bytes. */
  135.     char *pTable; /* Pointer to entries. */
  136.     } MULTI_TABLE;
  137. /* structure used as a vehicle to move data during a EIOCQUERY ioctl */
  138. typedef struct
  139.     {
  140.     int query; /* the query */
  141.     int queryLen; /* length of data expected/returned */
  142.     char queryData[4]; /* allocate a minimum of 4 bytes; expandable upto 120 */
  143.     } END_QUERY;
  144. /*
  145.  *
  146.  * DEV_OBJ - device specific control object
  147.  *
  148.  * The DEV_OBJ structure is the glue linking the device generic END_OBJ 
  149.  * structure with the device specific data object referenced by pDevice.
  150.  */
  151. typedef struct dev_obj 
  152.     {
  153.     char name[END_NAME_MAX];
  154.     int unit;
  155.     char description[END_DESC_MAX];
  156.     void* pDevice; /* Pointer back to the device data. */
  157.     } DEV_OBJ;
  158. /*
  159. * LL_HDR_INFO - link level Header info 
  160. *
  161. * This data structure defines information that is only relevant to
  162. * a stack receive routine.
  163. *
  164. */
  165. typedef struct llHdrInfo
  166.     {
  167.     int destAddrOffset; /* destination addr offset in mBlk */
  168.     int destSize;  /* destination address size */
  169.     int srcAddrOffset; /* source address offset in mBlk */
  170.     int srcSize; /* source address size */
  171.     int ctrlAddrOffset; /* control info offset in mBlk */
  172.     int ctrlSize; /* control info size */
  173.     int pktType; /* type of the packet */
  174.     int dataOffset; /* data offset in the mBlk */
  175.     } LL_HDR_INFO;
  176. /*
  177.  *
  178.  * endObject - the basic end object that everyone derives from
  179.  *
  180.  * This data structure defines a device independant amount of state
  181.  * that is maintained by all drivers/devices.
  182.  * Each specific device (Lance, Intel, etc.) derives from this object
  183.  * first and then incorporates it's own data structures after it.
  184.  *
  185.  */
  186. typedef struct end_object
  187.     {
  188.     NODE node;
  189. #ifndef _WRS_VXWORKS_5_X
  190.     BOOL nptFlagSpace;          /* Had indicated type of interface: END or NPT. Now: UNUSED */
  191. #endif /* _WRS_VXWORKS_5_X */
  192.     DEV_OBJ devObject; /* Root of the device heirarchy. */
  193.     STATUS (*receiveRtn) ();
  194.                                 /* Routine to call on reception. */
  195.     struct net_protocol *outputFilter;
  196.                                 /* Optional output filter routine. */
  197.     void* pOutputFilterSpare;   /* Output filter's spare pointer */
  198.     BOOL attached; /* Indicates unit is attached. */
  199.     SEM_ID txSem; /* Transmitter semaphore. */
  200.     long flags; /* Various flags. */
  201.     struct net_funcs *pFuncTable; /* Function table. */
  202.     M2_INTERFACETBL mib2Tbl; /* MIBII counters. */
  203.     LIST multiList; /* Head of the multicast address list */
  204.     int nMulti; /* Number of elements in the list. */
  205.     LIST protocols; /* Protocol node list. */
  206.     int snarfCount;             /* Number of snarf protocols at head of list */
  207.     NET_POOL_ID pNetPool;       /* Memory cookie used by MUX buffering. */
  208. #ifndef _WRS_VXWORKS_5_X
  209.     void * pNptCookie;  /* Access to NPT BIB (for unloading). UNUSED */
  210. #endif /* _WRS_VXWORKS_5_X */
  211.     M2_ID * pMib2Tbl;           /* RFC 2233 MIB objects */
  212.     } END_OBJ;
  213.     
  214. /*
  215.  * 
  216.  * NET_PROTOCOL - protocol structure
  217.  *
  218.  * This data structure defines information that is only relevant to
  219.  * a protocol.  This structure hangs from a singly linked list whose
  220.  * head is stored in a netDevice.
  221.  *
  222.  */
  223. typedef struct net_protocol 
  224.     {
  225.     NODE node; /* How we stay in a list. */
  226.     char name[END_PROTO_NAME_MAX];     /* String name for this protocol. */
  227.     long type; /* Protocol type from RFC 1700 */
  228.     BOOL nptFlag;  /* NPT or original MUX prototype? */
  229.     BOOL (*stackRcvRtn) ();
  230.                                 /* The routine to call when we get */
  231. /* a packet. */
  232.     STATUS (*stackShutdownRtn) ();
  233.                                 /* The routine to call to shutdown */
  234. /* the protocol stack. */
  235.     STATUS (*stackTxRestartRtn) ();
  236.                                 /* Callback for restarting on blocked tx. */
  237.     void (*stackErrorRtn) ();
  238.                                 /* Callback for device errors. */
  239.     END_OBJ * pEnd;  /* Device bound to protocol. */
  240.     void* pSpare;               /* Spare pointer that can be passed to */
  241.                                 /* the protocol. */
  242.     void * pNptCookie;  /* Access to NPT BIB (for unbinding). */
  243.     } NET_PROTOCOL;
  244. /*
  245.  * 
  246.  * NET_FUNCS - driver function table
  247.  *
  248.  * This is a table that is created, one per driver, to hold all the
  249.  * function pointers for that driver.  In this way we can have only one
  250.  * instance to this structer, but one pointer per netDevice structure.
  251.  */
  252. typedef struct net_funcs
  253.     {
  254.     STATUS (*start) (END_OBJ*);    /* Driver's start func. */
  255.     STATUS (*stop) (END_OBJ*);    /* Driver's stop func. */
  256.     STATUS (*unload) (END_OBJ*);    /* Driver's unload func. */
  257.     int (*ioctl) (END_OBJ*, int, caddr_t);    /* Driver's ioctl func. */
  258.     STATUS (*send) (END_OBJ* , M_BLK_ID);    /* Driver's send func. */
  259.     STATUS (*mCastAddrAdd) (END_OBJ*, char*); /* Driver's mcast add func. */
  260.     STATUS (*mCastAddrDel) (END_OBJ*, char*); /* Driver's mcast delete func. */
  261.     STATUS (*mCastAddrGet) (END_OBJ*, MULTI_TABLE*);
  262.                                            /* Driver's mcast get fun. */
  263.     STATUS (*pollSend) (END_OBJ*, M_BLK_ID);  /* Driver's polling send func. */
  264.     STATUS (*pollRcv) (END_OBJ*, M_BLK_ID);   /* Driver's polling receive func. */
  265.     M_BLK_ID (*formAddress) (M_BLK_ID, M_BLK_ID, M_BLK_ID, BOOL);
  266.                                            /* Driver's addr formation func. */
  267.     STATUS (*packetDataGet) (M_BLK_ID, LL_HDR_INFO *);
  268.                                            /* Driver's packet data get func. */
  269.     STATUS (*addrGet) (M_BLK_ID, M_BLK_ID, M_BLK_ID, M_BLK_ID, M_BLK_ID);
  270.                                            /* Driver's packet addr get func. */
  271.     int (*endBind) (void*, void*, void*, long type); 
  272. /* information exchange between */
  273. /* network service and network driver */ 
  274.     } NET_FUNCS; 
  275. /*
  276.  * 
  277.  * End Specific IOCTL commands.
  278.  *
  279.  * The following are the end specific IOCTL commands.  This is a place
  280.  * holder for them until we places them into the system ioctl.h file.
  281.  * 
  282.  * EIOC stands for END ioctl, just as SIOC stands for socket ioctl.
  283.  *
  284.  * The original set of END IOCTL commands started with number 260 and continued
  285.  * upwards. The value 260 or higher cannot be accomodated within the LSByte
  286.  * reserved for it by the _IO[RW] macros(sys/ioctl.h).
  287.  *
  288.  * However the numbers, 260 through 274, that were used did not
  289.  * alter the value of the command byte('i') in the IOCTL command and
  290.  * are equivalent to the numbers 4 through 18 used below. This preserves
  291.  * binary compatibility with END drivers that were built using the old defines.
  292.  *
  293.  * This list of IOCTLS with command byte 'i' SHOULD NOT BE EXTENDED BEYOND 18
  294.  *
  295.  * User defined IOCTLS should use the command byte 'e' (for END) and should
  296.  * start at 128. Numbers 0 through 127 are reserved by Wind River Systems.
  297.  */
  298. #include "ioctl.h"
  299. /* Device commands */
  300. #define EIOCSFLAGS _IOW('i', 4, int) /* Set device flag */
  301. #define EIOCGFLAGS _IOR('i', 5, int) /* Get device flag */
  302. #define EIOCSADDR _IOW('i', 6, char *) /* Set device address */
  303. #define EIOCGADDR _IOR('i', 7, char *) /* Get device address */
  304. #define EIOCGFBUF _IOR('i', 8, int)   /* Get min 1st buf for chaining. */
  305. #define EIOCGMWIDTH _IOR('i', 9, int)   /* Get device memory width. */
  306. /* Multicast commands */
  307. #define EIOCMULTIADD _IOW('i', 10, char *) /* add m'cast addr */
  308. #define EIOCMULTIDEL _IOW('i', 11, char *) /* del m'cast addr */
  309. #define EIOCMULTIGET _IOWR('i', 12, MULTI_TABLE)/* get m'cast addr */
  310. /* Miscellaneous functions */
  311. #define EIOCSRCVCB _IOW('i', 13, FUNCPTR) /* Set receive callback */
  312. #define EIOCPOLLSTART _IOW('i', 14, NULL) /* Start polling. */
  313. #define EIOCPOLLSTOP _IOW('i', 15, NULL) /* Stop polling. */
  314. /* MibII functions */
  315. #define EIOCGMIB2 _IOR('i', 16, M2_INTERFACETBL *)
  316. /* Name function. */
  317. #define EIOCGNAME _IOR('i', 17, char *)     /* get the device name */
  318. /* Header length fucntion. */
  319. #define EIOCGHDRLEN _IOR('i', 18, int)     /* get the header length */
  320. /*
  321.  * The IOCTL commands below were introduced by the Network Protocol Toolkit
  322.  * The command byte is set to 'e' for END and numbers 1 thro' 127 are reserved
  323.  * for WRS.
  324.  * Below we start at 20 to allow room for the above 'i' based IOCTLS to be
  325.  * converted to 'e' based IOCTLS sometime in the future.
  326.  */
  327. /* Toolkit device or not */
  328. #define EIOCGNPT _IOR('e', 20, NULL) /* return true in case of toolkit device*/
  329. /* Broadcast address */
  330. #define EIOCGBCASTADDR _IOR('e', 21, char *) /* return Broadcast addr */
  331. /* Query IOCTL command */
  332. #define EIOCQUERY _IOWR('e', 22, END_QUERY)
  333. /* More MibII functions */
  334. #define EIOCGMIB2233 _IOR('e', 23, M2_ID **) 
  335. #define EIOCSMIB2233 _IOW('e', 24, IF_SETENTRY *) 
  336. #define EIOCGMCASTLIST _IOR('e', 25, LIST **)
  337. /* MTU for Point to Multipoint */
  338. #define EIOCGMTU _IOR('e', 26, MTU_QUERY *)
  339. /* Query system Query commands */
  340. #define END_BIND_QUERY 0x1
  341. /* This structure is a row in our run time END table. 
  342.  * Each row contains all the units started on a particular named device.
  343.  * I.e. all devices that are Lance 7990 Ethernet will be in the list
  344.  * off of the row with the name "ln".
  345.  */
  346. typedef struct end_tbl_row
  347.     {
  348.     NODE node;                  /* Needed by our list processing library. */
  349.     char name[END_NAME_MAX]; /* Name of the devices in row. (ln, etc.) */
  350.     LIST units;                 /* List of devices, i.e. 0, 1, etc..  */
  351.     } END_TBL_ROW;
  352. /* This is the structure that is used by the BSP to build up a table
  353.  * of END devices to be started at boot time.
  354.  */
  355. typedef struct end_tbl_entry
  356.     {
  357.     int unit;                                /* This device's unit # */
  358.     END_OBJ* (*endLoadFunc) (char*, void*);         /* The Load function. */
  359.     char* endLoadString;                     /* The load string. */
  360.     BOOL endLoan;                            /* Do we loan buffers? */
  361.     void* pBSP;                              /* BSP private */
  362.     BOOL processed;                          /* Has this been processed? */
  363.     } END_TBL_ENTRY;
  364.     
  365. #define END_TBL_END NULL
  366.     
  367. #if CPU_FAMILY==I960
  368. #pragma align 0 /* turn off alignment requirement */
  369. #endif /* CPU_FAMILY==I960 */
  370. #ifdef __cplusplus
  371. }
  372. #endif
  373. #endif /* __INCendh */