zatm.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* drivers/atm/zatm.h - ZeitNet ZN122x device driver declarations */
  2. /* Written 1995-1998 by Werner Almesberger, EPFL LRC/ICA */
  3. #ifndef DRIVER_ATM_ZATM_H
  4. #define DRIVER_ATM_ZATM_H
  5. #include <linux/skbuff.h>
  6. #include <linux/atm.h>
  7. #include <linux/atmdev.h>
  8. #include <linux/sonet.h>
  9. #include <linux/pci.h>
  10. #define DEV_LABEL "zatm"
  11. #define MAX_AAL5_PDU 10240 /* allocate for AAL5 PDUs of this size */
  12. #define MAX_RX_SIZE_LD 14 /* ceil(log2((MAX_AAL5_PDU+47)/48)) */
  13. #define LOW_MARK 12 /* start adding new buffers if less than 12 */
  14. #define HIGH_MARK 30 /* stop adding buffers after reaching 30 */
  15. #define OFF_CNG_THRES 5 /* threshold for offset changes */
  16. #define RX_SIZE 2 /* RX lookup entry size (in bytes) */
  17. #define NR_POOLS 32 /* number of free buffer pointers */
  18. #define POOL_SIZE 8 /* buffer entry size (in bytes) */
  19. #define NR_SHAPERS 16 /* number of shapers */
  20. #define SHAPER_SIZE 4 /* shaper entry size (in bytes) */
  21. #define VC_SIZE 32 /* VC dsc (TX or RX) size (in bytes) */
  22. #define RING_ENTRIES 32 /* ring entries (without back pointer) */
  23. #define RING_WORDS 4 /* ring element size */
  24. #define RING_SIZE (sizeof(unsigned long)*(RING_ENTRIES+1)*RING_WORDS)
  25. #define NR_MBX 4 /* four mailboxes */
  26. #define MBX_RX_0 0 /* mailbox indices */
  27. #define MBX_RX_1 1
  28. #define MBX_TX_0 2
  29. #define MBX_TX_1 3
  30. struct zatm_vcc {
  31. /*-------------------------------- RX part */
  32. int rx_chan; /* RX channel, 0 if none */
  33. int pool; /* free buffer pool */
  34. /*-------------------------------- TX part */
  35. int tx_chan; /* TX channel, 0 if none */
  36. int shaper; /* shaper, <0 if none */
  37. struct sk_buff_head tx_queue; /* list of buffers in transit */
  38. wait_queue_head_t tx_wait; /* for close */
  39. u32 *ring; /* transmit ring */
  40. int ring_curr; /* current write position */
  41. int txing; /* number of transmits in progress */
  42. struct sk_buff_head backlog; /* list of buffers waiting for ring */
  43. };
  44. struct zatm_dev {
  45. /*-------------------------------- TX part */
  46. int tx_bw; /* remaining bandwidth */
  47. u32 free_shapers; /* bit set */
  48. int ubr; /* UBR shaper; -1 if none */
  49. int ubr_ref_cnt; /* number of VCs using UBR shaper */
  50. /*-------------------------------- RX part */
  51. int pool_ref[NR_POOLS]; /* free buffer pool usage counters */
  52. volatile struct sk_buff *last_free[NR_POOLS];
  53. /* last entry in respective pool */
  54. struct sk_buff_head pool[NR_POOLS];/* free buffer pools */
  55. struct zatm_pool_info pool_info[NR_POOLS]; /* pool information */
  56. /*-------------------------------- maps */
  57. struct atm_vcc **tx_map; /* TX VCCs */
  58. struct atm_vcc **rx_map; /* RX VCCs */
  59. int chans; /* map size, must be 2^n */
  60. /*-------------------------------- mailboxes */
  61. unsigned long mbx_start[NR_MBX];/* start addresses */
  62. dma_addr_t mbx_dma[NR_MBX];
  63. u16 mbx_end[NR_MBX]; /* end offset (in bytes) */
  64. /*-------------------------------- other pointers */
  65. u32 pool_base; /* Free buffer pool dsc (word addr) */
  66. /*-------------------------------- ZATM links */
  67. struct atm_dev *more; /* other ZATM devices */
  68. /*-------------------------------- general information */
  69. int mem; /* RAM on board (in bytes) */
  70. int khz; /* timer clock */
  71. int copper; /* PHY type */
  72. unsigned char irq; /* IRQ */
  73. unsigned int base; /* IO base address */
  74. struct pci_dev *pci_dev; /* PCI stuff */
  75. spinlock_t lock;
  76. };
  77. #define ZATM_DEV(d) ((struct zatm_dev *) (d)->dev_data)
  78. #define ZATM_VCC(d) ((struct zatm_vcc *) (d)->dev_data)
  79. struct zatm_skb_prv {
  80. struct atm_skb_data _; /* reserved */
  81. u32 *dsc; /* pointer to skb's descriptor */
  82. };
  83. #define ZATM_PRV_DSC(skb) (((struct zatm_skb_prv *) (skb)->cb)->dsc)
  84. #endif