if_frad.h 5.2 KB

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