if_frad.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. /* Structures and constants associated with the DLCI device driver */
  27. struct dlci_add
  28. {
  29. char devname[IFNAMSIZ];
  30. short dlci;
  31. };
  32. #define DLCI_GET_CONF (SIOCDEVPRIVATE + 2)
  33. #define DLCI_SET_CONF (SIOCDEVPRIVATE + 3)
  34. /*
  35. * These are related to the Sangoma SDLA and should remain in order.
  36. * Code within the SDLA module is based on the specifics of this
  37. * structure. Change at your own peril.
  38. */
  39. struct dlci_conf {
  40. short flags;
  41. short CIR_fwd;
  42. short Bc_fwd;
  43. short Be_fwd;
  44. short CIR_bwd;
  45. short Bc_bwd;
  46. short Be_bwd;
  47. /* these are part of the status read */
  48. short Tc_fwd;
  49. short Tc_bwd;
  50. short Tf_max;
  51. short Tb_max;
  52. /* add any new fields here above is a mirror of sdla_dlci_conf */
  53. };
  54. #define DLCI_GET_SLAVE (SIOCDEVPRIVATE + 4)
  55. /* configuration flags for DLCI */
  56. #define DLCI_IGNORE_CIR_OUT 0x0001
  57. #define DLCI_ACCOUNT_CIR_IN 0x0002
  58. #define DLCI_BUFFER_IF 0x0008
  59. #define DLCI_VALID_FLAGS 0x000B
  60. /* FRAD driver uses these to indicate what it did with packet */
  61. #define DLCI_RET_OK 0x00
  62. #define DLCI_RET_ERR 0x01
  63. #define DLCI_RET_DROP 0x02
  64. /* defines for the actual Frame Relay hardware */
  65. #define FRAD_GET_CONF (SIOCDEVPRIVATE)
  66. #define FRAD_SET_CONF (SIOCDEVPRIVATE + 1)
  67. #define FRAD_LAST_IOCTL FRAD_SET_CONF
  68. /*
  69. * Based on the setup for the Sangoma SDLA. If changes are
  70. * necessary to this structure, a routine will need to be
  71. * added to that module to copy fields.
  72. */
  73. struct frad_conf
  74. {
  75. short station;
  76. short flags;
  77. short kbaud;
  78. short clocking;
  79. short mtu;
  80. short T391;
  81. short T392;
  82. short N391;
  83. short N392;
  84. short N393;
  85. short CIR_fwd;
  86. short Bc_fwd;
  87. short Be_fwd;
  88. short CIR_bwd;
  89. short Bc_bwd;
  90. short Be_bwd;
  91. /* Add new fields here, above is a mirror of the sdla_conf */
  92. };
  93. #define FRAD_STATION_CPE 0x0000
  94. #define FRAD_STATION_NODE 0x0001
  95. #define FRAD_TX_IGNORE_CIR 0x0001
  96. #define FRAD_RX_ACCOUNT_CIR 0x0002
  97. #define FRAD_DROP_ABORTED 0x0004
  98. #define FRAD_BUFFERIF 0x0008
  99. #define FRAD_STATS 0x0010
  100. #define FRAD_MCI 0x0100
  101. #define FRAD_AUTODLCI 0x8000
  102. #define FRAD_VALID_FLAGS 0x811F
  103. #define FRAD_CLOCK_INT 0x0001
  104. #define FRAD_CLOCK_EXT 0x0000
  105. #ifdef __KERNEL__
  106. #if defined(CONFIG_DLCI) || defined(CONFIG_DLCI_MODULE)
  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. __be16 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 *master;
  128. struct net_device *slave;
  129. struct dlci_conf config;
  130. int configured;
  131. struct list_head list;
  132. /* callback function */
  133. void (*receive)(struct sk_buff *skb, struct net_device *);
  134. };
  135. struct frad_local
  136. {
  137. struct net_device_stats stats;
  138. /* devices which this FRAD is slaved to */
  139. struct net_device *master[CONFIG_DLCI_MAX];
  140. short dlci[CONFIG_DLCI_MAX];
  141. struct frad_conf config;
  142. int configured; /* has this device been configured */
  143. int initialized; /* mem_start, port, irq set ? */
  144. /* callback functions */
  145. int (*activate)(struct net_device *, struct net_device *);
  146. int (*deactivate)(struct net_device *, struct net_device *);
  147. int (*assoc)(struct net_device *, struct net_device *);
  148. int (*deassoc)(struct net_device *, struct net_device *);
  149. int (*dlci_conf)(struct net_device *, struct net_device *, int get);
  150. /* fields that are used by the Sangoma SDLA cards */
  151. struct timer_list timer;
  152. int type; /* adapter type */
  153. int state; /* state of the S502/8 control latch */
  154. int buffer; /* current buffer for S508 firmware */
  155. };
  156. #endif /* CONFIG_DLCI || CONFIG_DLCI_MODULE */
  157. extern void dlci_ioctl_set(int (*hook)(unsigned int, void __user *));
  158. #endif /* __KERNEL__ */
  159. #endif