eni.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* drivers/atm/eni.h - Efficient Networks ENI155P device driver declarations */
  2. /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
  3. #ifndef DRIVER_ATM_ENI_H
  4. #define DRIVER_ATM_ENI_H
  5. #include <linux/atm.h>
  6. #include <linux/atmdev.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/sonet.h>
  9. #include <linux/skbuff.h>
  10. #include <linux/time.h>
  11. #include <linux/pci.h>
  12. #include <linux/spinlock.h>
  13. #include <linux/atomic.h>
  14. #include "midway.h"
  15. #define DEV_LABEL "eni"
  16. #define UBR_BUFFER (128*1024) /* UBR buffer size */
  17. #define RX_DMA_BUF 8 /* burst and skip a few things */
  18. #define TX_DMA_BUF 100 /* should be enough for 64 kB */
  19. #define DEFAULT_RX_MULT 300 /* max_sdu*3 */
  20. #define DEFAULT_TX_MULT 300 /* max_sdu*3 */
  21. #define ENI_ZEROES_SIZE 4 /* need that many DMA-able zero bytes */
  22. struct eni_free {
  23. void __iomem *start; /* counting in bytes */
  24. int order;
  25. };
  26. struct eni_tx {
  27. void __iomem *send; /* base, 0 if unused */
  28. int prescaler; /* shaping prescaler */
  29. int resolution; /* shaping divider */
  30. unsigned long tx_pos; /* current TX write position */
  31. unsigned long words; /* size of TX queue */
  32. int index; /* TX channel number */
  33. int reserved; /* reserved peak cell rate */
  34. int shaping; /* shaped peak cell rate */
  35. struct sk_buff_head backlog; /* queue of waiting TX buffers */
  36. };
  37. struct eni_vcc {
  38. int (*rx)(struct atm_vcc *vcc); /* RX function, NULL if none */
  39. void __iomem *recv; /* receive buffer */
  40. unsigned long words; /* its size in words */
  41. unsigned long descr; /* next descriptor (RX) */
  42. unsigned long rx_pos; /* current RX descriptor pos */
  43. struct eni_tx *tx; /* TXer, NULL if none */
  44. int rxing; /* number of pending PDUs */
  45. int servicing; /* number of waiting VCs (0 or 1) */
  46. int txing; /* number of pending TX bytes */
  47. ktime_t timestamp; /* for RX timing */
  48. struct atm_vcc *next; /* next pending RX */
  49. struct sk_buff *last; /* last PDU being DMAed (used to carry
  50. discard information) */
  51. };
  52. struct eni_dev {
  53. /*-------------------------------- spinlock */
  54. spinlock_t lock; /* sync with interrupt */
  55. struct tasklet_struct task; /* tasklet for interrupt work */
  56. u32 events; /* pending events */
  57. /*-------------------------------- base pointers into Midway address
  58. space */
  59. void __iomem *ioaddr;
  60. void __iomem *phy; /* PHY interface chip registers */
  61. void __iomem *reg; /* register base */
  62. void __iomem *ram; /* RAM base */
  63. void __iomem *vci; /* VCI table */
  64. void __iomem *rx_dma; /* RX DMA queue */
  65. void __iomem *tx_dma; /* TX DMA queue */
  66. void __iomem *service; /* service list */
  67. /*-------------------------------- TX part */
  68. struct eni_tx tx[NR_CHAN]; /* TX channels */
  69. struct eni_tx *ubr; /* UBR channel */
  70. struct sk_buff_head tx_queue; /* PDUs currently being TX DMAed*/
  71. wait_queue_head_t tx_wait; /* for close */
  72. int tx_bw; /* remaining bandwidth */
  73. u32 dma[TX_DMA_BUF*2]; /* DMA request scratch area */
  74. struct eni_zero { /* aligned "magic" zeroes */
  75. u32 *addr;
  76. dma_addr_t dma;
  77. } zero;
  78. int tx_mult; /* buffer size multiplier (percent) */
  79. /*-------------------------------- RX part */
  80. u32 serv_read; /* host service read index */
  81. struct atm_vcc *fast,*last_fast;/* queues of VCCs with pending PDUs */
  82. struct atm_vcc *slow,*last_slow;
  83. struct atm_vcc **rx_map; /* for fast lookups */
  84. struct sk_buff_head rx_queue; /* PDUs currently being RX-DMAed */
  85. wait_queue_head_t rx_wait; /* for close */
  86. int rx_mult; /* buffer size multiplier (percent) */
  87. /*-------------------------------- statistics */
  88. unsigned long lost; /* number of lost cells (RX) */
  89. /*-------------------------------- memory management */
  90. unsigned long base_diff; /* virtual-real base address */
  91. int free_len; /* free list length */
  92. struct eni_free *free_list; /* free list */
  93. int free_list_size; /* maximum size of free list */
  94. /*-------------------------------- ENI links */
  95. struct atm_dev *more; /* other ENI devices */
  96. /*-------------------------------- general information */
  97. int mem; /* RAM on board (in bytes) */
  98. int asic; /* PCI interface type, 0 for FPGA */
  99. unsigned int irq; /* IRQ */
  100. struct pci_dev *pci_dev; /* PCI stuff */
  101. };
  102. #define ENI_DEV(d) ((struct eni_dev *) (d)->dev_data)
  103. #define ENI_VCC(d) ((struct eni_vcc *) (d)->dev_data)
  104. struct eni_skb_prv {
  105. struct atm_skb_data _; /* reserved */
  106. unsigned long pos; /* position of next descriptor */
  107. int size; /* PDU size in reassembly buffer */
  108. dma_addr_t paddr; /* DMA handle */
  109. };
  110. #define ENI_PRV_SIZE(skb) (((struct eni_skb_prv *) (skb)->cb)->size)
  111. #define ENI_PRV_POS(skb) (((struct eni_skb_prv *) (skb)->cb)->pos)
  112. #define ENI_PRV_PADDR(skb) (((struct eni_skb_prv *) (skb)->cb)->paddr)
  113. #endif