1
2
3
4
5
6
7#ifndef DSL3510_H_
8#define DSL3510_H_
9
10#include <linux/mutex.h>
11#include <linux/workqueue.h>
12
13
14
15
16struct tb_nhi {
17 struct mutex lock;
18
19
20
21
22 struct pci_dev *pdev;
23 void __iomem *iobase;
24 struct tb_ring **tx_rings;
25 struct tb_ring **rx_rings;
26 struct work_struct interrupt_work;
27 u32 hop_count;
28};
29
30
31
32
33struct tb_ring {
34 struct mutex lock;
35 struct tb_nhi *nhi;
36 int size;
37 int hop;
38 int head;
39 int tail;
40 struct ring_desc *descriptors;
41 dma_addr_t descriptors_dma;
42 struct list_head queue;
43 struct list_head in_flight;
44 struct work_struct work;
45 bool is_tx:1;
46 bool running:1;
47};
48
49struct ring_frame;
50typedef void (*ring_cb)(struct tb_ring*, struct ring_frame*, bool canceled);
51
52
53
54
55struct ring_frame {
56 dma_addr_t buffer_phy;
57 ring_cb callback;
58 struct list_head list;
59 u32 size:12;
60 u32 flags:12;
61 u32 eof:4;
62 u32 sof:4;
63};
64
65#define TB_FRAME_SIZE 0x100
66
67struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size);
68struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size);
69void ring_start(struct tb_ring *ring);
70void ring_stop(struct tb_ring *ring);
71void ring_free(struct tb_ring *ring);
72
73int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame);
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89static inline int ring_rx(struct tb_ring *ring, struct ring_frame *frame)
90{
91 WARN_ON(ring->is_tx);
92 return __ring_enqueue(ring, frame);
93}
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108static inline int ring_tx(struct tb_ring *ring, struct ring_frame *frame)
109{
110 WARN_ON(!ring->is_tx);
111 return __ring_enqueue(ring, frame);
112}
113
114#endif
115