This source file includes following definitions.
- octnet_iq_is_full
- octnet_prepare_pci_cmd_o2
- octnet_prepare_pci_cmd_o3
- octnet_prepare_pci_cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #ifndef __OCTEON_NIC_H__
26 #define __OCTEON_NIC_H__
27
28
29
30 #define MAX_NCTRL_UDD 32
31
32 typedef void (*octnic_ctrl_pkt_cb_fn_t) (void *);
33
34
35
36
37 struct octnic_ctrl_pkt {
38
39 union octnet_cmd ncmd;
40
41
42 void *data;
43 u64 dmadata;
44
45
46 void *rdata;
47 u64 dmardata;
48
49
50 u64 udd[MAX_NCTRL_UDD];
51
52
53 u64 iq_no;
54
55
56 u64 netpndev;
57
58
59 octnic_ctrl_pkt_cb_fn_t cb_fn;
60
61 u32 sc_status;
62 };
63
64 #define MAX_UDD_SIZE(nctrl) (sizeof((nctrl)->udd))
65
66
67
68
69 struct octnic_data_pkt {
70
71
72
73 void *buf;
74
75
76 u32 reqtype;
77
78
79 u32 datasize;
80
81
82 union octeon_instr_64B cmd;
83
84
85 u32 q_no;
86
87 };
88
89
90
91
92 union octnic_cmd_setup {
93 struct {
94 u32 iq_no:8;
95 u32 gather:1;
96 u32 timestamp:1;
97 u32 ip_csum:1;
98 u32 transport_csum:1;
99 u32 tnl_csum:1;
100 u32 rsvd:19;
101
102 union {
103 u32 datasize;
104 u32 gatherptrs;
105 } u;
106 } s;
107
108 u64 u64;
109
110 };
111
112 static inline int octnet_iq_is_full(struct octeon_device *oct, u32 q_no)
113 {
114 return ((u32)atomic_read(&oct->instr_queue[q_no]->instr_pending)
115 >= (oct->instr_queue[q_no]->max_count - 2));
116 }
117
118 static inline void
119 octnet_prepare_pci_cmd_o2(struct octeon_device *oct,
120 union octeon_instr_64B *cmd,
121 union octnic_cmd_setup *setup, u32 tag)
122 {
123 struct octeon_instr_ih2 *ih2;
124 struct octeon_instr_irh *irh;
125 union octnic_packet_params packet_params;
126 int port;
127
128 memset(cmd, 0, sizeof(union octeon_instr_64B));
129
130 ih2 = (struct octeon_instr_ih2 *)&cmd->cmd2.ih2;
131
132
133
134
135 ih2->fsz = LIO_PCICMD_O2;
136
137 ih2->tagtype = ORDERED_TAG;
138 ih2->grp = DEFAULT_POW_GRP;
139
140 port = (int)oct->instr_queue[setup->s.iq_no]->txpciq.s.port;
141
142 if (tag)
143 ih2->tag = tag;
144 else
145 ih2->tag = LIO_DATA(port);
146
147 ih2->raw = 1;
148 ih2->qos = (port & 3) + 4;
149
150 if (!setup->s.gather) {
151 ih2->dlengsz = setup->s.u.datasize;
152 } else {
153 ih2->gather = 1;
154 ih2->dlengsz = setup->s.u.gatherptrs;
155 }
156
157 irh = (struct octeon_instr_irh *)&cmd->cmd2.irh;
158
159 irh->opcode = OPCODE_NIC;
160 irh->subcode = OPCODE_NIC_NW_DATA;
161
162 packet_params.u32 = 0;
163
164 packet_params.s.ip_csum = setup->s.ip_csum;
165 packet_params.s.transport_csum = setup->s.transport_csum;
166 packet_params.s.tnl_csum = setup->s.tnl_csum;
167 packet_params.s.tsflag = setup->s.timestamp;
168
169 irh->ossp = packet_params.u32;
170 }
171
172 static inline void
173 octnet_prepare_pci_cmd_o3(struct octeon_device *oct,
174 union octeon_instr_64B *cmd,
175 union octnic_cmd_setup *setup, u32 tag)
176 {
177 struct octeon_instr_irh *irh;
178 struct octeon_instr_ih3 *ih3;
179 struct octeon_instr_pki_ih3 *pki_ih3;
180 union octnic_packet_params packet_params;
181 int port;
182
183 memset(cmd, 0, sizeof(union octeon_instr_64B));
184
185 ih3 = (struct octeon_instr_ih3 *)&cmd->cmd3.ih3;
186 pki_ih3 = (struct octeon_instr_pki_ih3 *)&cmd->cmd3.pki_ih3;
187
188
189
190
191 ih3->pkind = oct->instr_queue[setup->s.iq_no]->txpciq.s.pkind;
192
193 ih3->fsz = LIO_PCICMD_O3;
194
195 if (!setup->s.gather) {
196 ih3->dlengsz = setup->s.u.datasize;
197 } else {
198 ih3->gather = 1;
199 ih3->dlengsz = setup->s.u.gatherptrs;
200 }
201
202 pki_ih3->w = 1;
203 pki_ih3->raw = 1;
204 pki_ih3->utag = 1;
205 pki_ih3->utt = 1;
206 pki_ih3->uqpg = oct->instr_queue[setup->s.iq_no]->txpciq.s.use_qpg;
207
208 port = (int)oct->instr_queue[setup->s.iq_no]->txpciq.s.port;
209
210 if (tag)
211 pki_ih3->tag = tag;
212 else
213 pki_ih3->tag = LIO_DATA(port);
214
215 pki_ih3->tagtype = ORDERED_TAG;
216 pki_ih3->qpg = oct->instr_queue[setup->s.iq_no]->txpciq.s.qpg;
217 pki_ih3->pm = 0x7;
218 pki_ih3->sl = 8;
219
220 irh = (struct octeon_instr_irh *)&cmd->cmd3.irh;
221
222 irh->opcode = OPCODE_NIC;
223 irh->subcode = OPCODE_NIC_NW_DATA;
224
225 packet_params.u32 = 0;
226
227 packet_params.s.ip_csum = setup->s.ip_csum;
228 packet_params.s.transport_csum = setup->s.transport_csum;
229 packet_params.s.tnl_csum = setup->s.tnl_csum;
230 packet_params.s.tsflag = setup->s.timestamp;
231
232 irh->ossp = packet_params.u32;
233 }
234
235
236
237
238
239
240
241
242 static inline void
243 octnet_prepare_pci_cmd(struct octeon_device *oct, union octeon_instr_64B *cmd,
244 union octnic_cmd_setup *setup, u32 tag)
245 {
246 if (OCTEON_CN6XXX(oct))
247 octnet_prepare_pci_cmd_o2(oct, cmd, setup, tag);
248 else
249 octnet_prepare_pci_cmd_o3(oct, cmd, setup, tag);
250 }
251
252
253
254
255
256
257
258
259
260
261
262 void *
263 octeon_alloc_soft_command_resp(struct octeon_device *oct,
264 union octeon_instr_64B *cmd,
265 u32 rdatasize);
266
267
268
269
270
271
272
273
274 int octnet_send_nic_data_pkt(struct octeon_device *oct,
275 struct octnic_data_pkt *ndata,
276 int xmit_more);
277
278
279
280
281
282
283
284 int
285 octnet_send_nic_ctrl_pkt(struct octeon_device *oct,
286 struct octnic_ctrl_pkt *nctrl);
287
288 #endif