if_frad.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. /* defines for the actual Frame Relay hardware */
  61. #define FRAD_GET_CONF (SIOCDEVPRIVATE)
  62. #define FRAD_SET_CONF (SIOCDEVPRIVATE + 1)
  63. #define FRAD_LAST_IOCTL FRAD_SET_CONF
  64. /*
  65. * Based on the setup for the Sangoma SDLA. If changes are
  66. * necessary to this structure, a routine will need to be
  67. * added to that module to copy fields.
  68. */
  69. struct frad_conf
  70. {
  71. short station;
  72. short flags;
  73. short kbaud;
  74. short clocking;
  75. short mtu;
  76. short T391;
  77. short T392;
  78. short N391;
  79. short N392;
  80. short N393;
  81. short CIR_fwd;
  82. short Bc_fwd;
  83. short Be_fwd;
  84. short CIR_bwd;
  85. short Bc_bwd;
  86. short Be_bwd;
  87. /* Add new fields here, above is a mirror of the sdla_conf */
  88. };
  89. #define FRAD_STATION_CPE 0x0000
  90. #define FRAD_STATION_NODE 0x0001
  91. #define FRAD_TX_IGNORE_CIR 0x0001
  92. #define FRAD_RX_ACCOUNT_CIR 0x0002
  93. #define FRAD_DROP_ABORTED 0x0004
  94. #define FRAD_BUFFERIF 0x0008
  95. #define FRAD_STATS 0x0010
  96. #define FRAD_MCI 0x0100
  97. #define FRAD_AUTODLCI 0x8000
  98. #define FRAD_VALID_FLAGS 0x811F
  99. #define FRAD_CLOCK_INT 0x0001
  100. #define FRAD_CLOCK_EXT 0x0000
  101. #ifdef __KERNEL__
  102. #if defined(CONFIG_DLCI) || defined(CONFIG_DLCI_MODULE)
  103. /* these are the fields of an RFC 1490 header */
  104. struct frhdr
  105. {
  106. unsigned char control;
  107. /* for IP packets, this can be the NLPID */
  108. unsigned char pad;
  109. unsigned char NLPID;
  110. unsigned char OUI[3];
  111. __be16 PID;
  112. #define IP_NLPID pad
  113. } __packed;
  114. /* see RFC 1490 for the definition of the following */
  115. #define FRAD_I_UI 0x03
  116. #define FRAD_P_PADDING 0x00
  117. #define FRAD_P_Q933 0x08
  118. #define FRAD_P_SNAP 0x80
  119. #define FRAD_P_CLNP 0x81
  120. #define FRAD_P_IP 0xCC
  121. struct dlci_local
  122. {
  123. struct net_device *master;
  124. struct net_device *slave;
  125. struct dlci_conf config;
  126. int configured;
  127. struct list_head list;
  128. /* callback function */
  129. void (*receive)(struct sk_buff *skb, struct net_device *);
  130. };
  131. struct frad_local
  132. {
  133. struct net_device_stats stats;
  134. /* devices which this FRAD is slaved to */
  135. struct net_device *master[CONFIG_DLCI_MAX];
  136. short dlci[CONFIG_DLCI_MAX];
  137. struct frad_conf config;
  138. int configured; /* has this device been configured */
  139. int initialized; /* mem_start, port, irq set ? */
  140. /* callback functions */
  141. int (*activate)(struct net_device *, struct net_device *);
  142. int (*deactivate)(struct net_device *, struct net_device *);
  143. int (*assoc)(struct net_device *, struct net_device *);
  144. int (*deassoc)(struct net_device *, struct net_device *);
  145. int (*dlci_conf)(struct net_device *, struct net_device *, int get);
  146. /* fields that are used by the Sangoma SDLA cards */
  147. struct timer_list timer;
  148. int type; /* adapter type */
  149. int state; /* state of the S502/8 control latch */
  150. int buffer; /* current buffer for S508 firmware */
  151. };
  152. #endif /* CONFIG_DLCI || CONFIG_DLCI_MODULE */
  153. extern void dlci_ioctl_set(int (*hook)(unsigned int, void __user *));
  154. #endif /* __KERNEL__ */
  155. #endif