if_frad.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * DLCI/FRAD Definitions for Frame Relay Access Devices. DLCI devices are
  3. * created for each DLCI associated with a FRAD. The FRAD driver
  4. * is not truly a network device, but the lower level device
  5. * handler. This allows other FRAD manufacturers to use the DLCI
  6. * code, including its RFC1490 encapsulation alongside the current
  7. * implementation for the Sangoma cards.
  8. *
  9. * Version: @(#)if_ifrad.h 0.15 31 Mar 96
  10. *
  11. * Author: Mike McLagan <mike.mclagan@linux.org>
  12. *
  13. * Changes:
  14. * 0.15 Mike McLagan changed structure defs (packed)
  15. * re-arranged flags
  16. * added DLCI_RET vars
  17. *
  18. * This program is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU General Public License
  20. * as published by the Free Software Foundation; either version
  21. * 2 of the License, or (at your option) any later version.
  22. */
  23. #ifndef _FRAD_H_
  24. #define _FRAD_H_
  25. #include <linux/if.h>
  26. #if defined(CONFIG_DLCI) || defined(CONFIG_DLCI_MODULE)
  27. /* Structures and constants associated with the DLCI device driver */
  28. struct dlci_add
  29. {
  30. char devname[IFNAMSIZ];
  31. short dlci;
  32. };
  33. #define DLCI_GET_CONF (SIOCDEVPRIVATE + 2)
  34. #define DLCI_SET_CONF (SIOCDEVPRIVATE + 3)
  35. /*
  36. * These are related to the Sangoma SDLA and should remain in order.
  37. * Code within the SDLA module is based on the specifics of this
  38. * structure. Change at your own peril.
  39. */
  40. struct dlci_conf {
  41. short flags;
  42. short CIR_fwd;
  43. short Bc_fwd;
  44. short Be_fwd;
  45. short CIR_bwd;
  46. short Bc_bwd;
  47. short Be_bwd;
  48. /* these are part of the status read */
  49. short Tc_fwd;
  50. short Tc_bwd;
  51. short Tf_max;
  52. short Tb_max;
  53. /* add any new fields here above is a mirror of sdla_dlci_conf */
  54. };
  55. #define DLCI_GET_SLAVE (SIOCDEVPRIVATE + 4)
  56. /* configuration flags for DLCI */
  57. #define DLCI_IGNORE_CIR_OUT 0x0001
  58. #define DLCI_ACCOUNT_CIR_IN 0x0002
  59. #define DLCI_BUFFER_IF 0x0008
  60. #define DLCI_VALID_FLAGS 0x000B
  61. /* FRAD driver uses these to indicate what it did with packet */
  62. #define DLCI_RET_OK 0x00
  63. #define DLCI_RET_ERR 0x01
  64. #define DLCI_RET_DROP 0x02
  65. /* defines for the actual Frame Relay hardware */
  66. #define FRAD_GET_CONF (SIOCDEVPRIVATE)
  67. #define FRAD_SET_CONF (SIOCDEVPRIVATE + 1)
  68. #define FRAD_LAST_IOCTL FRAD_SET_CONF
  69. /*
  70. * Based on the setup for the Sangoma SDLA. If changes are
  71. * necessary to this structure, a routine will need to be
  72. * added to that module to copy fields.
  73. */
  74. struct frad_conf
  75. {
  76. short station;
  77. short flags;
  78. short kbaud;
  79. short clocking;
  80. short mtu;
  81. short T391;
  82. short T392;
  83. short N391;
  84. short N392;
  85. short N393;
  86. short CIR_fwd;
  87. short Bc_fwd;
  88. short Be_fwd;
  89. short CIR_bwd;
  90. short Bc_bwd;
  91. short Be_bwd;
  92. /* Add new fields here, above is a mirror of the sdla_conf */
  93. };
  94. #define FRAD_STATION_CPE 0x0000
  95. #define FRAD_STATION_NODE 0x0001
  96. #define FRAD_TX_IGNORE_CIR 0x0001
  97. #define FRAD_RX_ACCOUNT_CIR 0x0002
  98. #define FRAD_DROP_ABORTED 0x0004
  99. #define FRAD_BUFFERIF 0x0008
  100. #define FRAD_STATS 0x0010
  101. #define FRAD_MCI 0x0100
  102. #define FRAD_AUTODLCI 0x8000
  103. #define FRAD_VALID_FLAGS 0x811F
  104. #define FRAD_CLOCK_INT 0x0001
  105. #define FRAD_CLOCK_EXT 0x0000
  106. #ifdef __KERNEL__
  107. /* these are the fields of an RFC 1490 header */
  108. struct frhdr
  109. {
  110. unsigned char control;
  111. /* for IP packets, this can be the NLPID */
  112. unsigned char pad;
  113. unsigned char NLPID;
  114. unsigned char OUI[3];
  115. unsigned short PID;
  116. #define IP_NLPID pad
  117. } __attribute__((packed));
  118. /* see RFC 1490 for the definition of the following */
  119. #define FRAD_I_UI 0x03
  120. #define FRAD_P_PADDING 0x00
  121. #define FRAD_P_Q933 0x08
  122. #define FRAD_P_SNAP 0x80
  123. #define FRAD_P_CLNP 0x81
  124. #define FRAD_P_IP 0xCC
  125. struct dlci_local
  126. {
  127. struct net_device_stats stats;
  128. struct net_device *master;
  129. struct net_device *slave;
  130. struct dlci_conf config;
  131. int configured;
  132. struct list_head list;
  133. /* callback function */
  134. void (*receive)(struct sk_buff *skb, struct net_device *);
  135. };
  136. struct frad_local
  137. {
  138. struct net_device_stats stats;
  139. /* devices which this FRAD is slaved to */
  140. struct net_device *master[CONFIG_DLCI_MAX];
  141. short dlci[CONFIG_DLCI_MAX];
  142. struct frad_conf config;
  143. int configured; /* has this device been configured */
  144. int initialized; /* mem_start, port, irq set ? */
  145. /* callback functions */
  146. int (*activate)(struct net_device *, struct net_device *);
  147. int (*deactivate)(struct net_device *, struct net_device *);
  148. int (*assoc)(struct net_device *, struct net_device *);
  149. int (*deassoc)(struct net_device *, struct net_device *);
  150. int (*dlci_conf)(struct net_device *, struct net_device *, int get);
  151. /* fields that are used by the Sangoma SDLA cards */
  152. struct timer_list timer;
  153. int type; /* adapter type */
  154. int state; /* state of the S502/8 control latch */
  155. int buffer; /* current buffer for S508 firmware */
  156. };
  157. #endif /* __KERNEL__ */
  158. #endif /* CONFIG_DLCI || CONFIG_DLCI_MODULE */
  159. #ifdef __KERNEL__
  160. extern void dlci_ioctl_set(int (*hook)(unsigned int, void __user *));
  161. #endif
  162. #endif