eni.h 4.6 KB

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