]>
Commit | Line | Data |
---|---|---|
02e9c290 JB |
1 | /******************************************************************************* |
2 | * | |
3 | * Intel Ethernet Controller XL710 Family Linux Driver | |
13cb3e9d | 4 | * Copyright(c) 2013 - 2016 Intel Corporation. |
02e9c290 JB |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms and conditions of the GNU General Public License, | |
8 | * version 2, as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope it will be useful, but WITHOUT | |
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | * more details. | |
14 | * | |
dc641b73 GR |
15 | * You should have received a copy of the GNU General Public License along |
16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | |
02e9c290 JB |
17 | * |
18 | * The full GNU General Public License is included in this distribution in | |
19 | * the file called "COPYING". | |
20 | * | |
21 | * Contact Information: | |
22 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | |
23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
24 | * | |
25 | ******************************************************************************/ | |
26 | ||
27 | #ifdef CONFIG_DEBUG_FS | |
28 | ||
29 | #include <linux/fs.h> | |
30 | #include <linux/debugfs.h> | |
31 | ||
32 | #include "i40e.h" | |
33 | ||
34 | static struct dentry *i40e_dbg_root; | |
35 | ||
36 | /** | |
37 | * i40e_dbg_find_vsi - searches for the vsi with the given seid | |
b40c82e6 | 38 | * @pf - the PF structure to search for the vsi |
02e9c290 JB |
39 | * @seid - seid of the vsi it is searching for |
40 | **/ | |
41 | static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid) | |
42 | { | |
43 | int i; | |
44 | ||
45 | if (seid < 0) | |
46 | dev_info(&pf->pdev->dev, "%d: bad seid\n", seid); | |
47 | else | |
505682cd | 48 | for (i = 0; i < pf->num_alloc_vsi; i++) |
02e9c290 JB |
49 | if (pf->vsi[i] && (pf->vsi[i]->seid == seid)) |
50 | return pf->vsi[i]; | |
51 | ||
52 | return NULL; | |
53 | } | |
54 | ||
55 | /** | |
56 | * i40e_dbg_find_veb - searches for the veb with the given seid | |
b40c82e6 | 57 | * @pf - the PF structure to search for the veb |
02e9c290 JB |
58 | * @seid - seid of the veb it is searching for |
59 | **/ | |
60 | static struct i40e_veb *i40e_dbg_find_veb(struct i40e_pf *pf, int seid) | |
61 | { | |
62 | int i; | |
63 | ||
4147e2c5 KP |
64 | for (i = 0; i < I40E_MAX_VEB; i++) |
65 | if (pf->veb[i] && pf->veb[i]->seid == seid) | |
66 | return pf->veb[i]; | |
02e9c290 JB |
67 | return NULL; |
68 | } | |
69 | ||
02e9c290 JB |
70 | /************************************************************** |
71 | * command | |
72 | * The command entry in debugfs is for giving the driver commands | |
73 | * to be executed - these may be for changing the internal switch | |
74 | * setup, adding or removing filters, or other things. Many of | |
75 | * these will be useful for some forms of unit testing. | |
76 | **************************************************************/ | |
d1da3ac0 | 77 | static char i40e_dbg_command_buf[256] = ""; |
02e9c290 JB |
78 | |
79 | /** | |
80 | * i40e_dbg_command_read - read for command datum | |
81 | * @filp: the opened file | |
82 | * @buffer: where to write the data for the user to read | |
83 | * @count: the size of the user's buffer | |
84 | * @ppos: file position offset | |
85 | **/ | |
86 | static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer, | |
87 | size_t count, loff_t *ppos) | |
88 | { | |
89 | struct i40e_pf *pf = filp->private_data; | |
90 | int bytes_not_copied; | |
91 | int buf_size = 256; | |
92 | char *buf; | |
93 | int len; | |
94 | ||
95 | /* don't allow partial reads */ | |
96 | if (*ppos != 0) | |
97 | return 0; | |
98 | if (count < buf_size) | |
99 | return -ENOSPC; | |
100 | ||
101 | buf = kzalloc(buf_size, GFP_KERNEL); | |
102 | if (!buf) | |
103 | return -ENOSPC; | |
104 | ||
105 | len = snprintf(buf, buf_size, "%s: %s\n", | |
106 | pf->vsi[pf->lan_vsi]->netdev->name, | |
107 | i40e_dbg_command_buf); | |
108 | ||
109 | bytes_not_copied = copy_to_user(buffer, buf, len); | |
110 | kfree(buf); | |
111 | ||
0286c67e RV |
112 | if (bytes_not_copied) |
113 | return -EFAULT; | |
02e9c290 JB |
114 | |
115 | *ppos = len; | |
116 | return len; | |
117 | } | |
118 | ||
119 | /** | |
e625f71b | 120 | * i40e_dbg_dump_vsi_seid - handles dump vsi seid write into command datum |
02e9c290 JB |
121 | * @pf: the i40e_pf created in command write |
122 | * @seid: the seid the user put in | |
123 | **/ | |
124 | static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid) | |
125 | { | |
126 | struct rtnl_link_stats64 *nstat; | |
127 | struct i40e_mac_filter *f; | |
128 | struct i40e_vsi *vsi; | |
129 | int i; | |
130 | ||
131 | vsi = i40e_dbg_find_vsi(pf, seid); | |
132 | if (!vsi) { | |
133 | dev_info(&pf->pdev->dev, | |
134 | "dump %d: seid not found\n", seid); | |
135 | return; | |
136 | } | |
137 | dev_info(&pf->pdev->dev, "vsi seid %d\n", seid); | |
de1017f7 SN |
138 | if (vsi->netdev) { |
139 | struct net_device *nd = vsi->netdev; | |
140 | ||
141 | dev_info(&pf->pdev->dev, " netdev: name = %s, state = %lu, flags = 0x%08x\n", | |
142 | nd->name, nd->state, nd->flags); | |
143 | dev_info(&pf->pdev->dev, " features = 0x%08lx\n", | |
144 | (unsigned long int)nd->features); | |
145 | dev_info(&pf->pdev->dev, " hw_features = 0x%08lx\n", | |
146 | (unsigned long int)nd->hw_features); | |
147 | dev_info(&pf->pdev->dev, " vlan_features = 0x%08lx\n", | |
148 | (unsigned long int)nd->vlan_features); | |
149 | } | |
afb8ece4 CK |
150 | dev_info(&pf->pdev->dev, |
151 | " vlgrp: & = %p\n", vsi->active_vlans); | |
02e9c290 | 152 | dev_info(&pf->pdev->dev, |
de1017f7 SN |
153 | " state = %li flags = 0x%08lx, netdev_registered = %i, current_netdev_flags = 0x%04x\n", |
154 | vsi->state, vsi->flags, | |
155 | vsi->netdev_registered, vsi->current_netdev_flags); | |
2ddb80c9 | 156 | if (vsi == pf->vsi[pf->lan_vsi]) |
de1017f7 | 157 | dev_info(&pf->pdev->dev, " MAC address: %pM SAN MAC: %pM Port MAC: %pM\n", |
2ddb80c9 SN |
158 | pf->hw.mac.addr, |
159 | pf->hw.mac.san_addr, | |
160 | pf->hw.mac.port_addr); | |
02e9c290 JB |
161 | list_for_each_entry(f, &vsi->mac_filter_list, list) { |
162 | dev_info(&pf->pdev->dev, | |
163 | " mac_filter_list: %pM vid=%d, is_netdev=%d is_vf=%d counter=%d\n", | |
164 | f->macaddr, f->vlan, f->is_netdev, f->is_vf, | |
165 | f->counter); | |
166 | } | |
167 | nstat = i40e_get_vsi_stats_struct(vsi); | |
168 | dev_info(&pf->pdev->dev, | |
169 | " net_stats: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n", | |
6995b36c JB |
170 | (unsigned long int)nstat->rx_packets, |
171 | (unsigned long int)nstat->rx_bytes, | |
172 | (unsigned long int)nstat->rx_errors, | |
173 | (unsigned long int)nstat->rx_dropped); | |
02e9c290 JB |
174 | dev_info(&pf->pdev->dev, |
175 | " net_stats: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n", | |
6995b36c JB |
176 | (unsigned long int)nstat->tx_packets, |
177 | (unsigned long int)nstat->tx_bytes, | |
178 | (unsigned long int)nstat->tx_errors, | |
179 | (unsigned long int)nstat->tx_dropped); | |
02e9c290 JB |
180 | dev_info(&pf->pdev->dev, |
181 | " net_stats: multicast = %lu, collisions = %lu\n", | |
6995b36c JB |
182 | (unsigned long int)nstat->multicast, |
183 | (unsigned long int)nstat->collisions); | |
02e9c290 JB |
184 | dev_info(&pf->pdev->dev, |
185 | " net_stats: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n", | |
6995b36c JB |
186 | (unsigned long int)nstat->rx_length_errors, |
187 | (unsigned long int)nstat->rx_over_errors, | |
188 | (unsigned long int)nstat->rx_crc_errors); | |
02e9c290 JB |
189 | dev_info(&pf->pdev->dev, |
190 | " net_stats: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n", | |
6995b36c JB |
191 | (unsigned long int)nstat->rx_frame_errors, |
192 | (unsigned long int)nstat->rx_fifo_errors, | |
193 | (unsigned long int)nstat->rx_missed_errors); | |
02e9c290 JB |
194 | dev_info(&pf->pdev->dev, |
195 | " net_stats: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n", | |
6995b36c JB |
196 | (unsigned long int)nstat->tx_aborted_errors, |
197 | (unsigned long int)nstat->tx_carrier_errors, | |
198 | (unsigned long int)nstat->tx_fifo_errors); | |
02e9c290 JB |
199 | dev_info(&pf->pdev->dev, |
200 | " net_stats: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n", | |
6995b36c JB |
201 | (unsigned long int)nstat->tx_heartbeat_errors, |
202 | (unsigned long int)nstat->tx_window_errors); | |
02e9c290 JB |
203 | dev_info(&pf->pdev->dev, |
204 | " net_stats: rx_compressed = %lu, tx_compressed = %lu\n", | |
6995b36c JB |
205 | (unsigned long int)nstat->rx_compressed, |
206 | (unsigned long int)nstat->tx_compressed); | |
02e9c290 JB |
207 | dev_info(&pf->pdev->dev, |
208 | " net_stats_offsets: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n", | |
6995b36c JB |
209 | (unsigned long int)vsi->net_stats_offsets.rx_packets, |
210 | (unsigned long int)vsi->net_stats_offsets.rx_bytes, | |
211 | (unsigned long int)vsi->net_stats_offsets.rx_errors, | |
212 | (unsigned long int)vsi->net_stats_offsets.rx_dropped); | |
02e9c290 JB |
213 | dev_info(&pf->pdev->dev, |
214 | " net_stats_offsets: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n", | |
6995b36c JB |
215 | (unsigned long int)vsi->net_stats_offsets.tx_packets, |
216 | (unsigned long int)vsi->net_stats_offsets.tx_bytes, | |
217 | (unsigned long int)vsi->net_stats_offsets.tx_errors, | |
218 | (unsigned long int)vsi->net_stats_offsets.tx_dropped); | |
02e9c290 JB |
219 | dev_info(&pf->pdev->dev, |
220 | " net_stats_offsets: multicast = %lu, collisions = %lu\n", | |
6995b36c JB |
221 | (unsigned long int)vsi->net_stats_offsets.multicast, |
222 | (unsigned long int)vsi->net_stats_offsets.collisions); | |
02e9c290 JB |
223 | dev_info(&pf->pdev->dev, |
224 | " net_stats_offsets: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n", | |
6995b36c JB |
225 | (unsigned long int)vsi->net_stats_offsets.rx_length_errors, |
226 | (unsigned long int)vsi->net_stats_offsets.rx_over_errors, | |
227 | (unsigned long int)vsi->net_stats_offsets.rx_crc_errors); | |
02e9c290 JB |
228 | dev_info(&pf->pdev->dev, |
229 | " net_stats_offsets: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n", | |
6995b36c JB |
230 | (unsigned long int)vsi->net_stats_offsets.rx_frame_errors, |
231 | (unsigned long int)vsi->net_stats_offsets.rx_fifo_errors, | |
232 | (unsigned long int)vsi->net_stats_offsets.rx_missed_errors); | |
02e9c290 JB |
233 | dev_info(&pf->pdev->dev, |
234 | " net_stats_offsets: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n", | |
6995b36c JB |
235 | (unsigned long int)vsi->net_stats_offsets.tx_aborted_errors, |
236 | (unsigned long int)vsi->net_stats_offsets.tx_carrier_errors, | |
237 | (unsigned long int)vsi->net_stats_offsets.tx_fifo_errors); | |
02e9c290 JB |
238 | dev_info(&pf->pdev->dev, |
239 | " net_stats_offsets: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n", | |
6995b36c JB |
240 | (unsigned long int)vsi->net_stats_offsets.tx_heartbeat_errors, |
241 | (unsigned long int)vsi->net_stats_offsets.tx_window_errors); | |
02e9c290 JB |
242 | dev_info(&pf->pdev->dev, |
243 | " net_stats_offsets: rx_compressed = %lu, tx_compressed = %lu\n", | |
6995b36c JB |
244 | (unsigned long int)vsi->net_stats_offsets.rx_compressed, |
245 | (unsigned long int)vsi->net_stats_offsets.tx_compressed); | |
02e9c290 JB |
246 | dev_info(&pf->pdev->dev, |
247 | " tx_restart = %d, tx_busy = %d, rx_buf_failed = %d, rx_page_failed = %d\n", | |
248 | vsi->tx_restart, vsi->tx_busy, | |
249 | vsi->rx_buf_failed, vsi->rx_page_failed); | |
9f65e15b AD |
250 | rcu_read_lock(); |
251 | for (i = 0; i < vsi->num_queue_pairs; i++) { | |
252 | struct i40e_ring *rx_ring = ACCESS_ONCE(vsi->rx_rings[i]); | |
6995b36c | 253 | |
9f65e15b AD |
254 | if (!rx_ring) |
255 | continue; | |
256 | ||
257 | dev_info(&pf->pdev->dev, | |
258 | " rx_rings[%i]: desc = %p\n", | |
259 | i, rx_ring->desc); | |
260 | dev_info(&pf->pdev->dev, | |
261 | " rx_rings[%i]: dev = %p, netdev = %p, rx_bi = %p\n", | |
262 | i, rx_ring->dev, | |
263 | rx_ring->netdev, | |
264 | rx_ring->rx_bi); | |
265 | dev_info(&pf->pdev->dev, | |
266 | " rx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n", | |
267 | i, rx_ring->state, | |
268 | rx_ring->queue_index, | |
269 | rx_ring->reg_idx); | |
270 | dev_info(&pf->pdev->dev, | |
1a557afc JB |
271 | " rx_rings[%i]: rx_buf_len = %d\n", |
272 | i, rx_ring->rx_buf_len); | |
9f65e15b | 273 | dev_info(&pf->pdev->dev, |
b32bfa17 JB |
274 | " rx_rings[%i]: next_to_use = %d, next_to_clean = %d, ring_active = %i\n", |
275 | i, | |
9f65e15b AD |
276 | rx_ring->next_to_use, |
277 | rx_ring->next_to_clean, | |
278 | rx_ring->ring_active); | |
279 | dev_info(&pf->pdev->dev, | |
280 | " rx_rings[%i]: rx_stats: packets = %lld, bytes = %lld, non_eop_descs = %lld\n", | |
281 | i, rx_ring->stats.packets, | |
282 | rx_ring->stats.bytes, | |
283 | rx_ring->rx_stats.non_eop_descs); | |
284 | dev_info(&pf->pdev->dev, | |
420136cc | 285 | " rx_rings[%i]: rx_stats: alloc_page_failed = %lld, alloc_buff_failed = %lld\n", |
9f65e15b | 286 | i, |
420136cc MW |
287 | rx_ring->rx_stats.alloc_page_failed, |
288 | rx_ring->rx_stats.alloc_buff_failed); | |
f16704e5 MW |
289 | dev_info(&pf->pdev->dev, |
290 | " rx_rings[%i]: rx_stats: realloc_count = %lld, page_reuse_count = %lld\n", | |
291 | i, | |
292 | rx_ring->rx_stats.realloc_count, | |
293 | rx_ring->rx_stats.page_reuse_count); | |
9f65e15b AD |
294 | dev_info(&pf->pdev->dev, |
295 | " rx_rings[%i]: size = %i, dma = 0x%08lx\n", | |
296 | i, rx_ring->size, | |
6995b36c | 297 | (unsigned long int)rx_ring->dma); |
9f65e15b AD |
298 | dev_info(&pf->pdev->dev, |
299 | " rx_rings[%i]: vsi = %p, q_vector = %p\n", | |
300 | i, rx_ring->vsi, | |
301 | rx_ring->q_vector); | |
a75e8005 KL |
302 | dev_info(&pf->pdev->dev, |
303 | " rx_rings[%i]: rx_itr_setting = %d (%s)\n", | |
304 | i, rx_ring->rx_itr_setting, | |
305 | ITR_IS_DYNAMIC(rx_ring->rx_itr_setting) ? "dynamic" : "fixed"); | |
02e9c290 | 306 | } |
9f65e15b AD |
307 | for (i = 0; i < vsi->num_queue_pairs; i++) { |
308 | struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[i]); | |
6995b36c | 309 | |
9f65e15b AD |
310 | if (!tx_ring) |
311 | continue; | |
1b60f3c4 | 312 | |
9f65e15b AD |
313 | dev_info(&pf->pdev->dev, |
314 | " tx_rings[%i]: desc = %p\n", | |
315 | i, tx_ring->desc); | |
316 | dev_info(&pf->pdev->dev, | |
317 | " tx_rings[%i]: dev = %p, netdev = %p, tx_bi = %p\n", | |
318 | i, tx_ring->dev, | |
319 | tx_ring->netdev, | |
320 | tx_ring->tx_bi); | |
321 | dev_info(&pf->pdev->dev, | |
322 | " tx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n", | |
323 | i, tx_ring->state, | |
324 | tx_ring->queue_index, | |
325 | tx_ring->reg_idx); | |
9f65e15b | 326 | dev_info(&pf->pdev->dev, |
4668607a MW |
327 | " tx_rings[%i]: next_to_use = %d, next_to_clean = %d, ring_active = %i\n", |
328 | i, | |
9f65e15b AD |
329 | tx_ring->next_to_use, |
330 | tx_ring->next_to_clean, | |
331 | tx_ring->ring_active); | |
332 | dev_info(&pf->pdev->dev, | |
333 | " tx_rings[%i]: tx_stats: packets = %lld, bytes = %lld, restart_queue = %lld\n", | |
334 | i, tx_ring->stats.packets, | |
335 | tx_ring->stats.bytes, | |
336 | tx_ring->tx_stats.restart_queue); | |
337 | dev_info(&pf->pdev->dev, | |
338 | " tx_rings[%i]: tx_stats: tx_busy = %lld, tx_done_old = %lld\n", | |
339 | i, | |
340 | tx_ring->tx_stats.tx_busy, | |
341 | tx_ring->tx_stats.tx_done_old); | |
342 | dev_info(&pf->pdev->dev, | |
343 | " tx_rings[%i]: size = %i, dma = 0x%08lx\n", | |
344 | i, tx_ring->size, | |
6995b36c | 345 | (unsigned long int)tx_ring->dma); |
9f65e15b AD |
346 | dev_info(&pf->pdev->dev, |
347 | " tx_rings[%i]: vsi = %p, q_vector = %p\n", | |
348 | i, tx_ring->vsi, | |
349 | tx_ring->q_vector); | |
350 | dev_info(&pf->pdev->dev, | |
351 | " tx_rings[%i]: DCB tc = %d\n", | |
352 | i, tx_ring->dcb_tc); | |
a75e8005 KL |
353 | dev_info(&pf->pdev->dev, |
354 | " tx_rings[%i]: tx_itr_setting = %d (%s)\n", | |
355 | i, tx_ring->tx_itr_setting, | |
356 | ITR_IS_DYNAMIC(tx_ring->tx_itr_setting) ? "dynamic" : "fixed"); | |
02e9c290 | 357 | } |
9f65e15b | 358 | rcu_read_unlock(); |
02e9c290 | 359 | dev_info(&pf->pdev->dev, |
a75e8005 KL |
360 | " work_limit = %d\n", |
361 | vsi->work_limit); | |
02e9c290 | 362 | dev_info(&pf->pdev->dev, |
1a557afc JB |
363 | " max_frame = %d, rx_buf_len = %d dtype = %d\n", |
364 | vsi->max_frame, vsi->rx_buf_len, vsi->dtype); | |
02e9c290 JB |
365 | dev_info(&pf->pdev->dev, |
366 | " num_q_vectors = %i, base_vector = %i\n", | |
367 | vsi->num_q_vectors, vsi->base_vector); | |
368 | dev_info(&pf->pdev->dev, | |
369 | " seid = %d, id = %d, uplink_seid = %d\n", | |
370 | vsi->seid, vsi->id, vsi->uplink_seid); | |
371 | dev_info(&pf->pdev->dev, | |
372 | " base_queue = %d, num_queue_pairs = %d, num_desc = %d\n", | |
373 | vsi->base_queue, vsi->num_queue_pairs, vsi->num_desc); | |
374 | dev_info(&pf->pdev->dev, " type = %i\n", vsi->type); | |
375 | dev_info(&pf->pdev->dev, | |
376 | " info: valid_sections = 0x%04x, switch_id = 0x%04x\n", | |
377 | vsi->info.valid_sections, vsi->info.switch_id); | |
378 | dev_info(&pf->pdev->dev, | |
379 | " info: sw_reserved[] = 0x%02x 0x%02x\n", | |
380 | vsi->info.sw_reserved[0], vsi->info.sw_reserved[1]); | |
381 | dev_info(&pf->pdev->dev, | |
382 | " info: sec_flags = 0x%02x, sec_reserved = 0x%02x\n", | |
383 | vsi->info.sec_flags, vsi->info.sec_reserved); | |
384 | dev_info(&pf->pdev->dev, | |
385 | " info: pvid = 0x%04x, fcoe_pvid = 0x%04x, port_vlan_flags = 0x%02x\n", | |
386 | vsi->info.pvid, vsi->info.fcoe_pvid, | |
387 | vsi->info.port_vlan_flags); | |
388 | dev_info(&pf->pdev->dev, | |
389 | " info: pvlan_reserved[] = 0x%02x 0x%02x 0x%02x\n", | |
390 | vsi->info.pvlan_reserved[0], vsi->info.pvlan_reserved[1], | |
391 | vsi->info.pvlan_reserved[2]); | |
392 | dev_info(&pf->pdev->dev, | |
393 | " info: ingress_table = 0x%08x, egress_table = 0x%08x\n", | |
394 | vsi->info.ingress_table, vsi->info.egress_table); | |
395 | dev_info(&pf->pdev->dev, | |
396 | " info: cas_pv_stag = 0x%04x, cas_pv_flags= 0x%02x, cas_pv_reserved = 0x%02x\n", | |
397 | vsi->info.cas_pv_tag, vsi->info.cas_pv_flags, | |
398 | vsi->info.cas_pv_reserved); | |
399 | dev_info(&pf->pdev->dev, | |
400 | " info: queue_mapping[0..7 ] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n", | |
401 | vsi->info.queue_mapping[0], vsi->info.queue_mapping[1], | |
402 | vsi->info.queue_mapping[2], vsi->info.queue_mapping[3], | |
403 | vsi->info.queue_mapping[4], vsi->info.queue_mapping[5], | |
404 | vsi->info.queue_mapping[6], vsi->info.queue_mapping[7]); | |
405 | dev_info(&pf->pdev->dev, | |
406 | " info: queue_mapping[8..15] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n", | |
407 | vsi->info.queue_mapping[8], vsi->info.queue_mapping[9], | |
408 | vsi->info.queue_mapping[10], vsi->info.queue_mapping[11], | |
409 | vsi->info.queue_mapping[12], vsi->info.queue_mapping[13], | |
410 | vsi->info.queue_mapping[14], vsi->info.queue_mapping[15]); | |
411 | dev_info(&pf->pdev->dev, | |
412 | " info: tc_mapping[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n", | |
413 | vsi->info.tc_mapping[0], vsi->info.tc_mapping[1], | |
414 | vsi->info.tc_mapping[2], vsi->info.tc_mapping[3], | |
415 | vsi->info.tc_mapping[4], vsi->info.tc_mapping[5], | |
416 | vsi->info.tc_mapping[6], vsi->info.tc_mapping[7]); | |
417 | dev_info(&pf->pdev->dev, | |
418 | " info: queueing_opt_flags = 0x%02x queueing_opt_reserved[0..2] = 0x%02x 0x%02x 0x%02x\n", | |
419 | vsi->info.queueing_opt_flags, | |
420 | vsi->info.queueing_opt_reserved[0], | |
421 | vsi->info.queueing_opt_reserved[1], | |
422 | vsi->info.queueing_opt_reserved[2]); | |
423 | dev_info(&pf->pdev->dev, | |
424 | " info: up_enable_bits = 0x%02x\n", | |
425 | vsi->info.up_enable_bits); | |
426 | dev_info(&pf->pdev->dev, | |
427 | " info: sched_reserved = 0x%02x, outer_up_table = 0x%04x\n", | |
428 | vsi->info.sched_reserved, vsi->info.outer_up_table); | |
429 | dev_info(&pf->pdev->dev, | |
430 | " info: cmd_reserved[] = 0x%02x 0x%02x 0x%02x 0x0%02x 0x%02x 0x%02x 0x%02x 0x0%02x\n", | |
431 | vsi->info.cmd_reserved[0], vsi->info.cmd_reserved[1], | |
432 | vsi->info.cmd_reserved[2], vsi->info.cmd_reserved[3], | |
433 | vsi->info.cmd_reserved[4], vsi->info.cmd_reserved[5], | |
434 | vsi->info.cmd_reserved[6], vsi->info.cmd_reserved[7]); | |
435 | dev_info(&pf->pdev->dev, | |
436 | " info: qs_handle[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n", | |
437 | vsi->info.qs_handle[0], vsi->info.qs_handle[1], | |
438 | vsi->info.qs_handle[2], vsi->info.qs_handle[3], | |
439 | vsi->info.qs_handle[4], vsi->info.qs_handle[5], | |
440 | vsi->info.qs_handle[6], vsi->info.qs_handle[7]); | |
441 | dev_info(&pf->pdev->dev, | |
442 | " info: stat_counter_idx = 0x%04x, sched_id = 0x%04x\n", | |
443 | vsi->info.stat_counter_idx, vsi->info.sched_id); | |
444 | dev_info(&pf->pdev->dev, | |
445 | " info: resp_reserved[] = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", | |
446 | vsi->info.resp_reserved[0], vsi->info.resp_reserved[1], | |
447 | vsi->info.resp_reserved[2], vsi->info.resp_reserved[3], | |
448 | vsi->info.resp_reserved[4], vsi->info.resp_reserved[5], | |
449 | vsi->info.resp_reserved[6], vsi->info.resp_reserved[7], | |
450 | vsi->info.resp_reserved[8], vsi->info.resp_reserved[9], | |
451 | vsi->info.resp_reserved[10], vsi->info.resp_reserved[11]); | |
452 | if (vsi->back) | |
b40c82e6 | 453 | dev_info(&pf->pdev->dev, " PF = %p\n", vsi->back); |
02e9c290 JB |
454 | dev_info(&pf->pdev->dev, " idx = %d\n", vsi->idx); |
455 | dev_info(&pf->pdev->dev, | |
456 | " tc_config: numtc = %d, enabled_tc = 0x%x\n", | |
457 | vsi->tc_config.numtc, vsi->tc_config.enabled_tc); | |
458 | for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { | |
459 | dev_info(&pf->pdev->dev, | |
460 | " tc_config: tc = %d, qoffset = %d, qcount = %d, netdev_tc = %d\n", | |
461 | i, vsi->tc_config.tc_info[i].qoffset, | |
462 | vsi->tc_config.tc_info[i].qcount, | |
463 | vsi->tc_config.tc_info[i].netdev_tc); | |
464 | } | |
465 | dev_info(&pf->pdev->dev, | |
466 | " bw: bw_limit = %d, bw_max_quanta = %d\n", | |
467 | vsi->bw_limit, vsi->bw_max_quanta); | |
468 | for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { | |
469 | dev_info(&pf->pdev->dev, | |
470 | " bw[%d]: ets_share_credits = %d, ets_limit_credits = %d, max_quanta = %d\n", | |
471 | i, vsi->bw_ets_share_credits[i], | |
472 | vsi->bw_ets_limit_credits[i], | |
473 | vsi->bw_ets_max_quanta[i]); | |
474 | } | |
38e00438 VD |
475 | #ifdef I40E_FCOE |
476 | if (vsi->type == I40E_VSI_FCOE) { | |
477 | dev_info(&pf->pdev->dev, | |
478 | " fcoe_stats: rx_packets = %llu, rx_dwords = %llu, rx_dropped = %llu\n", | |
479 | vsi->fcoe_stats.rx_fcoe_packets, | |
480 | vsi->fcoe_stats.rx_fcoe_dwords, | |
481 | vsi->fcoe_stats.rx_fcoe_dropped); | |
482 | dev_info(&pf->pdev->dev, | |
483 | " fcoe_stats: tx_packets = %llu, tx_dwords = %llu\n", | |
484 | vsi->fcoe_stats.tx_fcoe_packets, | |
485 | vsi->fcoe_stats.tx_fcoe_dwords); | |
486 | dev_info(&pf->pdev->dev, | |
487 | " fcoe_stats: bad_crc = %llu, last_error = %llu\n", | |
488 | vsi->fcoe_stats.fcoe_bad_fccrc, | |
489 | vsi->fcoe_stats.fcoe_last_error); | |
490 | dev_info(&pf->pdev->dev, " fcoe_stats: ddp_count = %llu\n", | |
491 | vsi->fcoe_stats.fcoe_ddp_count); | |
492 | } | |
493 | #endif | |
02e9c290 JB |
494 | } |
495 | ||
496 | /** | |
497 | * i40e_dbg_dump_aq_desc - handles dump aq_desc write into command datum | |
498 | * @pf: the i40e_pf created in command write | |
499 | **/ | |
500 | static void i40e_dbg_dump_aq_desc(struct i40e_pf *pf) | |
501 | { | |
502 | struct i40e_adminq_ring *ring; | |
503 | struct i40e_hw *hw = &pf->hw; | |
e625f71b | 504 | char hdr[32]; |
02e9c290 JB |
505 | int i; |
506 | ||
e625f71b SN |
507 | snprintf(hdr, sizeof(hdr), "%s %s: ", |
508 | dev_driver_string(&pf->pdev->dev), | |
509 | dev_name(&pf->pdev->dev)); | |
510 | ||
02e9c290 JB |
511 | /* first the send (command) ring, then the receive (event) ring */ |
512 | dev_info(&pf->pdev->dev, "AdminQ Tx Ring\n"); | |
513 | ring = &(hw->aq.asq); | |
514 | for (i = 0; i < ring->count; i++) { | |
515 | struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i); | |
6995b36c | 516 | |
02e9c290 JB |
517 | dev_info(&pf->pdev->dev, |
518 | " at[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n", | |
519 | i, d->flags, d->opcode, d->datalen, d->retval, | |
520 | d->cookie_high, d->cookie_low); | |
e625f71b SN |
521 | print_hex_dump(KERN_INFO, hdr, DUMP_PREFIX_NONE, |
522 | 16, 1, d->params.raw, 16, 0); | |
02e9c290 JB |
523 | } |
524 | ||
525 | dev_info(&pf->pdev->dev, "AdminQ Rx Ring\n"); | |
526 | ring = &(hw->aq.arq); | |
527 | for (i = 0; i < ring->count; i++) { | |
528 | struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i); | |
6995b36c | 529 | |
02e9c290 JB |
530 | dev_info(&pf->pdev->dev, |
531 | " ar[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n", | |
532 | i, d->flags, d->opcode, d->datalen, d->retval, | |
533 | d->cookie_high, d->cookie_low); | |
e625f71b SN |
534 | print_hex_dump(KERN_INFO, hdr, DUMP_PREFIX_NONE, |
535 | 16, 1, d->params.raw, 16, 0); | |
02e9c290 JB |
536 | } |
537 | } | |
538 | ||
539 | /** | |
540 | * i40e_dbg_dump_desc - handles dump desc write into command datum | |
541 | * @cnt: number of arguments that the user supplied | |
542 | * @vsi_seid: vsi id entered by user | |
543 | * @ring_id: ring id entered by user | |
544 | * @desc_n: descriptor number entered by user | |
545 | * @pf: the i40e_pf created in command write | |
546 | * @is_rx_ring: true if rx, false if tx | |
547 | **/ | |
548 | static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n, | |
549 | struct i40e_pf *pf, bool is_rx_ring) | |
550 | { | |
68bf94aa SN |
551 | struct i40e_tx_desc *txd; |
552 | union i40e_rx_desc *rxd; | |
e6c97234 | 553 | struct i40e_ring *ring; |
02e9c290 JB |
554 | struct i40e_vsi *vsi; |
555 | int i; | |
556 | ||
557 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
558 | if (!vsi) { | |
7792fe4f | 559 | dev_info(&pf->pdev->dev, "vsi %d not found\n", vsi_seid); |
02e9c290 JB |
560 | return; |
561 | } | |
562 | if (ring_id >= vsi->num_queue_pairs || ring_id < 0) { | |
563 | dev_info(&pf->pdev->dev, "ring %d not found\n", ring_id); | |
02e9c290 JB |
564 | return; |
565 | } | |
68bf94aa | 566 | if (!vsi->tx_rings || !vsi->tx_rings[0]->desc) { |
29d0790e SN |
567 | dev_info(&pf->pdev->dev, |
568 | "descriptor rings have not been allocated for vsi %d\n", | |
569 | vsi_seid); | |
570 | return; | |
571 | } | |
e6c97234 JP |
572 | |
573 | ring = kmemdup(is_rx_ring | |
574 | ? vsi->rx_rings[ring_id] : vsi->tx_rings[ring_id], | |
575 | sizeof(*ring), GFP_KERNEL); | |
576 | if (!ring) | |
577 | return; | |
578 | ||
02e9c290 JB |
579 | if (cnt == 2) { |
580 | dev_info(&pf->pdev->dev, "vsi = %02i %s ring = %02i\n", | |
581 | vsi_seid, is_rx_ring ? "rx" : "tx", ring_id); | |
e6c97234 | 582 | for (i = 0; i < ring->count; i++) { |
68bf94aa | 583 | if (!is_rx_ring) { |
e6c97234 | 584 | txd = I40E_TX_DESC(ring, i); |
02e9c290 | 585 | dev_info(&pf->pdev->dev, |
13cb3e9d | 586 | " d[%03x] = 0x%016llx 0x%016llx\n", |
68bf94aa SN |
587 | i, txd->buffer_addr, |
588 | txd->cmd_type_offset_bsz); | |
589 | } else if (sizeof(union i40e_rx_desc) == | |
590 | sizeof(union i40e_16byte_rx_desc)) { | |
e6c97234 | 591 | rxd = I40E_RX_DESC(ring, i); |
68bf94aa | 592 | dev_info(&pf->pdev->dev, |
13cb3e9d | 593 | " d[%03x] = 0x%016llx 0x%016llx\n", |
68bf94aa SN |
594 | i, rxd->read.pkt_addr, |
595 | rxd->read.hdr_addr); | |
596 | } else { | |
e6c97234 | 597 | rxd = I40E_RX_DESC(ring, i); |
02e9c290 | 598 | dev_info(&pf->pdev->dev, |
13cb3e9d | 599 | " d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n", |
68bf94aa SN |
600 | i, rxd->read.pkt_addr, |
601 | rxd->read.hdr_addr, | |
602 | rxd->read.rsvd1, rxd->read.rsvd2); | |
603 | } | |
02e9c290 JB |
604 | } |
605 | } else if (cnt == 3) { | |
e6c97234 | 606 | if (desc_n >= ring->count || desc_n < 0) { |
02e9c290 JB |
607 | dev_info(&pf->pdev->dev, |
608 | "descriptor %d not found\n", desc_n); | |
e3fe44c7 | 609 | goto out; |
02e9c290 | 610 | } |
68bf94aa | 611 | if (!is_rx_ring) { |
e6c97234 | 612 | txd = I40E_TX_DESC(ring, desc_n); |
02e9c290 | 613 | dev_info(&pf->pdev->dev, |
13cb3e9d | 614 | "vsi = %02i tx ring = %02i d[%03x] = 0x%016llx 0x%016llx\n", |
68bf94aa SN |
615 | vsi_seid, ring_id, desc_n, |
616 | txd->buffer_addr, txd->cmd_type_offset_bsz); | |
617 | } else if (sizeof(union i40e_rx_desc) == | |
618 | sizeof(union i40e_16byte_rx_desc)) { | |
e6c97234 | 619 | rxd = I40E_RX_DESC(ring, desc_n); |
68bf94aa | 620 | dev_info(&pf->pdev->dev, |
13cb3e9d | 621 | "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx\n", |
68bf94aa SN |
622 | vsi_seid, ring_id, desc_n, |
623 | rxd->read.pkt_addr, rxd->read.hdr_addr); | |
624 | } else { | |
e6c97234 | 625 | rxd = I40E_RX_DESC(ring, desc_n); |
02e9c290 | 626 | dev_info(&pf->pdev->dev, |
13cb3e9d | 627 | "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n", |
68bf94aa SN |
628 | vsi_seid, ring_id, desc_n, |
629 | rxd->read.pkt_addr, rxd->read.hdr_addr, | |
630 | rxd->read.rsvd1, rxd->read.rsvd2); | |
631 | } | |
02e9c290 | 632 | } else { |
7792fe4f | 633 | dev_info(&pf->pdev->dev, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n"); |
02e9c290 | 634 | } |
e3fe44c7 JP |
635 | |
636 | out: | |
e6c97234 | 637 | kfree(ring); |
02e9c290 JB |
638 | } |
639 | ||
640 | /** | |
641 | * i40e_dbg_dump_vsi_no_seid - handles dump vsi write into command datum | |
642 | * @pf: the i40e_pf created in command write | |
643 | **/ | |
644 | static void i40e_dbg_dump_vsi_no_seid(struct i40e_pf *pf) | |
645 | { | |
646 | int i; | |
647 | ||
505682cd | 648 | for (i = 0; i < pf->num_alloc_vsi; i++) |
02e9c290 JB |
649 | if (pf->vsi[i]) |
650 | dev_info(&pf->pdev->dev, "dump vsi[%d]: %d\n", | |
651 | i, pf->vsi[i]->seid); | |
652 | } | |
653 | ||
654 | /** | |
655 | * i40e_dbg_dump_stats - handles dump stats write into command datum | |
656 | * @pf: the i40e_pf created in command write | |
657 | * @estats: the eth stats structure to be dumped | |
658 | **/ | |
659 | static void i40e_dbg_dump_eth_stats(struct i40e_pf *pf, | |
660 | struct i40e_eth_stats *estats) | |
661 | { | |
662 | dev_info(&pf->pdev->dev, " ethstats:\n"); | |
663 | dev_info(&pf->pdev->dev, | |
664 | " rx_bytes = \t%lld \trx_unicast = \t\t%lld \trx_multicast = \t%lld\n", | |
665 | estats->rx_bytes, estats->rx_unicast, estats->rx_multicast); | |
666 | dev_info(&pf->pdev->dev, | |
03da6f6a SN |
667 | " rx_broadcast = \t%lld \trx_discards = \t\t%lld\n", |
668 | estats->rx_broadcast, estats->rx_discards); | |
02e9c290 | 669 | dev_info(&pf->pdev->dev, |
03da6f6a SN |
670 | " rx_unknown_protocol = \t%lld \ttx_bytes = \t%lld\n", |
671 | estats->rx_unknown_protocol, estats->tx_bytes); | |
02e9c290 JB |
672 | dev_info(&pf->pdev->dev, |
673 | " tx_unicast = \t%lld \ttx_multicast = \t\t%lld \ttx_broadcast = \t%lld\n", | |
674 | estats->tx_unicast, estats->tx_multicast, estats->tx_broadcast); | |
675 | dev_info(&pf->pdev->dev, | |
676 | " tx_discards = \t%lld \ttx_errors = \t\t%lld\n", | |
677 | estats->tx_discards, estats->tx_errors); | |
678 | } | |
679 | ||
02e9c290 JB |
680 | /** |
681 | * i40e_dbg_dump_veb_seid - handles dump stats of a single given veb | |
682 | * @pf: the i40e_pf created in command write | |
683 | * @seid: the seid the user put in | |
684 | **/ | |
685 | static void i40e_dbg_dump_veb_seid(struct i40e_pf *pf, int seid) | |
686 | { | |
687 | struct i40e_veb *veb; | |
688 | ||
02e9c290 JB |
689 | veb = i40e_dbg_find_veb(pf, seid); |
690 | if (!veb) { | |
e625f71b | 691 | dev_info(&pf->pdev->dev, "can't find veb %d\n", seid); |
02e9c290 JB |
692 | return; |
693 | } | |
694 | dev_info(&pf->pdev->dev, | |
51616018 | 695 | "veb idx=%d,%d stats_ic=%d seid=%d uplink=%d mode=%s\n", |
02e9c290 | 696 | veb->idx, veb->veb_idx, veb->stats_idx, veb->seid, |
51616018 NP |
697 | veb->uplink_seid, |
698 | veb->bridge_mode == BRIDGE_MODE_VEPA ? "VEPA" : "VEB"); | |
02e9c290 JB |
699 | i40e_dbg_dump_eth_stats(pf, &veb->stats); |
700 | } | |
701 | ||
702 | /** | |
703 | * i40e_dbg_dump_veb_all - dumps all known veb's stats | |
704 | * @pf: the i40e_pf created in command write | |
705 | **/ | |
706 | static void i40e_dbg_dump_veb_all(struct i40e_pf *pf) | |
707 | { | |
708 | struct i40e_veb *veb; | |
709 | int i; | |
710 | ||
711 | for (i = 0; i < I40E_MAX_VEB; i++) { | |
712 | veb = pf->veb[i]; | |
713 | if (veb) | |
714 | i40e_dbg_dump_veb_seid(pf, veb->seid); | |
715 | } | |
716 | } | |
717 | ||
718 | #define I40E_MAX_DEBUG_OUT_BUFFER (4096*4) | |
719 | /** | |
720 | * i40e_dbg_command_write - write into command datum | |
721 | * @filp: the opened file | |
722 | * @buffer: where to find the user's data | |
723 | * @count: the length of the user's data | |
724 | * @ppos: file position offset | |
725 | **/ | |
726 | static ssize_t i40e_dbg_command_write(struct file *filp, | |
727 | const char __user *buffer, | |
728 | size_t count, loff_t *ppos) | |
729 | { | |
730 | struct i40e_pf *pf = filp->private_data; | |
004173cb | 731 | char *cmd_buf, *cmd_buf_tmp; |
02e9c290 JB |
732 | int bytes_not_copied; |
733 | struct i40e_vsi *vsi; | |
02e9c290 JB |
734 | int vsi_seid; |
735 | int veb_seid; | |
736 | int cnt; | |
737 | ||
738 | /* don't allow partial writes */ | |
739 | if (*ppos != 0) | |
740 | return 0; | |
741 | ||
742 | cmd_buf = kzalloc(count + 1, GFP_KERNEL); | |
743 | if (!cmd_buf) | |
744 | return count; | |
745 | bytes_not_copied = copy_from_user(cmd_buf, buffer, count); | |
0286c67e | 746 | if (bytes_not_copied) { |
dda094a3 | 747 | kfree(cmd_buf); |
0286c67e | 748 | return -EFAULT; |
dda094a3 | 749 | } |
02e9c290 JB |
750 | cmd_buf[count] = '\0'; |
751 | ||
004173cb JB |
752 | cmd_buf_tmp = strchr(cmd_buf, '\n'); |
753 | if (cmd_buf_tmp) { | |
754 | *cmd_buf_tmp = '\0'; | |
755 | count = cmd_buf_tmp - cmd_buf + 1; | |
756 | } | |
757 | ||
02e9c290 JB |
758 | if (strncmp(cmd_buf, "add vsi", 7) == 0) { |
759 | vsi_seid = -1; | |
760 | cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid); | |
761 | if (cnt == 0) { | |
762 | /* default to PF VSI */ | |
763 | vsi_seid = pf->vsi[pf->lan_vsi]->seid; | |
764 | } else if (vsi_seid < 0) { | |
765 | dev_info(&pf->pdev->dev, "add VSI %d: bad vsi seid\n", | |
766 | vsi_seid); | |
767 | goto command_write_done; | |
768 | } | |
769 | ||
fc60861e ASJ |
770 | /* By default we are in VEPA mode, if this is the first VF/VMDq |
771 | * VSI to be added switch to VEB mode. | |
772 | */ | |
773 | if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) { | |
774 | pf->flags |= I40E_FLAG_VEB_MODE_ENABLED; | |
775 | i40e_do_reset_safe(pf, | |
776 | BIT_ULL(__I40E_PF_RESET_REQUESTED)); | |
777 | } | |
778 | ||
02e9c290 JB |
779 | vsi = i40e_vsi_setup(pf, I40E_VSI_VMDQ2, vsi_seid, 0); |
780 | if (vsi) | |
781 | dev_info(&pf->pdev->dev, "added VSI %d to relay %d\n", | |
782 | vsi->seid, vsi->uplink_seid); | |
783 | else | |
784 | dev_info(&pf->pdev->dev, "'%s' failed\n", cmd_buf); | |
785 | ||
786 | } else if (strncmp(cmd_buf, "del vsi", 7) == 0) { | |
6995b36c JB |
787 | cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid); |
788 | if (cnt != 1) { | |
789 | dev_info(&pf->pdev->dev, | |
790 | "del vsi: bad command string, cnt=%d\n", | |
791 | cnt); | |
792 | goto command_write_done; | |
793 | } | |
02e9c290 JB |
794 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); |
795 | if (!vsi) { | |
796 | dev_info(&pf->pdev->dev, "del VSI %d: seid not found\n", | |
797 | vsi_seid); | |
798 | goto command_write_done; | |
799 | } | |
800 | ||
801 | dev_info(&pf->pdev->dev, "deleting VSI %d\n", vsi_seid); | |
802 | i40e_vsi_release(vsi); | |
803 | ||
804 | } else if (strncmp(cmd_buf, "add relay", 9) == 0) { | |
805 | struct i40e_veb *veb; | |
806 | int uplink_seid, i; | |
807 | ||
808 | cnt = sscanf(&cmd_buf[9], "%i %i", &uplink_seid, &vsi_seid); | |
809 | if (cnt != 2) { | |
810 | dev_info(&pf->pdev->dev, | |
811 | "add relay: bad command string, cnt=%d\n", | |
812 | cnt); | |
813 | goto command_write_done; | |
814 | } else if (uplink_seid < 0) { | |
815 | dev_info(&pf->pdev->dev, | |
816 | "add relay %d: bad uplink seid\n", | |
817 | uplink_seid); | |
818 | goto command_write_done; | |
819 | } | |
820 | ||
821 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
822 | if (!vsi) { | |
823 | dev_info(&pf->pdev->dev, | |
c07019e4 | 824 | "add relay: VSI %d not found\n", vsi_seid); |
02e9c290 JB |
825 | goto command_write_done; |
826 | } | |
827 | ||
828 | for (i = 0; i < I40E_MAX_VEB; i++) | |
829 | if (pf->veb[i] && pf->veb[i]->seid == uplink_seid) | |
830 | break; | |
831 | if (i >= I40E_MAX_VEB && uplink_seid != 0 && | |
832 | uplink_seid != pf->mac_seid) { | |
833 | dev_info(&pf->pdev->dev, | |
834 | "add relay: relay uplink %d not found\n", | |
835 | uplink_seid); | |
836 | goto command_write_done; | |
837 | } | |
838 | ||
839 | veb = i40e_veb_setup(pf, 0, uplink_seid, vsi_seid, | |
840 | vsi->tc_config.enabled_tc); | |
841 | if (veb) | |
842 | dev_info(&pf->pdev->dev, "added relay %d\n", veb->seid); | |
843 | else | |
844 | dev_info(&pf->pdev->dev, "add relay failed\n"); | |
845 | ||
846 | } else if (strncmp(cmd_buf, "del relay", 9) == 0) { | |
847 | int i; | |
848 | cnt = sscanf(&cmd_buf[9], "%i", &veb_seid); | |
849 | if (cnt != 1) { | |
850 | dev_info(&pf->pdev->dev, | |
851 | "del relay: bad command string, cnt=%d\n", | |
852 | cnt); | |
853 | goto command_write_done; | |
854 | } else if (veb_seid < 0) { | |
855 | dev_info(&pf->pdev->dev, | |
856 | "del relay %d: bad relay seid\n", veb_seid); | |
857 | goto command_write_done; | |
858 | } | |
859 | ||
860 | /* find the veb */ | |
861 | for (i = 0; i < I40E_MAX_VEB; i++) | |
862 | if (pf->veb[i] && pf->veb[i]->seid == veb_seid) | |
863 | break; | |
864 | if (i >= I40E_MAX_VEB) { | |
865 | dev_info(&pf->pdev->dev, | |
866 | "del relay: relay %d not found\n", veb_seid); | |
867 | goto command_write_done; | |
868 | } | |
869 | ||
870 | dev_info(&pf->pdev->dev, "deleting relay %d\n", veb_seid); | |
871 | i40e_veb_release(pf->veb[i]); | |
872 | ||
873 | } else if (strncmp(cmd_buf, "add macaddr", 11) == 0) { | |
02e9c290 | 874 | struct i40e_mac_filter *f; |
738a9e9b SN |
875 | int vlan = 0; |
876 | u8 ma[6]; | |
02e9c290 JB |
877 | int ret; |
878 | ||
879 | cnt = sscanf(&cmd_buf[11], | |
880 | "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i", | |
881 | &vsi_seid, | |
882 | &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5], | |
883 | &vlan); | |
884 | if (cnt == 7) { | |
885 | vlan = 0; | |
886 | } else if (cnt != 8) { | |
887 | dev_info(&pf->pdev->dev, | |
888 | "add macaddr: bad command string, cnt=%d\n", | |
889 | cnt); | |
890 | goto command_write_done; | |
891 | } | |
892 | ||
893 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
894 | if (!vsi) { | |
895 | dev_info(&pf->pdev->dev, | |
896 | "add macaddr: VSI %d not found\n", vsi_seid); | |
897 | goto command_write_done; | |
898 | } | |
899 | ||
10dc0358 | 900 | spin_lock_bh(&vsi->mac_filter_list_lock); |
02e9c290 | 901 | f = i40e_add_filter(vsi, ma, vlan, false, false); |
10dc0358 | 902 | spin_unlock_bh(&vsi->mac_filter_list_lock); |
17652c63 | 903 | ret = i40e_sync_vsi_filters(vsi); |
02e9c290 JB |
904 | if (f && !ret) |
905 | dev_info(&pf->pdev->dev, | |
906 | "add macaddr: %pM vlan=%d added to VSI %d\n", | |
907 | ma, vlan, vsi_seid); | |
908 | else | |
909 | dev_info(&pf->pdev->dev, | |
910 | "add macaddr: %pM vlan=%d to VSI %d failed, f=%p ret=%d\n", | |
911 | ma, vlan, vsi_seid, f, ret); | |
912 | ||
913 | } else if (strncmp(cmd_buf, "del macaddr", 11) == 0) { | |
02e9c290 | 914 | int vlan = 0; |
738a9e9b | 915 | u8 ma[6]; |
02e9c290 JB |
916 | int ret; |
917 | ||
918 | cnt = sscanf(&cmd_buf[11], | |
919 | "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i", | |
920 | &vsi_seid, | |
921 | &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5], | |
922 | &vlan); | |
923 | if (cnt == 7) { | |
924 | vlan = 0; | |
925 | } else if (cnt != 8) { | |
926 | dev_info(&pf->pdev->dev, | |
927 | "del macaddr: bad command string, cnt=%d\n", | |
928 | cnt); | |
929 | goto command_write_done; | |
930 | } | |
931 | ||
932 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
933 | if (!vsi) { | |
934 | dev_info(&pf->pdev->dev, | |
935 | "del macaddr: VSI %d not found\n", vsi_seid); | |
936 | goto command_write_done; | |
937 | } | |
938 | ||
10dc0358 | 939 | spin_lock_bh(&vsi->mac_filter_list_lock); |
02e9c290 | 940 | i40e_del_filter(vsi, ma, vlan, false, false); |
10dc0358 | 941 | spin_unlock_bh(&vsi->mac_filter_list_lock); |
17652c63 | 942 | ret = i40e_sync_vsi_filters(vsi); |
02e9c290 JB |
943 | if (!ret) |
944 | dev_info(&pf->pdev->dev, | |
945 | "del macaddr: %pM vlan=%d removed from VSI %d\n", | |
946 | ma, vlan, vsi_seid); | |
947 | else | |
948 | dev_info(&pf->pdev->dev, | |
949 | "del macaddr: %pM vlan=%d from VSI %d failed, ret=%d\n", | |
950 | ma, vlan, vsi_seid, ret); | |
951 | ||
952 | } else if (strncmp(cmd_buf, "add pvid", 8) == 0) { | |
02e9c290 | 953 | i40e_status ret; |
738a9e9b | 954 | u16 vid; |
efe1ac25 | 955 | unsigned int v; |
02e9c290 JB |
956 | |
957 | cnt = sscanf(&cmd_buf[8], "%i %u", &vsi_seid, &v); | |
958 | if (cnt != 2) { | |
959 | dev_info(&pf->pdev->dev, | |
960 | "add pvid: bad command string, cnt=%d\n", cnt); | |
961 | goto command_write_done; | |
962 | } | |
963 | ||
964 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
965 | if (!vsi) { | |
966 | dev_info(&pf->pdev->dev, "add pvid: VSI %d not found\n", | |
967 | vsi_seid); | |
968 | goto command_write_done; | |
969 | } | |
970 | ||
efe1ac25 | 971 | vid = v; |
02e9c290 JB |
972 | ret = i40e_vsi_add_pvid(vsi, vid); |
973 | if (!ret) | |
974 | dev_info(&pf->pdev->dev, | |
975 | "add pvid: %d added to VSI %d\n", | |
976 | vid, vsi_seid); | |
977 | else | |
978 | dev_info(&pf->pdev->dev, | |
979 | "add pvid: %d to VSI %d failed, ret=%d\n", | |
980 | vid, vsi_seid, ret); | |
981 | ||
982 | } else if (strncmp(cmd_buf, "del pvid", 8) == 0) { | |
983 | ||
984 | cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid); | |
985 | if (cnt != 1) { | |
986 | dev_info(&pf->pdev->dev, | |
987 | "del pvid: bad command string, cnt=%d\n", | |
988 | cnt); | |
989 | goto command_write_done; | |
990 | } | |
991 | ||
992 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
993 | if (!vsi) { | |
994 | dev_info(&pf->pdev->dev, | |
995 | "del pvid: VSI %d not found\n", vsi_seid); | |
996 | goto command_write_done; | |
997 | } | |
998 | ||
999 | i40e_vsi_remove_pvid(vsi); | |
1000 | dev_info(&pf->pdev->dev, | |
1001 | "del pvid: removed from VSI %d\n", vsi_seid); | |
1002 | ||
1003 | } else if (strncmp(cmd_buf, "dump", 4) == 0) { | |
1004 | if (strncmp(&cmd_buf[5], "switch", 6) == 0) { | |
1005 | i40e_fetch_switch_configuration(pf, true); | |
1006 | } else if (strncmp(&cmd_buf[5], "vsi", 3) == 0) { | |
1007 | cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid); | |
1008 | if (cnt > 0) | |
1009 | i40e_dbg_dump_vsi_seid(pf, vsi_seid); | |
1010 | else | |
1011 | i40e_dbg_dump_vsi_no_seid(pf); | |
1012 | } else if (strncmp(&cmd_buf[5], "veb", 3) == 0) { | |
1013 | cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid); | |
1014 | if (cnt > 0) | |
1015 | i40e_dbg_dump_veb_seid(pf, vsi_seid); | |
1016 | else | |
1017 | i40e_dbg_dump_veb_all(pf); | |
1018 | } else if (strncmp(&cmd_buf[5], "desc", 4) == 0) { | |
1019 | int ring_id, desc_n; | |
1020 | if (strncmp(&cmd_buf[10], "rx", 2) == 0) { | |
1021 | cnt = sscanf(&cmd_buf[12], "%i %i %i", | |
1022 | &vsi_seid, &ring_id, &desc_n); | |
1023 | i40e_dbg_dump_desc(cnt, vsi_seid, ring_id, | |
1024 | desc_n, pf, true); | |
1025 | } else if (strncmp(&cmd_buf[10], "tx", 2) | |
1026 | == 0) { | |
1027 | cnt = sscanf(&cmd_buf[12], "%i %i %i", | |
1028 | &vsi_seid, &ring_id, &desc_n); | |
1029 | i40e_dbg_dump_desc(cnt, vsi_seid, ring_id, | |
1030 | desc_n, pf, false); | |
1031 | } else if (strncmp(&cmd_buf[10], "aq", 2) == 0) { | |
1032 | i40e_dbg_dump_aq_desc(pf); | |
1033 | } else { | |
1034 | dev_info(&pf->pdev->dev, | |
1035 | "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n"); | |
1036 | dev_info(&pf->pdev->dev, | |
1037 | "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n"); | |
1038 | dev_info(&pf->pdev->dev, "dump desc aq\n"); | |
1039 | } | |
02e9c290 JB |
1040 | } else if (strncmp(&cmd_buf[5], "reset stats", 11) == 0) { |
1041 | dev_info(&pf->pdev->dev, | |
1042 | "core reset count: %d\n", pf->corer_count); | |
1043 | dev_info(&pf->pdev->dev, | |
1044 | "global reset count: %d\n", pf->globr_count); | |
1045 | dev_info(&pf->pdev->dev, | |
1046 | "emp reset count: %d\n", pf->empr_count); | |
1047 | dev_info(&pf->pdev->dev, | |
1048 | "pf reset count: %d\n", pf->pfr_count); | |
810b3ae4 ASJ |
1049 | dev_info(&pf->pdev->dev, |
1050 | "pf tx sluggish count: %d\n", | |
1051 | pf->tx_sluggish_count); | |
02e9c290 JB |
1052 | } else if (strncmp(&cmd_buf[5], "port", 4) == 0) { |
1053 | struct i40e_aqc_query_port_ets_config_resp *bw_data; | |
1054 | struct i40e_dcbx_config *cfg = | |
1055 | &pf->hw.local_dcbx_config; | |
1056 | struct i40e_dcbx_config *r_cfg = | |
1057 | &pf->hw.remote_dcbx_config; | |
1058 | int i, ret; | |
1059 | ||
1060 | bw_data = kzalloc(sizeof( | |
1061 | struct i40e_aqc_query_port_ets_config_resp), | |
1062 | GFP_KERNEL); | |
1063 | if (!bw_data) { | |
1064 | ret = -ENOMEM; | |
1065 | goto command_write_done; | |
1066 | } | |
1067 | ||
1068 | ret = i40e_aq_query_port_ets_config(&pf->hw, | |
1069 | pf->mac_seid, | |
1070 | bw_data, NULL); | |
1071 | if (ret) { | |
1072 | dev_info(&pf->pdev->dev, | |
1073 | "Query Port ETS Config AQ command failed =0x%x\n", | |
1074 | pf->hw.aq.asq_last_status); | |
1075 | kfree(bw_data); | |
1076 | bw_data = NULL; | |
1077 | goto command_write_done; | |
1078 | } | |
1079 | dev_info(&pf->pdev->dev, | |
1080 | "port bw: tc_valid=0x%x tc_strict_prio=0x%x, tc_bw_max=0x%04x,0x%04x\n", | |
1081 | bw_data->tc_valid_bits, | |
1082 | bw_data->tc_strict_priority_bits, | |
1083 | le16_to_cpu(bw_data->tc_bw_max[0]), | |
1084 | le16_to_cpu(bw_data->tc_bw_max[1])); | |
1085 | for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { | |
1086 | dev_info(&pf->pdev->dev, "port bw: tc_bw_share=%d tc_bw_limit=%d\n", | |
1087 | bw_data->tc_bw_share_credits[i], | |
1088 | le16_to_cpu(bw_data->tc_bw_limits[i])); | |
1089 | } | |
1090 | ||
1091 | kfree(bw_data); | |
1092 | bw_data = NULL; | |
1093 | ||
9fa61dd2 NP |
1094 | dev_info(&pf->pdev->dev, |
1095 | "port dcbx_mode=%d\n", cfg->dcbx_mode); | |
02e9c290 JB |
1096 | dev_info(&pf->pdev->dev, |
1097 | "port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n", | |
1098 | cfg->etscfg.willing, cfg->etscfg.cbs, | |
1099 | cfg->etscfg.maxtcs); | |
1100 | for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { | |
1101 | dev_info(&pf->pdev->dev, "port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n", | |
1102 | i, cfg->etscfg.prioritytable[i], | |
1103 | cfg->etscfg.tcbwtable[i], | |
1104 | cfg->etscfg.tsatable[i]); | |
1105 | } | |
1106 | for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { | |
1107 | dev_info(&pf->pdev->dev, "port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n", | |
1108 | i, cfg->etsrec.prioritytable[i], | |
1109 | cfg->etsrec.tcbwtable[i], | |
1110 | cfg->etsrec.tsatable[i]); | |
1111 | } | |
1112 | dev_info(&pf->pdev->dev, | |
1113 | "port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n", | |
1114 | cfg->pfc.willing, cfg->pfc.mbc, | |
1115 | cfg->pfc.pfccap, cfg->pfc.pfcenable); | |
1116 | dev_info(&pf->pdev->dev, | |
1117 | "port app_table: num_apps=%d\n", cfg->numapps); | |
1118 | for (i = 0; i < cfg->numapps; i++) { | |
1119 | dev_info(&pf->pdev->dev, "port app_table: %d prio=%d selector=%d protocol=0x%x\n", | |
1120 | i, cfg->app[i].priority, | |
1121 | cfg->app[i].selector, | |
1122 | cfg->app[i].protocolid); | |
1123 | } | |
1124 | /* Peer TLV DCBX data */ | |
1125 | dev_info(&pf->pdev->dev, | |
1126 | "remote port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n", | |
1127 | r_cfg->etscfg.willing, | |
1128 | r_cfg->etscfg.cbs, r_cfg->etscfg.maxtcs); | |
1129 | for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { | |
1130 | dev_info(&pf->pdev->dev, "remote port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n", | |
1131 | i, r_cfg->etscfg.prioritytable[i], | |
1132 | r_cfg->etscfg.tcbwtable[i], | |
1133 | r_cfg->etscfg.tsatable[i]); | |
1134 | } | |
1135 | for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { | |
1136 | dev_info(&pf->pdev->dev, "remote port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n", | |
1137 | i, r_cfg->etsrec.prioritytable[i], | |
1138 | r_cfg->etsrec.tcbwtable[i], | |
1139 | r_cfg->etsrec.tsatable[i]); | |
1140 | } | |
1141 | dev_info(&pf->pdev->dev, | |
1142 | "remote port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n", | |
1143 | r_cfg->pfc.willing, | |
1144 | r_cfg->pfc.mbc, | |
1145 | r_cfg->pfc.pfccap, | |
1146 | r_cfg->pfc.pfcenable); | |
1147 | dev_info(&pf->pdev->dev, | |
1148 | "remote port app_table: num_apps=%d\n", | |
1149 | r_cfg->numapps); | |
1150 | for (i = 0; i < r_cfg->numapps; i++) { | |
1151 | dev_info(&pf->pdev->dev, "remote port app_table: %d prio=%d selector=%d protocol=0x%x\n", | |
1152 | i, r_cfg->app[i].priority, | |
1153 | r_cfg->app[i].selector, | |
1154 | r_cfg->app[i].protocolid); | |
1155 | } | |
3169c323 JB |
1156 | } else if (strncmp(&cmd_buf[5], "debug fwdata", 12) == 0) { |
1157 | int cluster_id, table_id; | |
1158 | int index, ret; | |
1159 | u16 buff_len = 4096; | |
1160 | u32 next_index; | |
1161 | u8 next_table; | |
1162 | u8 *buff; | |
1163 | u16 rlen; | |
1164 | ||
1165 | cnt = sscanf(&cmd_buf[18], "%i %i %i", | |
1166 | &cluster_id, &table_id, &index); | |
1167 | if (cnt != 3) { | |
1168 | dev_info(&pf->pdev->dev, | |
1169 | "dump debug fwdata <cluster_id> <table_id> <index>\n"); | |
1170 | goto command_write_done; | |
1171 | } | |
1172 | ||
1173 | dev_info(&pf->pdev->dev, | |
1174 | "AQ debug dump fwdata params %x %x %x %x\n", | |
1175 | cluster_id, table_id, index, buff_len); | |
1176 | buff = kzalloc(buff_len, GFP_KERNEL); | |
1177 | if (!buff) | |
1178 | goto command_write_done; | |
1179 | ||
1180 | ret = i40e_aq_debug_dump(&pf->hw, cluster_id, table_id, | |
1181 | index, buff_len, buff, &rlen, | |
1182 | &next_table, &next_index, | |
1183 | NULL); | |
1184 | if (ret) { | |
1185 | dev_info(&pf->pdev->dev, | |
1186 | "debug dump fwdata AQ Failed %d 0x%x\n", | |
1187 | ret, pf->hw.aq.asq_last_status); | |
1188 | kfree(buff); | |
1189 | buff = NULL; | |
1190 | goto command_write_done; | |
1191 | } | |
1192 | dev_info(&pf->pdev->dev, | |
1193 | "AQ debug dump fwdata rlen=0x%x next_table=0x%x next_index=0x%x\n", | |
1194 | rlen, next_table, next_index); | |
1195 | print_hex_dump(KERN_INFO, "AQ buffer WB: ", | |
1196 | DUMP_PREFIX_OFFSET, 16, 1, | |
1197 | buff, rlen, true); | |
1198 | kfree(buff); | |
1199 | buff = NULL; | |
02e9c290 JB |
1200 | } else { |
1201 | dev_info(&pf->pdev->dev, | |
1202 | "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n"); | |
7204a785 SN |
1203 | dev_info(&pf->pdev->dev, "dump switch\n"); |
1204 | dev_info(&pf->pdev->dev, "dump vsi [seid]\n"); | |
02e9c290 JB |
1205 | dev_info(&pf->pdev->dev, "dump reset stats\n"); |
1206 | dev_info(&pf->pdev->dev, "dump port\n"); | |
1207 | dev_info(&pf->pdev->dev, | |
1208 | "dump debug fwdata <cluster_id> <table_id> <index>\n"); | |
1209 | } | |
1210 | ||
1211 | } else if (strncmp(cmd_buf, "msg_enable", 10) == 0) { | |
1212 | u32 level; | |
1213 | cnt = sscanf(&cmd_buf[10], "%i", &level); | |
1214 | if (cnt) { | |
1215 | if (I40E_DEBUG_USER & level) { | |
1216 | pf->hw.debug_mask = level; | |
1217 | dev_info(&pf->pdev->dev, | |
1218 | "set hw.debug_mask = 0x%08x\n", | |
1219 | pf->hw.debug_mask); | |
1220 | } | |
1221 | pf->msg_enable = level; | |
1222 | dev_info(&pf->pdev->dev, "set msg_enable = 0x%08x\n", | |
1223 | pf->msg_enable); | |
1224 | } else { | |
1225 | dev_info(&pf->pdev->dev, "msg_enable = 0x%08x\n", | |
1226 | pf->msg_enable); | |
1227 | } | |
1228 | } else if (strncmp(cmd_buf, "pfr", 3) == 0) { | |
69bfb110 | 1229 | dev_info(&pf->pdev->dev, "debugfs: forcing PFR\n"); |
41a1d04b | 1230 | i40e_do_reset_safe(pf, BIT(__I40E_PF_RESET_REQUESTED)); |
02e9c290 JB |
1231 | |
1232 | } else if (strncmp(cmd_buf, "corer", 5) == 0) { | |
69bfb110 | 1233 | dev_info(&pf->pdev->dev, "debugfs: forcing CoreR\n"); |
41a1d04b | 1234 | i40e_do_reset_safe(pf, BIT(__I40E_CORE_RESET_REQUESTED)); |
02e9c290 JB |
1235 | |
1236 | } else if (strncmp(cmd_buf, "globr", 5) == 0) { | |
69bfb110 | 1237 | dev_info(&pf->pdev->dev, "debugfs: forcing GlobR\n"); |
41a1d04b | 1238 | i40e_do_reset_safe(pf, BIT(__I40E_GLOBAL_RESET_REQUESTED)); |
02e9c290 | 1239 | |
7823fe34 | 1240 | } else if (strncmp(cmd_buf, "empr", 4) == 0) { |
69bfb110 | 1241 | dev_info(&pf->pdev->dev, "debugfs: forcing EMPR\n"); |
41a1d04b | 1242 | i40e_do_reset_safe(pf, BIT(__I40E_EMP_RESET_REQUESTED)); |
7823fe34 | 1243 | |
02e9c290 JB |
1244 | } else if (strncmp(cmd_buf, "read", 4) == 0) { |
1245 | u32 address; | |
1246 | u32 value; | |
6995b36c | 1247 | |
2706a20e | 1248 | cnt = sscanf(&cmd_buf[4], "%i", &address); |
02e9c290 JB |
1249 | if (cnt != 1) { |
1250 | dev_info(&pf->pdev->dev, "read <reg>\n"); | |
1251 | goto command_write_done; | |
1252 | } | |
1253 | ||
1254 | /* check the range on address */ | |
2ac8b675 SN |
1255 | if (address > (pf->ioremap_len - sizeof(u32))) { |
1256 | dev_info(&pf->pdev->dev, "read reg address 0x%08x too large, max=0x%08lx\n", | |
e88ae667 | 1257 | address, (unsigned long int)(pf->ioremap_len - sizeof(u32))); |
02e9c290 JB |
1258 | goto command_write_done; |
1259 | } | |
1260 | ||
1261 | value = rd32(&pf->hw, address); | |
1262 | dev_info(&pf->pdev->dev, "read: 0x%08x = 0x%08x\n", | |
1263 | address, value); | |
1264 | ||
1265 | } else if (strncmp(cmd_buf, "write", 5) == 0) { | |
1266 | u32 address, value; | |
6995b36c | 1267 | |
2706a20e | 1268 | cnt = sscanf(&cmd_buf[5], "%i %i", &address, &value); |
02e9c290 JB |
1269 | if (cnt != 2) { |
1270 | dev_info(&pf->pdev->dev, "write <reg> <value>\n"); | |
1271 | goto command_write_done; | |
1272 | } | |
1273 | ||
1274 | /* check the range on address */ | |
2ac8b675 SN |
1275 | if (address > (pf->ioremap_len - sizeof(u32))) { |
1276 | dev_info(&pf->pdev->dev, "write reg address 0x%08x too large, max=0x%08lx\n", | |
e88ae667 | 1277 | address, (unsigned long int)(pf->ioremap_len - sizeof(u32))); |
02e9c290 JB |
1278 | goto command_write_done; |
1279 | } | |
1280 | wr32(&pf->hw, address, value); | |
1281 | value = rd32(&pf->hw, address); | |
1282 | dev_info(&pf->pdev->dev, "write: 0x%08x = 0x%08x\n", | |
1283 | address, value); | |
1284 | } else if (strncmp(cmd_buf, "clear_stats", 11) == 0) { | |
1285 | if (strncmp(&cmd_buf[12], "vsi", 3) == 0) { | |
2706a20e | 1286 | cnt = sscanf(&cmd_buf[15], "%i", &vsi_seid); |
02e9c290 JB |
1287 | if (cnt == 0) { |
1288 | int i; | |
6995b36c | 1289 | |
505682cd | 1290 | for (i = 0; i < pf->num_alloc_vsi; i++) |
02e9c290 JB |
1291 | i40e_vsi_reset_stats(pf->vsi[i]); |
1292 | dev_info(&pf->pdev->dev, "vsi clear stats called for all vsi's\n"); | |
1293 | } else if (cnt == 1) { | |
1294 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
1295 | if (!vsi) { | |
1296 | dev_info(&pf->pdev->dev, | |
1297 | "clear_stats vsi: bad vsi %d\n", | |
1298 | vsi_seid); | |
1299 | goto command_write_done; | |
1300 | } | |
1301 | i40e_vsi_reset_stats(vsi); | |
1302 | dev_info(&pf->pdev->dev, | |
1303 | "vsi clear stats called for vsi %d\n", | |
1304 | vsi_seid); | |
1305 | } else { | |
1306 | dev_info(&pf->pdev->dev, "clear_stats vsi [seid]\n"); | |
1307 | } | |
694dc1cb SN |
1308 | } else if (strncmp(&cmd_buf[12], "port", 4) == 0) { |
1309 | if (pf->hw.partition_id == 1) { | |
1310 | i40e_pf_reset_stats(pf); | |
1311 | dev_info(&pf->pdev->dev, "port stats cleared\n"); | |
1312 | } else { | |
1313 | dev_info(&pf->pdev->dev, "clear port stats not allowed on this port partition\n"); | |
1314 | } | |
02e9c290 | 1315 | } else { |
694dc1cb | 1316 | dev_info(&pf->pdev->dev, "clear_stats vsi [seid] or clear_stats port\n"); |
02e9c290 | 1317 | } |
f1143c4b ASJ |
1318 | } else if (strncmp(cmd_buf, "send aq_cmd", 11) == 0) { |
1319 | struct i40e_aq_desc *desc; | |
1320 | i40e_status ret; | |
1321 | ||
1322 | desc = kzalloc(sizeof(struct i40e_aq_desc), GFP_KERNEL); | |
1323 | if (!desc) | |
1324 | goto command_write_done; | |
1325 | cnt = sscanf(&cmd_buf[11], | |
fbe82101 | 1326 | "%hi %hi %hi %hi %i %i %i %i %i %i", |
f1143c4b ASJ |
1327 | &desc->flags, |
1328 | &desc->opcode, &desc->datalen, &desc->retval, | |
1329 | &desc->cookie_high, &desc->cookie_low, | |
1330 | &desc->params.internal.param0, | |
1331 | &desc->params.internal.param1, | |
1332 | &desc->params.internal.param2, | |
1333 | &desc->params.internal.param3); | |
1334 | if (cnt != 10) { | |
1335 | dev_info(&pf->pdev->dev, | |
1336 | "send aq_cmd: bad command string, cnt=%d\n", | |
1337 | cnt); | |
1338 | kfree(desc); | |
1339 | desc = NULL; | |
1340 | goto command_write_done; | |
1341 | } | |
1342 | ret = i40e_asq_send_command(&pf->hw, desc, NULL, 0, NULL); | |
1343 | if (!ret) { | |
1344 | dev_info(&pf->pdev->dev, "AQ command sent Status : Success\n"); | |
1345 | } else if (ret == I40E_ERR_ADMIN_QUEUE_ERROR) { | |
1346 | dev_info(&pf->pdev->dev, | |
1347 | "AQ command send failed Opcode %x AQ Error: %d\n", | |
1348 | desc->opcode, pf->hw.aq.asq_last_status); | |
1349 | } else { | |
1350 | dev_info(&pf->pdev->dev, | |
1351 | "AQ command send failed Opcode %x Status: %d\n", | |
1352 | desc->opcode, ret); | |
1353 | } | |
1354 | dev_info(&pf->pdev->dev, | |
1355 | "AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", | |
1356 | desc->flags, desc->opcode, desc->datalen, desc->retval, | |
1357 | desc->cookie_high, desc->cookie_low, | |
1358 | desc->params.internal.param0, | |
1359 | desc->params.internal.param1, | |
1360 | desc->params.internal.param2, | |
1361 | desc->params.internal.param3); | |
1362 | kfree(desc); | |
1363 | desc = NULL; | |
1364 | } else if (strncmp(cmd_buf, "send indirect aq_cmd", 20) == 0) { | |
1365 | struct i40e_aq_desc *desc; | |
1366 | i40e_status ret; | |
1367 | u16 buffer_len; | |
1368 | u8 *buff; | |
1369 | ||
1370 | desc = kzalloc(sizeof(struct i40e_aq_desc), GFP_KERNEL); | |
1371 | if (!desc) | |
1372 | goto command_write_done; | |
1373 | cnt = sscanf(&cmd_buf[20], | |
fbe82101 | 1374 | "%hi %hi %hi %hi %i %i %i %i %i %i %hi", |
f1143c4b ASJ |
1375 | &desc->flags, |
1376 | &desc->opcode, &desc->datalen, &desc->retval, | |
1377 | &desc->cookie_high, &desc->cookie_low, | |
1378 | &desc->params.internal.param0, | |
1379 | &desc->params.internal.param1, | |
1380 | &desc->params.internal.param2, | |
1381 | &desc->params.internal.param3, | |
1382 | &buffer_len); | |
1383 | if (cnt != 11) { | |
1384 | dev_info(&pf->pdev->dev, | |
1385 | "send indirect aq_cmd: bad command string, cnt=%d\n", | |
1386 | cnt); | |
1387 | kfree(desc); | |
1388 | desc = NULL; | |
1389 | goto command_write_done; | |
1390 | } | |
1391 | /* Just stub a buffer big enough in case user messed up */ | |
1392 | if (buffer_len == 0) | |
1393 | buffer_len = 1280; | |
1394 | ||
1395 | buff = kzalloc(buffer_len, GFP_KERNEL); | |
1396 | if (!buff) { | |
1397 | kfree(desc); | |
1398 | desc = NULL; | |
1399 | goto command_write_done; | |
1400 | } | |
1401 | desc->flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF); | |
1402 | ret = i40e_asq_send_command(&pf->hw, desc, buff, | |
1403 | buffer_len, NULL); | |
1404 | if (!ret) { | |
1405 | dev_info(&pf->pdev->dev, "AQ command sent Status : Success\n"); | |
1406 | } else if (ret == I40E_ERR_ADMIN_QUEUE_ERROR) { | |
1407 | dev_info(&pf->pdev->dev, | |
1408 | "AQ command send failed Opcode %x AQ Error: %d\n", | |
1409 | desc->opcode, pf->hw.aq.asq_last_status); | |
1410 | } else { | |
1411 | dev_info(&pf->pdev->dev, | |
1412 | "AQ command send failed Opcode %x Status: %d\n", | |
1413 | desc->opcode, ret); | |
1414 | } | |
1415 | dev_info(&pf->pdev->dev, | |
1416 | "AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", | |
1417 | desc->flags, desc->opcode, desc->datalen, desc->retval, | |
1418 | desc->cookie_high, desc->cookie_low, | |
1419 | desc->params.internal.param0, | |
1420 | desc->params.internal.param1, | |
1421 | desc->params.internal.param2, | |
1422 | desc->params.internal.param3); | |
1423 | print_hex_dump(KERN_INFO, "AQ buffer WB: ", | |
1424 | DUMP_PREFIX_OFFSET, 16, 1, | |
1425 | buff, buffer_len, true); | |
1426 | kfree(buff); | |
1427 | buff = NULL; | |
1428 | kfree(desc); | |
1429 | desc = NULL; | |
02e9c290 JB |
1430 | } else if ((strncmp(cmd_buf, "add fd_filter", 13) == 0) || |
1431 | (strncmp(cmd_buf, "rem fd_filter", 13) == 0)) { | |
17a73f6b | 1432 | struct i40e_fdir_filter fd_data; |
02e9c290 JB |
1433 | u16 packet_len, i, j = 0; |
1434 | char *asc_packet; | |
17a73f6b | 1435 | u8 *raw_packet; |
02e9c290 | 1436 | bool add = false; |
738a9e9b | 1437 | int ret; |
02e9c290 | 1438 | |
55a5e60b ASJ |
1439 | if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) |
1440 | goto command_write_done; | |
1441 | ||
1442 | if (strncmp(cmd_buf, "add", 3) == 0) | |
1443 | add = true; | |
1444 | ||
1445 | if (add && (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)) | |
1446 | goto command_write_done; | |
1447 | ||
17a73f6b | 1448 | asc_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE, |
02e9c290 JB |
1449 | GFP_KERNEL); |
1450 | if (!asc_packet) | |
1451 | goto command_write_done; | |
1452 | ||
17a73f6b JG |
1453 | raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE, |
1454 | GFP_KERNEL); | |
02e9c290 | 1455 | |
17a73f6b | 1456 | if (!raw_packet) { |
02e9c290 JB |
1457 | kfree(asc_packet); |
1458 | asc_packet = NULL; | |
1459 | goto command_write_done; | |
1460 | } | |
1461 | ||
02e9c290 | 1462 | cnt = sscanf(&cmd_buf[13], |
5561b6a1 | 1463 | "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %511s", |
02e9c290 JB |
1464 | &fd_data.q_index, |
1465 | &fd_data.flex_off, &fd_data.pctype, | |
1466 | &fd_data.dest_vsi, &fd_data.dest_ctl, | |
1467 | &fd_data.fd_status, &fd_data.cnt_index, | |
1468 | &fd_data.fd_id, &packet_len, asc_packet); | |
1469 | if (cnt != 10) { | |
1470 | dev_info(&pf->pdev->dev, | |
1471 | "program fd_filter: bad command string, cnt=%d\n", | |
1472 | cnt); | |
1473 | kfree(asc_packet); | |
1474 | asc_packet = NULL; | |
17a73f6b | 1475 | kfree(raw_packet); |
02e9c290 JB |
1476 | goto command_write_done; |
1477 | } | |
1478 | ||
1479 | /* fix packet length if user entered 0 */ | |
1480 | if (packet_len == 0) | |
17a73f6b | 1481 | packet_len = I40E_FDIR_MAX_RAW_PACKET_SIZE; |
02e9c290 JB |
1482 | |
1483 | /* make sure to check the max as well */ | |
1484 | packet_len = min_t(u16, | |
17a73f6b | 1485 | packet_len, I40E_FDIR_MAX_RAW_PACKET_SIZE); |
02e9c290 | 1486 | |
02e9c290 | 1487 | for (i = 0; i < packet_len; i++) { |
6995b36c JB |
1488 | cnt = sscanf(&asc_packet[j], "%2hhx ", &raw_packet[i]); |
1489 | if (!cnt) | |
1490 | break; | |
02e9c290 | 1491 | j += 3; |
02e9c290 | 1492 | } |
3753cb24 NP |
1493 | dev_info(&pf->pdev->dev, "FD raw packet dump\n"); |
1494 | print_hex_dump(KERN_INFO, "FD raw packet: ", | |
1495 | DUMP_PREFIX_OFFSET, 16, 1, | |
17a73f6b JG |
1496 | raw_packet, packet_len, true); |
1497 | ret = i40e_program_fdir_filter(&fd_data, raw_packet, pf, add); | |
02e9c290 JB |
1498 | if (!ret) { |
1499 | dev_info(&pf->pdev->dev, "Filter command send Status : Success\n"); | |
1500 | } else { | |
1501 | dev_info(&pf->pdev->dev, | |
1502 | "Filter command send failed %d\n", ret); | |
1503 | } | |
17a73f6b JG |
1504 | kfree(raw_packet); |
1505 | raw_packet = NULL; | |
02e9c290 JB |
1506 | kfree(asc_packet); |
1507 | asc_packet = NULL; | |
e17ff05c ASJ |
1508 | } else if (strncmp(cmd_buf, "fd current cnt", 14) == 0) { |
1509 | dev_info(&pf->pdev->dev, "FD current total filter count for this interface: %d\n", | |
1510 | i40e_get_current_fd_count(pf)); | |
02e9c290 JB |
1511 | } else if (strncmp(cmd_buf, "lldp", 4) == 0) { |
1512 | if (strncmp(&cmd_buf[5], "stop", 4) == 0) { | |
1513 | int ret; | |
6995b36c | 1514 | |
02e9c290 JB |
1515 | ret = i40e_aq_stop_lldp(&pf->hw, false, NULL); |
1516 | if (ret) { | |
1517 | dev_info(&pf->pdev->dev, | |
1518 | "Stop LLDP AQ command failed =0x%x\n", | |
1519 | pf->hw.aq.asq_last_status); | |
1520 | goto command_write_done; | |
1521 | } | |
4e3b35b0 NP |
1522 | ret = i40e_aq_add_rem_control_packet_filter(&pf->hw, |
1523 | pf->hw.mac.addr, | |
1524 | I40E_ETH_P_LLDP, 0, | |
1525 | pf->vsi[pf->lan_vsi]->seid, | |
1526 | 0, true, NULL, NULL); | |
1527 | if (ret) { | |
1528 | dev_info(&pf->pdev->dev, | |
1529 | "%s: Add Control Packet Filter AQ command failed =0x%x\n", | |
1530 | __func__, pf->hw.aq.asq_last_status); | |
1531 | goto command_write_done; | |
1532 | } | |
1533 | #ifdef CONFIG_I40E_DCB | |
1534 | pf->dcbx_cap = DCB_CAP_DCBX_HOST | | |
1535 | DCB_CAP_DCBX_VER_IEEE; | |
1536 | #endif /* CONFIG_I40E_DCB */ | |
02e9c290 JB |
1537 | } else if (strncmp(&cmd_buf[5], "start", 5) == 0) { |
1538 | int ret; | |
6995b36c | 1539 | |
4e3b35b0 NP |
1540 | ret = i40e_aq_add_rem_control_packet_filter(&pf->hw, |
1541 | pf->hw.mac.addr, | |
1542 | I40E_ETH_P_LLDP, 0, | |
1543 | pf->vsi[pf->lan_vsi]->seid, | |
1544 | 0, false, NULL, NULL); | |
1545 | if (ret) { | |
1546 | dev_info(&pf->pdev->dev, | |
1547 | "%s: Remove Control Packet Filter AQ command failed =0x%x\n", | |
1548 | __func__, pf->hw.aq.asq_last_status); | |
1549 | /* Continue and start FW LLDP anyways */ | |
1550 | } | |
1551 | ||
02e9c290 JB |
1552 | ret = i40e_aq_start_lldp(&pf->hw, NULL); |
1553 | if (ret) { | |
1554 | dev_info(&pf->pdev->dev, | |
1555 | "Start LLDP AQ command failed =0x%x\n", | |
1556 | pf->hw.aq.asq_last_status); | |
1557 | goto command_write_done; | |
1558 | } | |
4e3b35b0 NP |
1559 | #ifdef CONFIG_I40E_DCB |
1560 | pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | | |
1561 | DCB_CAP_DCBX_VER_IEEE; | |
1562 | #endif /* CONFIG_I40E_DCB */ | |
02e9c290 JB |
1563 | } else if (strncmp(&cmd_buf[5], |
1564 | "get local", 9) == 0) { | |
738a9e9b | 1565 | u16 llen, rlen; |
3753cb24 | 1566 | int ret; |
02e9c290 | 1567 | u8 *buff; |
6995b36c | 1568 | |
02e9c290 JB |
1569 | buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL); |
1570 | if (!buff) | |
1571 | goto command_write_done; | |
1572 | ||
1573 | ret = i40e_aq_get_lldp_mib(&pf->hw, 0, | |
1574 | I40E_AQ_LLDP_MIB_LOCAL, | |
1575 | buff, I40E_LLDPDU_SIZE, | |
1576 | &llen, &rlen, NULL); | |
1577 | if (ret) { | |
1578 | dev_info(&pf->pdev->dev, | |
1579 | "Get LLDP MIB (local) AQ command failed =0x%x\n", | |
1580 | pf->hw.aq.asq_last_status); | |
1581 | kfree(buff); | |
1582 | buff = NULL; | |
1583 | goto command_write_done; | |
1584 | } | |
3753cb24 NP |
1585 | dev_info(&pf->pdev->dev, "LLDP MIB (local)\n"); |
1586 | print_hex_dump(KERN_INFO, "LLDP MIB (local): ", | |
1587 | DUMP_PREFIX_OFFSET, 16, 1, | |
1588 | buff, I40E_LLDPDU_SIZE, true); | |
02e9c290 JB |
1589 | kfree(buff); |
1590 | buff = NULL; | |
1591 | } else if (strncmp(&cmd_buf[5], "get remote", 10) == 0) { | |
738a9e9b | 1592 | u16 llen, rlen; |
3753cb24 | 1593 | int ret; |
02e9c290 | 1594 | u8 *buff; |
6995b36c | 1595 | |
02e9c290 JB |
1596 | buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL); |
1597 | if (!buff) | |
1598 | goto command_write_done; | |
1599 | ||
1600 | ret = i40e_aq_get_lldp_mib(&pf->hw, | |
1601 | I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE, | |
c27936e7 | 1602 | I40E_AQ_LLDP_MIB_REMOTE, |
02e9c290 JB |
1603 | buff, I40E_LLDPDU_SIZE, |
1604 | &llen, &rlen, NULL); | |
1605 | if (ret) { | |
1606 | dev_info(&pf->pdev->dev, | |
1607 | "Get LLDP MIB (remote) AQ command failed =0x%x\n", | |
1608 | pf->hw.aq.asq_last_status); | |
1609 | kfree(buff); | |
1610 | buff = NULL; | |
1611 | goto command_write_done; | |
1612 | } | |
3753cb24 NP |
1613 | dev_info(&pf->pdev->dev, "LLDP MIB (remote)\n"); |
1614 | print_hex_dump(KERN_INFO, "LLDP MIB (remote): ", | |
1615 | DUMP_PREFIX_OFFSET, 16, 1, | |
1616 | buff, I40E_LLDPDU_SIZE, true); | |
02e9c290 JB |
1617 | kfree(buff); |
1618 | buff = NULL; | |
1619 | } else if (strncmp(&cmd_buf[5], "event on", 8) == 0) { | |
1620 | int ret; | |
6995b36c | 1621 | |
02e9c290 JB |
1622 | ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw, |
1623 | true, NULL); | |
1624 | if (ret) { | |
1625 | dev_info(&pf->pdev->dev, | |
1626 | "Config LLDP MIB Change Event (on) AQ command failed =0x%x\n", | |
1627 | pf->hw.aq.asq_last_status); | |
1628 | goto command_write_done; | |
1629 | } | |
1630 | } else if (strncmp(&cmd_buf[5], "event off", 9) == 0) { | |
1631 | int ret; | |
6995b36c | 1632 | |
02e9c290 JB |
1633 | ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw, |
1634 | false, NULL); | |
1635 | if (ret) { | |
1636 | dev_info(&pf->pdev->dev, | |
1637 | "Config LLDP MIB Change Event (off) AQ command failed =0x%x\n", | |
1638 | pf->hw.aq.asq_last_status); | |
1639 | goto command_write_done; | |
1640 | } | |
1641 | } | |
1642 | } else if (strncmp(cmd_buf, "nvm read", 8) == 0) { | |
3753cb24 | 1643 | u16 buffer_len, bytes; |
02e9c290 JB |
1644 | u16 module; |
1645 | u32 offset; | |
1646 | u16 *buff; | |
1647 | int ret; | |
1648 | ||
1649 | cnt = sscanf(&cmd_buf[8], "%hx %x %hx", | |
1650 | &module, &offset, &buffer_len); | |
1651 | if (cnt == 0) { | |
1652 | module = 0; | |
1653 | offset = 0; | |
1654 | buffer_len = 0; | |
1655 | } else if (cnt == 1) { | |
1656 | offset = 0; | |
1657 | buffer_len = 0; | |
1658 | } else if (cnt == 2) { | |
1659 | buffer_len = 0; | |
1660 | } else if (cnt > 3) { | |
1661 | dev_info(&pf->pdev->dev, | |
1662 | "nvm read: bad command string, cnt=%d\n", cnt); | |
1663 | goto command_write_done; | |
1664 | } | |
1665 | ||
520dfd8b JB |
1666 | /* set the max length */ |
1667 | buffer_len = min_t(u16, buffer_len, I40E_MAX_AQ_BUF_SIZE/2); | |
02e9c290 JB |
1668 | |
1669 | bytes = 2 * buffer_len; | |
520dfd8b JB |
1670 | |
1671 | /* read at least 1k bytes, no more than 4kB */ | |
1672 | bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE); | |
02e9c290 JB |
1673 | buff = kzalloc(bytes, GFP_KERNEL); |
1674 | if (!buff) | |
1675 | goto command_write_done; | |
1676 | ||
1677 | ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_READ); | |
1678 | if (ret) { | |
1679 | dev_info(&pf->pdev->dev, | |
1680 | "Failed Acquiring NVM resource for read err=%d status=0x%x\n", | |
1681 | ret, pf->hw.aq.asq_last_status); | |
1682 | kfree(buff); | |
1683 | goto command_write_done; | |
1684 | } | |
1685 | ||
1686 | ret = i40e_aq_read_nvm(&pf->hw, module, (2 * offset), | |
1687 | bytes, (u8 *)buff, true, NULL); | |
1688 | i40e_release_nvm(&pf->hw); | |
1689 | if (ret) { | |
1690 | dev_info(&pf->pdev->dev, | |
1691 | "Read NVM AQ failed err=%d status=0x%x\n", | |
1692 | ret, pf->hw.aq.asq_last_status); | |
1693 | } else { | |
1694 | dev_info(&pf->pdev->dev, | |
1695 | "Read NVM module=0x%x offset=0x%x words=%d\n", | |
1696 | module, offset, buffer_len); | |
a45e88c9 | 1697 | if (bytes) |
3753cb24 NP |
1698 | print_hex_dump(KERN_INFO, "NVM Dump: ", |
1699 | DUMP_PREFIX_OFFSET, 16, 2, | |
a45e88c9 | 1700 | buff, bytes, true); |
02e9c290 JB |
1701 | } |
1702 | kfree(buff); | |
1703 | buff = NULL; | |
1704 | } else { | |
1705 | dev_info(&pf->pdev->dev, "unknown command '%s'\n", cmd_buf); | |
1706 | dev_info(&pf->pdev->dev, "available commands\n"); | |
1707 | dev_info(&pf->pdev->dev, " add vsi [relay_seid]\n"); | |
1708 | dev_info(&pf->pdev->dev, " del vsi [vsi_seid]\n"); | |
1709 | dev_info(&pf->pdev->dev, " add relay <uplink_seid> <vsi_seid>\n"); | |
1710 | dev_info(&pf->pdev->dev, " del relay <relay_seid>\n"); | |
1711 | dev_info(&pf->pdev->dev, " add macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n"); | |
1712 | dev_info(&pf->pdev->dev, " del macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n"); | |
1713 | dev_info(&pf->pdev->dev, " add pvid <vsi_seid> <vid>\n"); | |
1714 | dev_info(&pf->pdev->dev, " del pvid <vsi_seid>\n"); | |
1715 | dev_info(&pf->pdev->dev, " dump switch\n"); | |
1716 | dev_info(&pf->pdev->dev, " dump vsi [seid]\n"); | |
1717 | dev_info(&pf->pdev->dev, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n"); | |
1718 | dev_info(&pf->pdev->dev, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n"); | |
1719 | dev_info(&pf->pdev->dev, " dump desc aq\n"); | |
02e9c290 | 1720 | dev_info(&pf->pdev->dev, " dump reset stats\n"); |
3169c323 | 1721 | dev_info(&pf->pdev->dev, " dump debug fwdata <cluster_id> <table_id> <index>\n"); |
02e9c290 JB |
1722 | dev_info(&pf->pdev->dev, " msg_enable [level]\n"); |
1723 | dev_info(&pf->pdev->dev, " read <reg>\n"); | |
1724 | dev_info(&pf->pdev->dev, " write <reg> <value>\n"); | |
1725 | dev_info(&pf->pdev->dev, " clear_stats vsi [seid]\n"); | |
694dc1cb | 1726 | dev_info(&pf->pdev->dev, " clear_stats port\n"); |
02e9c290 JB |
1727 | dev_info(&pf->pdev->dev, " pfr\n"); |
1728 | dev_info(&pf->pdev->dev, " corer\n"); | |
1729 | dev_info(&pf->pdev->dev, " globr\n"); | |
f1143c4b ASJ |
1730 | dev_info(&pf->pdev->dev, " send aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3>\n"); |
1731 | dev_info(&pf->pdev->dev, " send indirect aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3> <buffer_len>\n"); | |
02e9c290 JB |
1732 | dev_info(&pf->pdev->dev, " add fd_filter <dest q_index> <flex_off> <pctype> <dest_vsi> <dest_ctl> <fd_status> <cnt_index> <fd_id> <packet_len> <packet>\n"); |
1733 | dev_info(&pf->pdev->dev, " rem fd_filter <dest q_index> <flex_off> <pctype> <dest_vsi> <dest_ctl> <fd_status> <cnt_index> <fd_id> <packet_len> <packet>\n"); | |
e17ff05c | 1734 | dev_info(&pf->pdev->dev, " fd current cnt"); |
02e9c290 JB |
1735 | dev_info(&pf->pdev->dev, " lldp start\n"); |
1736 | dev_info(&pf->pdev->dev, " lldp stop\n"); | |
1737 | dev_info(&pf->pdev->dev, " lldp get local\n"); | |
1738 | dev_info(&pf->pdev->dev, " lldp get remote\n"); | |
1739 | dev_info(&pf->pdev->dev, " lldp event on\n"); | |
1740 | dev_info(&pf->pdev->dev, " lldp event off\n"); | |
1741 | dev_info(&pf->pdev->dev, " nvm read [module] [word_offset] [word_count]\n"); | |
1742 | } | |
1743 | ||
1744 | command_write_done: | |
1745 | kfree(cmd_buf); | |
1746 | cmd_buf = NULL; | |
02e9c290 JB |
1747 | return count; |
1748 | } | |
1749 | ||
1750 | static const struct file_operations i40e_dbg_command_fops = { | |
1751 | .owner = THIS_MODULE, | |
1752 | .open = simple_open, | |
1753 | .read = i40e_dbg_command_read, | |
1754 | .write = i40e_dbg_command_write, | |
1755 | }; | |
1756 | ||
1757 | /************************************************************** | |
1758 | * netdev_ops | |
1759 | * The netdev_ops entry in debugfs is for giving the driver commands | |
1760 | * to be executed from the netdev operations. | |
1761 | **************************************************************/ | |
d1da3ac0 | 1762 | static char i40e_dbg_netdev_ops_buf[256] = ""; |
02e9c290 JB |
1763 | |
1764 | /** | |
1765 | * i40e_dbg_netdev_ops - read for netdev_ops datum | |
1766 | * @filp: the opened file | |
1767 | * @buffer: where to write the data for the user to read | |
1768 | * @count: the size of the user's buffer | |
1769 | * @ppos: file position offset | |
1770 | **/ | |
1771 | static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer, | |
1772 | size_t count, loff_t *ppos) | |
1773 | { | |
1774 | struct i40e_pf *pf = filp->private_data; | |
1775 | int bytes_not_copied; | |
1776 | int buf_size = 256; | |
1777 | char *buf; | |
1778 | int len; | |
1779 | ||
1780 | /* don't allow partal reads */ | |
1781 | if (*ppos != 0) | |
1782 | return 0; | |
1783 | if (count < buf_size) | |
1784 | return -ENOSPC; | |
1785 | ||
1786 | buf = kzalloc(buf_size, GFP_KERNEL); | |
1787 | if (!buf) | |
1788 | return -ENOSPC; | |
1789 | ||
1790 | len = snprintf(buf, buf_size, "%s: %s\n", | |
1791 | pf->vsi[pf->lan_vsi]->netdev->name, | |
1792 | i40e_dbg_netdev_ops_buf); | |
1793 | ||
1794 | bytes_not_copied = copy_to_user(buffer, buf, len); | |
1795 | kfree(buf); | |
1796 | ||
0286c67e RV |
1797 | if (bytes_not_copied) |
1798 | return -EFAULT; | |
02e9c290 JB |
1799 | |
1800 | *ppos = len; | |
1801 | return len; | |
1802 | } | |
1803 | ||
1804 | /** | |
1805 | * i40e_dbg_netdev_ops_write - write into netdev_ops datum | |
1806 | * @filp: the opened file | |
1807 | * @buffer: where to find the user's data | |
1808 | * @count: the length of the user's data | |
1809 | * @ppos: file position offset | |
1810 | **/ | |
1811 | static ssize_t i40e_dbg_netdev_ops_write(struct file *filp, | |
1812 | const char __user *buffer, | |
1813 | size_t count, loff_t *ppos) | |
1814 | { | |
1815 | struct i40e_pf *pf = filp->private_data; | |
1816 | int bytes_not_copied; | |
1817 | struct i40e_vsi *vsi; | |
004173cb | 1818 | char *buf_tmp; |
02e9c290 JB |
1819 | int vsi_seid; |
1820 | int i, cnt; | |
1821 | ||
1822 | /* don't allow partial writes */ | |
1823 | if (*ppos != 0) | |
1824 | return 0; | |
1825 | if (count >= sizeof(i40e_dbg_netdev_ops_buf)) | |
1826 | return -ENOSPC; | |
1827 | ||
1828 | memset(i40e_dbg_netdev_ops_buf, 0, sizeof(i40e_dbg_netdev_ops_buf)); | |
1829 | bytes_not_copied = copy_from_user(i40e_dbg_netdev_ops_buf, | |
1830 | buffer, count); | |
0286c67e RV |
1831 | if (bytes_not_copied) |
1832 | return -EFAULT; | |
02e9c290 JB |
1833 | i40e_dbg_netdev_ops_buf[count] = '\0'; |
1834 | ||
004173cb JB |
1835 | buf_tmp = strchr(i40e_dbg_netdev_ops_buf, '\n'); |
1836 | if (buf_tmp) { | |
1837 | *buf_tmp = '\0'; | |
1838 | count = buf_tmp - i40e_dbg_netdev_ops_buf + 1; | |
1839 | } | |
1840 | ||
02e9c290 JB |
1841 | if (strncmp(i40e_dbg_netdev_ops_buf, "tx_timeout", 10) == 0) { |
1842 | cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid); | |
1843 | if (cnt != 1) { | |
1844 | dev_info(&pf->pdev->dev, "tx_timeout <vsi_seid>\n"); | |
1845 | goto netdev_ops_write_done; | |
1846 | } | |
1847 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
1848 | if (!vsi) { | |
1849 | dev_info(&pf->pdev->dev, | |
1850 | "tx_timeout: VSI %d not found\n", vsi_seid); | |
ca04657b SN |
1851 | } else if (!vsi->netdev) { |
1852 | dev_info(&pf->pdev->dev, "tx_timeout: no netdev for VSI %d\n", | |
1853 | vsi_seid); | |
1854 | } else if (test_bit(__I40E_DOWN, &vsi->state)) { | |
1855 | dev_info(&pf->pdev->dev, "tx_timeout: VSI %d not UP\n", | |
1856 | vsi_seid); | |
1857 | } else if (rtnl_trylock()) { | |
02e9c290 JB |
1858 | vsi->netdev->netdev_ops->ndo_tx_timeout(vsi->netdev); |
1859 | rtnl_unlock(); | |
1860 | dev_info(&pf->pdev->dev, "tx_timeout called\n"); | |
1861 | } else { | |
1862 | dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n"); | |
1863 | } | |
1864 | } else if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) { | |
1865 | int mtu; | |
6995b36c | 1866 | |
02e9c290 JB |
1867 | cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i %i", |
1868 | &vsi_seid, &mtu); | |
1869 | if (cnt != 2) { | |
1870 | dev_info(&pf->pdev->dev, "change_mtu <vsi_seid> <mtu>\n"); | |
1871 | goto netdev_ops_write_done; | |
1872 | } | |
1873 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
1874 | if (!vsi) { | |
1875 | dev_info(&pf->pdev->dev, | |
1876 | "change_mtu: VSI %d not found\n", vsi_seid); | |
ca04657b SN |
1877 | } else if (!vsi->netdev) { |
1878 | dev_info(&pf->pdev->dev, "change_mtu: no netdev for VSI %d\n", | |
1879 | vsi_seid); | |
1880 | } else if (rtnl_trylock()) { | |
02e9c290 JB |
1881 | vsi->netdev->netdev_ops->ndo_change_mtu(vsi->netdev, |
1882 | mtu); | |
1883 | rtnl_unlock(); | |
1884 | dev_info(&pf->pdev->dev, "change_mtu called\n"); | |
1885 | } else { | |
1886 | dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n"); | |
1887 | } | |
1888 | ||
1889 | } else if (strncmp(i40e_dbg_netdev_ops_buf, "set_rx_mode", 11) == 0) { | |
1890 | cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid); | |
1891 | if (cnt != 1) { | |
1892 | dev_info(&pf->pdev->dev, "set_rx_mode <vsi_seid>\n"); | |
1893 | goto netdev_ops_write_done; | |
1894 | } | |
1895 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
1896 | if (!vsi) { | |
1897 | dev_info(&pf->pdev->dev, | |
1898 | "set_rx_mode: VSI %d not found\n", vsi_seid); | |
ca04657b SN |
1899 | } else if (!vsi->netdev) { |
1900 | dev_info(&pf->pdev->dev, "set_rx_mode: no netdev for VSI %d\n", | |
1901 | vsi_seid); | |
1902 | } else if (rtnl_trylock()) { | |
02e9c290 JB |
1903 | vsi->netdev->netdev_ops->ndo_set_rx_mode(vsi->netdev); |
1904 | rtnl_unlock(); | |
1905 | dev_info(&pf->pdev->dev, "set_rx_mode called\n"); | |
1906 | } else { | |
1907 | dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n"); | |
1908 | } | |
1909 | ||
1910 | } else if (strncmp(i40e_dbg_netdev_ops_buf, "napi", 4) == 0) { | |
1911 | cnt = sscanf(&i40e_dbg_netdev_ops_buf[4], "%i", &vsi_seid); | |
1912 | if (cnt != 1) { | |
1913 | dev_info(&pf->pdev->dev, "napi <vsi_seid>\n"); | |
1914 | goto netdev_ops_write_done; | |
1915 | } | |
1916 | vsi = i40e_dbg_find_vsi(pf, vsi_seid); | |
1917 | if (!vsi) { | |
1918 | dev_info(&pf->pdev->dev, "napi: VSI %d not found\n", | |
1919 | vsi_seid); | |
ca04657b SN |
1920 | } else if (!vsi->netdev) { |
1921 | dev_info(&pf->pdev->dev, "napi: no netdev for VSI %d\n", | |
1922 | vsi_seid); | |
1923 | } else { | |
1924 | for (i = 0; i < vsi->num_q_vectors; i++) | |
1925 | napi_schedule(&vsi->q_vectors[i]->napi); | |
1926 | dev_info(&pf->pdev->dev, "napi called\n"); | |
02e9c290 | 1927 | } |
02e9c290 JB |
1928 | } else { |
1929 | dev_info(&pf->pdev->dev, "unknown command '%s'\n", | |
1930 | i40e_dbg_netdev_ops_buf); | |
1931 | dev_info(&pf->pdev->dev, "available commands\n"); | |
1932 | dev_info(&pf->pdev->dev, " tx_timeout <vsi_seid>\n"); | |
1933 | dev_info(&pf->pdev->dev, " change_mtu <vsi_seid> <mtu>\n"); | |
1934 | dev_info(&pf->pdev->dev, " set_rx_mode <vsi_seid>\n"); | |
1935 | dev_info(&pf->pdev->dev, " napi <vsi_seid>\n"); | |
1936 | } | |
1937 | netdev_ops_write_done: | |
1938 | return count; | |
1939 | } | |
1940 | ||
1941 | static const struct file_operations i40e_dbg_netdev_ops_fops = { | |
1942 | .owner = THIS_MODULE, | |
1943 | .open = simple_open, | |
1944 | .read = i40e_dbg_netdev_ops_read, | |
1945 | .write = i40e_dbg_netdev_ops_write, | |
1946 | }; | |
1947 | ||
1948 | /** | |
b40c82e6 JK |
1949 | * i40e_dbg_pf_init - setup the debugfs directory for the PF |
1950 | * @pf: the PF that is starting up | |
02e9c290 JB |
1951 | **/ |
1952 | void i40e_dbg_pf_init(struct i40e_pf *pf) | |
1953 | { | |
6301002f | 1954 | struct dentry *pfile; |
02e9c290 | 1955 | const char *name = pci_name(pf->pdev); |
6301002f | 1956 | const struct device *dev = &pf->pdev->dev; |
02e9c290 JB |
1957 | |
1958 | pf->i40e_dbg_pf = debugfs_create_dir(name, i40e_dbg_root); | |
6301002f JB |
1959 | if (!pf->i40e_dbg_pf) |
1960 | return; | |
1961 | ||
1962 | pfile = debugfs_create_file("command", 0600, pf->i40e_dbg_pf, pf, | |
1963 | &i40e_dbg_command_fops); | |
1964 | if (!pfile) | |
1965 | goto create_failed; | |
1966 | ||
6301002f JB |
1967 | pfile = debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf, pf, |
1968 | &i40e_dbg_netdev_ops_fops); | |
1969 | if (!pfile) | |
1970 | goto create_failed; | |
1971 | ||
1972 | return; | |
1973 | ||
1974 | create_failed: | |
1975 | dev_info(dev, "debugfs dir/file for %s failed\n", name); | |
1976 | debugfs_remove_recursive(pf->i40e_dbg_pf); | |
02e9c290 JB |
1977 | } |
1978 | ||
1979 | /** | |
b40c82e6 JK |
1980 | * i40e_dbg_pf_exit - clear out the PF's debugfs entries |
1981 | * @pf: the PF that is stopping | |
02e9c290 JB |
1982 | **/ |
1983 | void i40e_dbg_pf_exit(struct i40e_pf *pf) | |
1984 | { | |
1985 | debugfs_remove_recursive(pf->i40e_dbg_pf); | |
1986 | pf->i40e_dbg_pf = NULL; | |
02e9c290 JB |
1987 | } |
1988 | ||
1989 | /** | |
1990 | * i40e_dbg_init - start up debugfs for the driver | |
1991 | **/ | |
1992 | void i40e_dbg_init(void) | |
1993 | { | |
1994 | i40e_dbg_root = debugfs_create_dir(i40e_driver_name, NULL); | |
1995 | if (!i40e_dbg_root) | |
1996 | pr_info("init of debugfs failed\n"); | |
1997 | } | |
1998 | ||
1999 | /** | |
2000 | * i40e_dbg_exit - clean out the driver's debugfs entries | |
2001 | **/ | |
2002 | void i40e_dbg_exit(void) | |
2003 | { | |
2004 | debugfs_remove_recursive(i40e_dbg_root); | |
2005 | i40e_dbg_root = NULL; | |
2006 | } | |
2007 | ||
2008 | #endif /* CONFIG_DEBUG_FS */ |