1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 - 2016 Intel Corporation.
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.
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
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/>.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
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
25 ******************************************************************************/
27 #ifdef CONFIG_DEBUG_FS
30 #include <linux/debugfs.h>
34 static struct dentry
*i40e_dbg_root
;
37 * i40e_dbg_find_vsi - searches for the vsi with the given seid
38 * @pf - the PF structure to search for the vsi
39 * @seid - seid of the vsi it is searching for
41 static struct i40e_vsi
*i40e_dbg_find_vsi(struct i40e_pf
*pf
, int seid
)
46 dev_info(&pf
->pdev
->dev
, "%d: bad seid\n", seid
);
48 for (i
= 0; i
< pf
->num_alloc_vsi
; i
++)
49 if (pf
->vsi
[i
] && (pf
->vsi
[i
]->seid
== seid
))
56 * i40e_dbg_find_veb - searches for the veb with the given seid
57 * @pf - the PF structure to search for the veb
58 * @seid - seid of the veb it is searching for
60 static struct i40e_veb
*i40e_dbg_find_veb(struct i40e_pf
*pf
, int seid
)
64 for (i
= 0; i
< I40E_MAX_VEB
; i
++)
65 if (pf
->veb
[i
] && pf
->veb
[i
]->seid
== seid
)
70 /**************************************************************
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 **************************************************************/
77 static char i40e_dbg_command_buf
[256] = "";
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
86 static ssize_t
i40e_dbg_command_read(struct file
*filp
, char __user
*buffer
,
87 size_t count
, loff_t
*ppos
)
89 struct i40e_pf
*pf
= filp
->private_data
;
95 /* don't allow partial reads */
101 buf
= kzalloc(buf_size
, GFP_KERNEL
);
105 len
= snprintf(buf
, buf_size
, "%s: %s\n",
106 pf
->vsi
[pf
->lan_vsi
]->netdev
->name
,
107 i40e_dbg_command_buf
);
109 bytes_not_copied
= copy_to_user(buffer
, buf
, len
);
112 if (bytes_not_copied
)
120 * i40e_dbg_dump_vsi_seid - handles dump vsi seid write into command datum
121 * @pf: the i40e_pf created in command write
122 * @seid: the seid the user put in
124 static void i40e_dbg_dump_vsi_seid(struct i40e_pf
*pf
, int seid
)
126 struct rtnl_link_stats64
*nstat
;
127 struct i40e_mac_filter
*f
;
128 struct i40e_vsi
*vsi
;
131 vsi
= i40e_dbg_find_vsi(pf
, seid
);
133 dev_info(&pf
->pdev
->dev
,
134 "dump %d: seid not found\n", seid
);
137 dev_info(&pf
->pdev
->dev
, "vsi seid %d\n", seid
);
139 struct net_device
*nd
= vsi
->netdev
;
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
);
150 dev_info(&pf
->pdev
->dev
,
151 " vlgrp: & = %p\n", vsi
->active_vlans
);
152 dev_info(&pf
->pdev
->dev
,
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
);
156 if (vsi
== pf
->vsi
[pf
->lan_vsi
])
157 dev_info(&pf
->pdev
->dev
, " MAC address: %pM SAN MAC: %pM Port MAC: %pM\n",
160 pf
->hw
.mac
.port_addr
);
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
,
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",
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
);
174 dev_info(&pf
->pdev
->dev
,
175 " net_stats: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
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
);
180 dev_info(&pf
->pdev
->dev
,
181 " net_stats: multicast = %lu, collisions = %lu\n",
182 (unsigned long int)nstat
->multicast
,
183 (unsigned long int)nstat
->collisions
);
184 dev_info(&pf
->pdev
->dev
,
185 " net_stats: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
186 (unsigned long int)nstat
->rx_length_errors
,
187 (unsigned long int)nstat
->rx_over_errors
,
188 (unsigned long int)nstat
->rx_crc_errors
);
189 dev_info(&pf
->pdev
->dev
,
190 " net_stats: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
191 (unsigned long int)nstat
->rx_frame_errors
,
192 (unsigned long int)nstat
->rx_fifo_errors
,
193 (unsigned long int)nstat
->rx_missed_errors
);
194 dev_info(&pf
->pdev
->dev
,
195 " net_stats: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
196 (unsigned long int)nstat
->tx_aborted_errors
,
197 (unsigned long int)nstat
->tx_carrier_errors
,
198 (unsigned long int)nstat
->tx_fifo_errors
);
199 dev_info(&pf
->pdev
->dev
,
200 " net_stats: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
201 (unsigned long int)nstat
->tx_heartbeat_errors
,
202 (unsigned long int)nstat
->tx_window_errors
);
203 dev_info(&pf
->pdev
->dev
,
204 " net_stats: rx_compressed = %lu, tx_compressed = %lu\n",
205 (unsigned long int)nstat
->rx_compressed
,
206 (unsigned long int)nstat
->tx_compressed
);
207 dev_info(&pf
->pdev
->dev
,
208 " net_stats_offsets: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
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
);
213 dev_info(&pf
->pdev
->dev
,
214 " net_stats_offsets: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
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
);
219 dev_info(&pf
->pdev
->dev
,
220 " net_stats_offsets: multicast = %lu, collisions = %lu\n",
221 (unsigned long int)vsi
->net_stats_offsets
.multicast
,
222 (unsigned long int)vsi
->net_stats_offsets
.collisions
);
223 dev_info(&pf
->pdev
->dev
,
224 " net_stats_offsets: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
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
);
228 dev_info(&pf
->pdev
->dev
,
229 " net_stats_offsets: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
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
);
233 dev_info(&pf
->pdev
->dev
,
234 " net_stats_offsets: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
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
);
238 dev_info(&pf
->pdev
->dev
,
239 " net_stats_offsets: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
240 (unsigned long int)vsi
->net_stats_offsets
.tx_heartbeat_errors
,
241 (unsigned long int)vsi
->net_stats_offsets
.tx_window_errors
);
242 dev_info(&pf
->pdev
->dev
,
243 " net_stats_offsets: rx_compressed = %lu, tx_compressed = %lu\n",
244 (unsigned long int)vsi
->net_stats_offsets
.rx_compressed
,
245 (unsigned long int)vsi
->net_stats_offsets
.tx_compressed
);
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
);
251 for (i
= 0; i
< vsi
->num_queue_pairs
; i
++) {
252 struct i40e_ring
*rx_ring
= ACCESS_ONCE(vsi
->rx_rings
[i
]);
257 dev_info(&pf
->pdev
->dev
,
258 " rx_rings[%i]: desc = %p\n",
260 dev_info(&pf
->pdev
->dev
,
261 " rx_rings[%i]: dev = %p, netdev = %p, rx_bi = %p\n",
265 dev_info(&pf
->pdev
->dev
,
266 " rx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
268 rx_ring
->queue_index
,
270 dev_info(&pf
->pdev
->dev
,
271 " rx_rings[%i]: rx_hdr_len = %d, rx_buf_len = %d, dtype = %d\n",
272 i
, rx_ring
->rx_hdr_len
,
275 dev_info(&pf
->pdev
->dev
,
276 " rx_rings[%i]: hsplit = %d, next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
277 i
, ring_is_ps_enabled(rx_ring
),
278 rx_ring
->next_to_use
,
279 rx_ring
->next_to_clean
,
280 rx_ring
->ring_active
);
281 dev_info(&pf
->pdev
->dev
,
282 " rx_rings[%i]: rx_stats: packets = %lld, bytes = %lld, non_eop_descs = %lld\n",
283 i
, rx_ring
->stats
.packets
,
284 rx_ring
->stats
.bytes
,
285 rx_ring
->rx_stats
.non_eop_descs
);
286 dev_info(&pf
->pdev
->dev
,
287 " rx_rings[%i]: rx_stats: alloc_page_failed = %lld, alloc_buff_failed = %lld\n",
289 rx_ring
->rx_stats
.alloc_page_failed
,
290 rx_ring
->rx_stats
.alloc_buff_failed
);
291 dev_info(&pf
->pdev
->dev
,
292 " rx_rings[%i]: rx_stats: realloc_count = %lld, page_reuse_count = %lld\n",
294 rx_ring
->rx_stats
.realloc_count
,
295 rx_ring
->rx_stats
.page_reuse_count
);
296 dev_info(&pf
->pdev
->dev
,
297 " rx_rings[%i]: size = %i, dma = 0x%08lx\n",
299 (unsigned long int)rx_ring
->dma
);
300 dev_info(&pf
->pdev
->dev
,
301 " rx_rings[%i]: vsi = %p, q_vector = %p\n",
304 dev_info(&pf
->pdev
->dev
,
305 " rx_rings[%i]: rx_itr_setting = %d (%s)\n",
306 i
, rx_ring
->rx_itr_setting
,
307 ITR_IS_DYNAMIC(rx_ring
->rx_itr_setting
) ? "dynamic" : "fixed");
309 for (i
= 0; i
< vsi
->num_queue_pairs
; i
++) {
310 struct i40e_ring
*tx_ring
= ACCESS_ONCE(vsi
->tx_rings
[i
]);
315 dev_info(&pf
->pdev
->dev
,
316 " tx_rings[%i]: desc = %p\n",
318 dev_info(&pf
->pdev
->dev
,
319 " tx_rings[%i]: dev = %p, netdev = %p, tx_bi = %p\n",
323 dev_info(&pf
->pdev
->dev
,
324 " tx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
326 tx_ring
->queue_index
,
328 dev_info(&pf
->pdev
->dev
,
329 " tx_rings[%i]: dtype = %d\n",
331 dev_info(&pf
->pdev
->dev
,
332 " tx_rings[%i]: next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
334 tx_ring
->next_to_use
,
335 tx_ring
->next_to_clean
,
336 tx_ring
->ring_active
);
337 dev_info(&pf
->pdev
->dev
,
338 " tx_rings[%i]: tx_stats: packets = %lld, bytes = %lld, restart_queue = %lld\n",
339 i
, tx_ring
->stats
.packets
,
340 tx_ring
->stats
.bytes
,
341 tx_ring
->tx_stats
.restart_queue
);
342 dev_info(&pf
->pdev
->dev
,
343 " tx_rings[%i]: tx_stats: tx_busy = %lld, tx_done_old = %lld\n",
345 tx_ring
->tx_stats
.tx_busy
,
346 tx_ring
->tx_stats
.tx_done_old
);
347 dev_info(&pf
->pdev
->dev
,
348 " tx_rings[%i]: size = %i, dma = 0x%08lx\n",
350 (unsigned long int)tx_ring
->dma
);
351 dev_info(&pf
->pdev
->dev
,
352 " tx_rings[%i]: vsi = %p, q_vector = %p\n",
355 dev_info(&pf
->pdev
->dev
,
356 " tx_rings[%i]: DCB tc = %d\n",
358 dev_info(&pf
->pdev
->dev
,
359 " tx_rings[%i]: tx_itr_setting = %d (%s)\n",
360 i
, tx_ring
->tx_itr_setting
,
361 ITR_IS_DYNAMIC(tx_ring
->tx_itr_setting
) ? "dynamic" : "fixed");
364 dev_info(&pf
->pdev
->dev
,
365 " work_limit = %d\n",
367 dev_info(&pf
->pdev
->dev
,
368 " max_frame = %d, rx_hdr_len = %d, rx_buf_len = %d dtype = %d\n",
369 vsi
->max_frame
, vsi
->rx_hdr_len
, vsi
->rx_buf_len
, vsi
->dtype
);
370 dev_info(&pf
->pdev
->dev
,
371 " num_q_vectors = %i, base_vector = %i\n",
372 vsi
->num_q_vectors
, vsi
->base_vector
);
373 dev_info(&pf
->pdev
->dev
,
374 " seid = %d, id = %d, uplink_seid = %d\n",
375 vsi
->seid
, vsi
->id
, vsi
->uplink_seid
);
376 dev_info(&pf
->pdev
->dev
,
377 " base_queue = %d, num_queue_pairs = %d, num_desc = %d\n",
378 vsi
->base_queue
, vsi
->num_queue_pairs
, vsi
->num_desc
);
379 dev_info(&pf
->pdev
->dev
, " type = %i\n", vsi
->type
);
380 dev_info(&pf
->pdev
->dev
,
381 " info: valid_sections = 0x%04x, switch_id = 0x%04x\n",
382 vsi
->info
.valid_sections
, vsi
->info
.switch_id
);
383 dev_info(&pf
->pdev
->dev
,
384 " info: sw_reserved[] = 0x%02x 0x%02x\n",
385 vsi
->info
.sw_reserved
[0], vsi
->info
.sw_reserved
[1]);
386 dev_info(&pf
->pdev
->dev
,
387 " info: sec_flags = 0x%02x, sec_reserved = 0x%02x\n",
388 vsi
->info
.sec_flags
, vsi
->info
.sec_reserved
);
389 dev_info(&pf
->pdev
->dev
,
390 " info: pvid = 0x%04x, fcoe_pvid = 0x%04x, port_vlan_flags = 0x%02x\n",
391 vsi
->info
.pvid
, vsi
->info
.fcoe_pvid
,
392 vsi
->info
.port_vlan_flags
);
393 dev_info(&pf
->pdev
->dev
,
394 " info: pvlan_reserved[] = 0x%02x 0x%02x 0x%02x\n",
395 vsi
->info
.pvlan_reserved
[0], vsi
->info
.pvlan_reserved
[1],
396 vsi
->info
.pvlan_reserved
[2]);
397 dev_info(&pf
->pdev
->dev
,
398 " info: ingress_table = 0x%08x, egress_table = 0x%08x\n",
399 vsi
->info
.ingress_table
, vsi
->info
.egress_table
);
400 dev_info(&pf
->pdev
->dev
,
401 " info: cas_pv_stag = 0x%04x, cas_pv_flags= 0x%02x, cas_pv_reserved = 0x%02x\n",
402 vsi
->info
.cas_pv_tag
, vsi
->info
.cas_pv_flags
,
403 vsi
->info
.cas_pv_reserved
);
404 dev_info(&pf
->pdev
->dev
,
405 " info: queue_mapping[0..7 ] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
406 vsi
->info
.queue_mapping
[0], vsi
->info
.queue_mapping
[1],
407 vsi
->info
.queue_mapping
[2], vsi
->info
.queue_mapping
[3],
408 vsi
->info
.queue_mapping
[4], vsi
->info
.queue_mapping
[5],
409 vsi
->info
.queue_mapping
[6], vsi
->info
.queue_mapping
[7]);
410 dev_info(&pf
->pdev
->dev
,
411 " info: queue_mapping[8..15] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
412 vsi
->info
.queue_mapping
[8], vsi
->info
.queue_mapping
[9],
413 vsi
->info
.queue_mapping
[10], vsi
->info
.queue_mapping
[11],
414 vsi
->info
.queue_mapping
[12], vsi
->info
.queue_mapping
[13],
415 vsi
->info
.queue_mapping
[14], vsi
->info
.queue_mapping
[15]);
416 dev_info(&pf
->pdev
->dev
,
417 " info: tc_mapping[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
418 vsi
->info
.tc_mapping
[0], vsi
->info
.tc_mapping
[1],
419 vsi
->info
.tc_mapping
[2], vsi
->info
.tc_mapping
[3],
420 vsi
->info
.tc_mapping
[4], vsi
->info
.tc_mapping
[5],
421 vsi
->info
.tc_mapping
[6], vsi
->info
.tc_mapping
[7]);
422 dev_info(&pf
->pdev
->dev
,
423 " info: queueing_opt_flags = 0x%02x queueing_opt_reserved[0..2] = 0x%02x 0x%02x 0x%02x\n",
424 vsi
->info
.queueing_opt_flags
,
425 vsi
->info
.queueing_opt_reserved
[0],
426 vsi
->info
.queueing_opt_reserved
[1],
427 vsi
->info
.queueing_opt_reserved
[2]);
428 dev_info(&pf
->pdev
->dev
,
429 " info: up_enable_bits = 0x%02x\n",
430 vsi
->info
.up_enable_bits
);
431 dev_info(&pf
->pdev
->dev
,
432 " info: sched_reserved = 0x%02x, outer_up_table = 0x%04x\n",
433 vsi
->info
.sched_reserved
, vsi
->info
.outer_up_table
);
434 dev_info(&pf
->pdev
->dev
,
435 " info: cmd_reserved[] = 0x%02x 0x%02x 0x%02x 0x0%02x 0x%02x 0x%02x 0x%02x 0x0%02x\n",
436 vsi
->info
.cmd_reserved
[0], vsi
->info
.cmd_reserved
[1],
437 vsi
->info
.cmd_reserved
[2], vsi
->info
.cmd_reserved
[3],
438 vsi
->info
.cmd_reserved
[4], vsi
->info
.cmd_reserved
[5],
439 vsi
->info
.cmd_reserved
[6], vsi
->info
.cmd_reserved
[7]);
440 dev_info(&pf
->pdev
->dev
,
441 " info: qs_handle[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
442 vsi
->info
.qs_handle
[0], vsi
->info
.qs_handle
[1],
443 vsi
->info
.qs_handle
[2], vsi
->info
.qs_handle
[3],
444 vsi
->info
.qs_handle
[4], vsi
->info
.qs_handle
[5],
445 vsi
->info
.qs_handle
[6], vsi
->info
.qs_handle
[7]);
446 dev_info(&pf
->pdev
->dev
,
447 " info: stat_counter_idx = 0x%04x, sched_id = 0x%04x\n",
448 vsi
->info
.stat_counter_idx
, vsi
->info
.sched_id
);
449 dev_info(&pf
->pdev
->dev
,
450 " 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",
451 vsi
->info
.resp_reserved
[0], vsi
->info
.resp_reserved
[1],
452 vsi
->info
.resp_reserved
[2], vsi
->info
.resp_reserved
[3],
453 vsi
->info
.resp_reserved
[4], vsi
->info
.resp_reserved
[5],
454 vsi
->info
.resp_reserved
[6], vsi
->info
.resp_reserved
[7],
455 vsi
->info
.resp_reserved
[8], vsi
->info
.resp_reserved
[9],
456 vsi
->info
.resp_reserved
[10], vsi
->info
.resp_reserved
[11]);
458 dev_info(&pf
->pdev
->dev
, " PF = %p\n", vsi
->back
);
459 dev_info(&pf
->pdev
->dev
, " idx = %d\n", vsi
->idx
);
460 dev_info(&pf
->pdev
->dev
,
461 " tc_config: numtc = %d, enabled_tc = 0x%x\n",
462 vsi
->tc_config
.numtc
, vsi
->tc_config
.enabled_tc
);
463 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
464 dev_info(&pf
->pdev
->dev
,
465 " tc_config: tc = %d, qoffset = %d, qcount = %d, netdev_tc = %d\n",
466 i
, vsi
->tc_config
.tc_info
[i
].qoffset
,
467 vsi
->tc_config
.tc_info
[i
].qcount
,
468 vsi
->tc_config
.tc_info
[i
].netdev_tc
);
470 dev_info(&pf
->pdev
->dev
,
471 " bw: bw_limit = %d, bw_max_quanta = %d\n",
472 vsi
->bw_limit
, vsi
->bw_max_quanta
);
473 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
474 dev_info(&pf
->pdev
->dev
,
475 " bw[%d]: ets_share_credits = %d, ets_limit_credits = %d, max_quanta = %d\n",
476 i
, vsi
->bw_ets_share_credits
[i
],
477 vsi
->bw_ets_limit_credits
[i
],
478 vsi
->bw_ets_max_quanta
[i
]);
481 if (vsi
->type
== I40E_VSI_FCOE
) {
482 dev_info(&pf
->pdev
->dev
,
483 " fcoe_stats: rx_packets = %llu, rx_dwords = %llu, rx_dropped = %llu\n",
484 vsi
->fcoe_stats
.rx_fcoe_packets
,
485 vsi
->fcoe_stats
.rx_fcoe_dwords
,
486 vsi
->fcoe_stats
.rx_fcoe_dropped
);
487 dev_info(&pf
->pdev
->dev
,
488 " fcoe_stats: tx_packets = %llu, tx_dwords = %llu\n",
489 vsi
->fcoe_stats
.tx_fcoe_packets
,
490 vsi
->fcoe_stats
.tx_fcoe_dwords
);
491 dev_info(&pf
->pdev
->dev
,
492 " fcoe_stats: bad_crc = %llu, last_error = %llu\n",
493 vsi
->fcoe_stats
.fcoe_bad_fccrc
,
494 vsi
->fcoe_stats
.fcoe_last_error
);
495 dev_info(&pf
->pdev
->dev
, " fcoe_stats: ddp_count = %llu\n",
496 vsi
->fcoe_stats
.fcoe_ddp_count
);
502 * i40e_dbg_dump_aq_desc - handles dump aq_desc write into command datum
503 * @pf: the i40e_pf created in command write
505 static void i40e_dbg_dump_aq_desc(struct i40e_pf
*pf
)
507 struct i40e_adminq_ring
*ring
;
508 struct i40e_hw
*hw
= &pf
->hw
;
512 snprintf(hdr
, sizeof(hdr
), "%s %s: ",
513 dev_driver_string(&pf
->pdev
->dev
),
514 dev_name(&pf
->pdev
->dev
));
516 /* first the send (command) ring, then the receive (event) ring */
517 dev_info(&pf
->pdev
->dev
, "AdminQ Tx Ring\n");
518 ring
= &(hw
->aq
.asq
);
519 for (i
= 0; i
< ring
->count
; i
++) {
520 struct i40e_aq_desc
*d
= I40E_ADMINQ_DESC(*ring
, i
);
522 dev_info(&pf
->pdev
->dev
,
523 " at[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
524 i
, d
->flags
, d
->opcode
, d
->datalen
, d
->retval
,
525 d
->cookie_high
, d
->cookie_low
);
526 print_hex_dump(KERN_INFO
, hdr
, DUMP_PREFIX_NONE
,
527 16, 1, d
->params
.raw
, 16, 0);
530 dev_info(&pf
->pdev
->dev
, "AdminQ Rx Ring\n");
531 ring
= &(hw
->aq
.arq
);
532 for (i
= 0; i
< ring
->count
; i
++) {
533 struct i40e_aq_desc
*d
= I40E_ADMINQ_DESC(*ring
, i
);
535 dev_info(&pf
->pdev
->dev
,
536 " ar[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
537 i
, d
->flags
, d
->opcode
, d
->datalen
, d
->retval
,
538 d
->cookie_high
, d
->cookie_low
);
539 print_hex_dump(KERN_INFO
, hdr
, DUMP_PREFIX_NONE
,
540 16, 1, d
->params
.raw
, 16, 0);
545 * i40e_dbg_dump_desc - handles dump desc write into command datum
546 * @cnt: number of arguments that the user supplied
547 * @vsi_seid: vsi id entered by user
548 * @ring_id: ring id entered by user
549 * @desc_n: descriptor number entered by user
550 * @pf: the i40e_pf created in command write
551 * @is_rx_ring: true if rx, false if tx
553 static void i40e_dbg_dump_desc(int cnt
, int vsi_seid
, int ring_id
, int desc_n
,
554 struct i40e_pf
*pf
, bool is_rx_ring
)
556 struct i40e_tx_desc
*txd
;
557 union i40e_rx_desc
*rxd
;
558 struct i40e_ring
*ring
;
559 struct i40e_vsi
*vsi
;
562 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
564 dev_info(&pf
->pdev
->dev
, "vsi %d not found\n", vsi_seid
);
567 if (ring_id
>= vsi
->num_queue_pairs
|| ring_id
< 0) {
568 dev_info(&pf
->pdev
->dev
, "ring %d not found\n", ring_id
);
571 if (!vsi
->tx_rings
|| !vsi
->tx_rings
[0]->desc
) {
572 dev_info(&pf
->pdev
->dev
,
573 "descriptor rings have not been allocated for vsi %d\n",
578 ring
= kmemdup(is_rx_ring
579 ? vsi
->rx_rings
[ring_id
] : vsi
->tx_rings
[ring_id
],
580 sizeof(*ring
), GFP_KERNEL
);
585 dev_info(&pf
->pdev
->dev
, "vsi = %02i %s ring = %02i\n",
586 vsi_seid
, is_rx_ring
? "rx" : "tx", ring_id
);
587 for (i
= 0; i
< ring
->count
; i
++) {
589 txd
= I40E_TX_DESC(ring
, i
);
590 dev_info(&pf
->pdev
->dev
,
591 " d[%03x] = 0x%016llx 0x%016llx\n",
593 txd
->cmd_type_offset_bsz
);
594 } else if (sizeof(union i40e_rx_desc
) ==
595 sizeof(union i40e_16byte_rx_desc
)) {
596 rxd
= I40E_RX_DESC(ring
, i
);
597 dev_info(&pf
->pdev
->dev
,
598 " d[%03x] = 0x%016llx 0x%016llx\n",
599 i
, rxd
->read
.pkt_addr
,
602 rxd
= I40E_RX_DESC(ring
, i
);
603 dev_info(&pf
->pdev
->dev
,
604 " d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
605 i
, rxd
->read
.pkt_addr
,
607 rxd
->read
.rsvd1
, rxd
->read
.rsvd2
);
610 } else if (cnt
== 3) {
611 if (desc_n
>= ring
->count
|| desc_n
< 0) {
612 dev_info(&pf
->pdev
->dev
,
613 "descriptor %d not found\n", desc_n
);
617 txd
= I40E_TX_DESC(ring
, desc_n
);
618 dev_info(&pf
->pdev
->dev
,
619 "vsi = %02i tx ring = %02i d[%03x] = 0x%016llx 0x%016llx\n",
620 vsi_seid
, ring_id
, desc_n
,
621 txd
->buffer_addr
, txd
->cmd_type_offset_bsz
);
622 } else if (sizeof(union i40e_rx_desc
) ==
623 sizeof(union i40e_16byte_rx_desc
)) {
624 rxd
= I40E_RX_DESC(ring
, desc_n
);
625 dev_info(&pf
->pdev
->dev
,
626 "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx\n",
627 vsi_seid
, ring_id
, desc_n
,
628 rxd
->read
.pkt_addr
, rxd
->read
.hdr_addr
);
630 rxd
= I40E_RX_DESC(ring
, desc_n
);
631 dev_info(&pf
->pdev
->dev
,
632 "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
633 vsi_seid
, ring_id
, desc_n
,
634 rxd
->read
.pkt_addr
, rxd
->read
.hdr_addr
,
635 rxd
->read
.rsvd1
, rxd
->read
.rsvd2
);
638 dev_info(&pf
->pdev
->dev
, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n");
646 * i40e_dbg_dump_vsi_no_seid - handles dump vsi write into command datum
647 * @pf: the i40e_pf created in command write
649 static void i40e_dbg_dump_vsi_no_seid(struct i40e_pf
*pf
)
653 for (i
= 0; i
< pf
->num_alloc_vsi
; i
++)
655 dev_info(&pf
->pdev
->dev
, "dump vsi[%d]: %d\n",
656 i
, pf
->vsi
[i
]->seid
);
660 * i40e_dbg_dump_stats - handles dump stats write into command datum
661 * @pf: the i40e_pf created in command write
662 * @estats: the eth stats structure to be dumped
664 static void i40e_dbg_dump_eth_stats(struct i40e_pf
*pf
,
665 struct i40e_eth_stats
*estats
)
667 dev_info(&pf
->pdev
->dev
, " ethstats:\n");
668 dev_info(&pf
->pdev
->dev
,
669 " rx_bytes = \t%lld \trx_unicast = \t\t%lld \trx_multicast = \t%lld\n",
670 estats
->rx_bytes
, estats
->rx_unicast
, estats
->rx_multicast
);
671 dev_info(&pf
->pdev
->dev
,
672 " rx_broadcast = \t%lld \trx_discards = \t\t%lld\n",
673 estats
->rx_broadcast
, estats
->rx_discards
);
674 dev_info(&pf
->pdev
->dev
,
675 " rx_unknown_protocol = \t%lld \ttx_bytes = \t%lld\n",
676 estats
->rx_unknown_protocol
, estats
->tx_bytes
);
677 dev_info(&pf
->pdev
->dev
,
678 " tx_unicast = \t%lld \ttx_multicast = \t\t%lld \ttx_broadcast = \t%lld\n",
679 estats
->tx_unicast
, estats
->tx_multicast
, estats
->tx_broadcast
);
680 dev_info(&pf
->pdev
->dev
,
681 " tx_discards = \t%lld \ttx_errors = \t\t%lld\n",
682 estats
->tx_discards
, estats
->tx_errors
);
686 * i40e_dbg_dump_veb_seid - handles dump stats of a single given veb
687 * @pf: the i40e_pf created in command write
688 * @seid: the seid the user put in
690 static void i40e_dbg_dump_veb_seid(struct i40e_pf
*pf
, int seid
)
692 struct i40e_veb
*veb
;
694 veb
= i40e_dbg_find_veb(pf
, seid
);
696 dev_info(&pf
->pdev
->dev
, "can't find veb %d\n", seid
);
699 dev_info(&pf
->pdev
->dev
,
700 "veb idx=%d,%d stats_ic=%d seid=%d uplink=%d mode=%s\n",
701 veb
->idx
, veb
->veb_idx
, veb
->stats_idx
, veb
->seid
,
703 veb
->bridge_mode
== BRIDGE_MODE_VEPA
? "VEPA" : "VEB");
704 i40e_dbg_dump_eth_stats(pf
, &veb
->stats
);
708 * i40e_dbg_dump_veb_all - dumps all known veb's stats
709 * @pf: the i40e_pf created in command write
711 static void i40e_dbg_dump_veb_all(struct i40e_pf
*pf
)
713 struct i40e_veb
*veb
;
716 for (i
= 0; i
< I40E_MAX_VEB
; i
++) {
719 i40e_dbg_dump_veb_seid(pf
, veb
->seid
);
723 #define I40E_MAX_DEBUG_OUT_BUFFER (4096*4)
725 * i40e_dbg_command_write - write into command datum
726 * @filp: the opened file
727 * @buffer: where to find the user's data
728 * @count: the length of the user's data
729 * @ppos: file position offset
731 static ssize_t
i40e_dbg_command_write(struct file
*filp
,
732 const char __user
*buffer
,
733 size_t count
, loff_t
*ppos
)
735 struct i40e_pf
*pf
= filp
->private_data
;
736 char *cmd_buf
, *cmd_buf_tmp
;
737 int bytes_not_copied
;
738 struct i40e_vsi
*vsi
;
743 /* don't allow partial writes */
747 cmd_buf
= kzalloc(count
+ 1, GFP_KERNEL
);
750 bytes_not_copied
= copy_from_user(cmd_buf
, buffer
, count
);
751 if (bytes_not_copied
) {
755 cmd_buf
[count
] = '\0';
757 cmd_buf_tmp
= strchr(cmd_buf
, '\n');
760 count
= cmd_buf_tmp
- cmd_buf
+ 1;
763 if (strncmp(cmd_buf
, "add vsi", 7) == 0) {
765 cnt
= sscanf(&cmd_buf
[7], "%i", &vsi_seid
);
767 /* default to PF VSI */
768 vsi_seid
= pf
->vsi
[pf
->lan_vsi
]->seid
;
769 } else if (vsi_seid
< 0) {
770 dev_info(&pf
->pdev
->dev
, "add VSI %d: bad vsi seid\n",
772 goto command_write_done
;
775 /* By default we are in VEPA mode, if this is the first VF/VMDq
776 * VSI to be added switch to VEB mode.
778 if (!(pf
->flags
& I40E_FLAG_VEB_MODE_ENABLED
)) {
779 pf
->flags
|= I40E_FLAG_VEB_MODE_ENABLED
;
780 i40e_do_reset_safe(pf
,
781 BIT_ULL(__I40E_PF_RESET_REQUESTED
));
784 vsi
= i40e_vsi_setup(pf
, I40E_VSI_VMDQ2
, vsi_seid
, 0);
786 dev_info(&pf
->pdev
->dev
, "added VSI %d to relay %d\n",
787 vsi
->seid
, vsi
->uplink_seid
);
789 dev_info(&pf
->pdev
->dev
, "'%s' failed\n", cmd_buf
);
791 } else if (strncmp(cmd_buf
, "del vsi", 7) == 0) {
792 cnt
= sscanf(&cmd_buf
[7], "%i", &vsi_seid
);
794 dev_info(&pf
->pdev
->dev
,
795 "del vsi: bad command string, cnt=%d\n",
797 goto command_write_done
;
799 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
801 dev_info(&pf
->pdev
->dev
, "del VSI %d: seid not found\n",
803 goto command_write_done
;
806 dev_info(&pf
->pdev
->dev
, "deleting VSI %d\n", vsi_seid
);
807 i40e_vsi_release(vsi
);
809 } else if (strncmp(cmd_buf
, "add relay", 9) == 0) {
810 struct i40e_veb
*veb
;
813 cnt
= sscanf(&cmd_buf
[9], "%i %i", &uplink_seid
, &vsi_seid
);
815 dev_info(&pf
->pdev
->dev
,
816 "add relay: bad command string, cnt=%d\n",
818 goto command_write_done
;
819 } else if (uplink_seid
< 0) {
820 dev_info(&pf
->pdev
->dev
,
821 "add relay %d: bad uplink seid\n",
823 goto command_write_done
;
826 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
828 dev_info(&pf
->pdev
->dev
,
829 "add relay: VSI %d not found\n", vsi_seid
);
830 goto command_write_done
;
833 for (i
= 0; i
< I40E_MAX_VEB
; i
++)
834 if (pf
->veb
[i
] && pf
->veb
[i
]->seid
== uplink_seid
)
836 if (i
>= I40E_MAX_VEB
&& uplink_seid
!= 0 &&
837 uplink_seid
!= pf
->mac_seid
) {
838 dev_info(&pf
->pdev
->dev
,
839 "add relay: relay uplink %d not found\n",
841 goto command_write_done
;
844 veb
= i40e_veb_setup(pf
, 0, uplink_seid
, vsi_seid
,
845 vsi
->tc_config
.enabled_tc
);
847 dev_info(&pf
->pdev
->dev
, "added relay %d\n", veb
->seid
);
849 dev_info(&pf
->pdev
->dev
, "add relay failed\n");
851 } else if (strncmp(cmd_buf
, "del relay", 9) == 0) {
853 cnt
= sscanf(&cmd_buf
[9], "%i", &veb_seid
);
855 dev_info(&pf
->pdev
->dev
,
856 "del relay: bad command string, cnt=%d\n",
858 goto command_write_done
;
859 } else if (veb_seid
< 0) {
860 dev_info(&pf
->pdev
->dev
,
861 "del relay %d: bad relay seid\n", veb_seid
);
862 goto command_write_done
;
866 for (i
= 0; i
< I40E_MAX_VEB
; i
++)
867 if (pf
->veb
[i
] && pf
->veb
[i
]->seid
== veb_seid
)
869 if (i
>= I40E_MAX_VEB
) {
870 dev_info(&pf
->pdev
->dev
,
871 "del relay: relay %d not found\n", veb_seid
);
872 goto command_write_done
;
875 dev_info(&pf
->pdev
->dev
, "deleting relay %d\n", veb_seid
);
876 i40e_veb_release(pf
->veb
[i
]);
878 } else if (strncmp(cmd_buf
, "add macaddr", 11) == 0) {
879 struct i40e_mac_filter
*f
;
884 cnt
= sscanf(&cmd_buf
[11],
885 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
887 &ma
[0], &ma
[1], &ma
[2], &ma
[3], &ma
[4], &ma
[5],
891 } else if (cnt
!= 8) {
892 dev_info(&pf
->pdev
->dev
,
893 "add macaddr: bad command string, cnt=%d\n",
895 goto command_write_done
;
898 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
900 dev_info(&pf
->pdev
->dev
,
901 "add macaddr: VSI %d not found\n", vsi_seid
);
902 goto command_write_done
;
905 spin_lock_bh(&vsi
->mac_filter_list_lock
);
906 f
= i40e_add_filter(vsi
, ma
, vlan
, false, false);
907 spin_unlock_bh(&vsi
->mac_filter_list_lock
);
908 ret
= i40e_sync_vsi_filters(vsi
);
910 dev_info(&pf
->pdev
->dev
,
911 "add macaddr: %pM vlan=%d added to VSI %d\n",
914 dev_info(&pf
->pdev
->dev
,
915 "add macaddr: %pM vlan=%d to VSI %d failed, f=%p ret=%d\n",
916 ma
, vlan
, vsi_seid
, f
, ret
);
918 } else if (strncmp(cmd_buf
, "del macaddr", 11) == 0) {
923 cnt
= sscanf(&cmd_buf
[11],
924 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
926 &ma
[0], &ma
[1], &ma
[2], &ma
[3], &ma
[4], &ma
[5],
930 } else if (cnt
!= 8) {
931 dev_info(&pf
->pdev
->dev
,
932 "del macaddr: bad command string, cnt=%d\n",
934 goto command_write_done
;
937 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
939 dev_info(&pf
->pdev
->dev
,
940 "del macaddr: VSI %d not found\n", vsi_seid
);
941 goto command_write_done
;
944 spin_lock_bh(&vsi
->mac_filter_list_lock
);
945 i40e_del_filter(vsi
, ma
, vlan
, false, false);
946 spin_unlock_bh(&vsi
->mac_filter_list_lock
);
947 ret
= i40e_sync_vsi_filters(vsi
);
949 dev_info(&pf
->pdev
->dev
,
950 "del macaddr: %pM vlan=%d removed from VSI %d\n",
953 dev_info(&pf
->pdev
->dev
,
954 "del macaddr: %pM vlan=%d from VSI %d failed, ret=%d\n",
955 ma
, vlan
, vsi_seid
, ret
);
957 } else if (strncmp(cmd_buf
, "add pvid", 8) == 0) {
962 cnt
= sscanf(&cmd_buf
[8], "%i %u", &vsi_seid
, &v
);
964 dev_info(&pf
->pdev
->dev
,
965 "add pvid: bad command string, cnt=%d\n", cnt
);
966 goto command_write_done
;
969 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
971 dev_info(&pf
->pdev
->dev
, "add pvid: VSI %d not found\n",
973 goto command_write_done
;
977 ret
= i40e_vsi_add_pvid(vsi
, vid
);
979 dev_info(&pf
->pdev
->dev
,
980 "add pvid: %d added to VSI %d\n",
983 dev_info(&pf
->pdev
->dev
,
984 "add pvid: %d to VSI %d failed, ret=%d\n",
987 } else if (strncmp(cmd_buf
, "del pvid", 8) == 0) {
989 cnt
= sscanf(&cmd_buf
[8], "%i", &vsi_seid
);
991 dev_info(&pf
->pdev
->dev
,
992 "del pvid: bad command string, cnt=%d\n",
994 goto command_write_done
;
997 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
999 dev_info(&pf
->pdev
->dev
,
1000 "del pvid: VSI %d not found\n", vsi_seid
);
1001 goto command_write_done
;
1004 i40e_vsi_remove_pvid(vsi
);
1005 dev_info(&pf
->pdev
->dev
,
1006 "del pvid: removed from VSI %d\n", vsi_seid
);
1008 } else if (strncmp(cmd_buf
, "dump", 4) == 0) {
1009 if (strncmp(&cmd_buf
[5], "switch", 6) == 0) {
1010 i40e_fetch_switch_configuration(pf
, true);
1011 } else if (strncmp(&cmd_buf
[5], "vsi", 3) == 0) {
1012 cnt
= sscanf(&cmd_buf
[8], "%i", &vsi_seid
);
1014 i40e_dbg_dump_vsi_seid(pf
, vsi_seid
);
1016 i40e_dbg_dump_vsi_no_seid(pf
);
1017 } else if (strncmp(&cmd_buf
[5], "veb", 3) == 0) {
1018 cnt
= sscanf(&cmd_buf
[8], "%i", &vsi_seid
);
1020 i40e_dbg_dump_veb_seid(pf
, vsi_seid
);
1022 i40e_dbg_dump_veb_all(pf
);
1023 } else if (strncmp(&cmd_buf
[5], "desc", 4) == 0) {
1024 int ring_id
, desc_n
;
1025 if (strncmp(&cmd_buf
[10], "rx", 2) == 0) {
1026 cnt
= sscanf(&cmd_buf
[12], "%i %i %i",
1027 &vsi_seid
, &ring_id
, &desc_n
);
1028 i40e_dbg_dump_desc(cnt
, vsi_seid
, ring_id
,
1030 } else if (strncmp(&cmd_buf
[10], "tx", 2)
1032 cnt
= sscanf(&cmd_buf
[12], "%i %i %i",
1033 &vsi_seid
, &ring_id
, &desc_n
);
1034 i40e_dbg_dump_desc(cnt
, vsi_seid
, ring_id
,
1036 } else if (strncmp(&cmd_buf
[10], "aq", 2) == 0) {
1037 i40e_dbg_dump_aq_desc(pf
);
1039 dev_info(&pf
->pdev
->dev
,
1040 "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1041 dev_info(&pf
->pdev
->dev
,
1042 "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1043 dev_info(&pf
->pdev
->dev
, "dump desc aq\n");
1045 } else if (strncmp(&cmd_buf
[5], "reset stats", 11) == 0) {
1046 dev_info(&pf
->pdev
->dev
,
1047 "core reset count: %d\n", pf
->corer_count
);
1048 dev_info(&pf
->pdev
->dev
,
1049 "global reset count: %d\n", pf
->globr_count
);
1050 dev_info(&pf
->pdev
->dev
,
1051 "emp reset count: %d\n", pf
->empr_count
);
1052 dev_info(&pf
->pdev
->dev
,
1053 "pf reset count: %d\n", pf
->pfr_count
);
1054 dev_info(&pf
->pdev
->dev
,
1055 "pf tx sluggish count: %d\n",
1056 pf
->tx_sluggish_count
);
1057 } else if (strncmp(&cmd_buf
[5], "port", 4) == 0) {
1058 struct i40e_aqc_query_port_ets_config_resp
*bw_data
;
1059 struct i40e_dcbx_config
*cfg
=
1060 &pf
->hw
.local_dcbx_config
;
1061 struct i40e_dcbx_config
*r_cfg
=
1062 &pf
->hw
.remote_dcbx_config
;
1065 bw_data
= kzalloc(sizeof(
1066 struct i40e_aqc_query_port_ets_config_resp
),
1070 goto command_write_done
;
1073 ret
= i40e_aq_query_port_ets_config(&pf
->hw
,
1077 dev_info(&pf
->pdev
->dev
,
1078 "Query Port ETS Config AQ command failed =0x%x\n",
1079 pf
->hw
.aq
.asq_last_status
);
1082 goto command_write_done
;
1084 dev_info(&pf
->pdev
->dev
,
1085 "port bw: tc_valid=0x%x tc_strict_prio=0x%x, tc_bw_max=0x%04x,0x%04x\n",
1086 bw_data
->tc_valid_bits
,
1087 bw_data
->tc_strict_priority_bits
,
1088 le16_to_cpu(bw_data
->tc_bw_max
[0]),
1089 le16_to_cpu(bw_data
->tc_bw_max
[1]));
1090 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1091 dev_info(&pf
->pdev
->dev
, "port bw: tc_bw_share=%d tc_bw_limit=%d\n",
1092 bw_data
->tc_bw_share_credits
[i
],
1093 le16_to_cpu(bw_data
->tc_bw_limits
[i
]));
1099 dev_info(&pf
->pdev
->dev
,
1100 "port dcbx_mode=%d\n", cfg
->dcbx_mode
);
1101 dev_info(&pf
->pdev
->dev
,
1102 "port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1103 cfg
->etscfg
.willing
, cfg
->etscfg
.cbs
,
1104 cfg
->etscfg
.maxtcs
);
1105 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1106 dev_info(&pf
->pdev
->dev
, "port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1107 i
, cfg
->etscfg
.prioritytable
[i
],
1108 cfg
->etscfg
.tcbwtable
[i
],
1109 cfg
->etscfg
.tsatable
[i
]);
1111 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1112 dev_info(&pf
->pdev
->dev
, "port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1113 i
, cfg
->etsrec
.prioritytable
[i
],
1114 cfg
->etsrec
.tcbwtable
[i
],
1115 cfg
->etsrec
.tsatable
[i
]);
1117 dev_info(&pf
->pdev
->dev
,
1118 "port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1119 cfg
->pfc
.willing
, cfg
->pfc
.mbc
,
1120 cfg
->pfc
.pfccap
, cfg
->pfc
.pfcenable
);
1121 dev_info(&pf
->pdev
->dev
,
1122 "port app_table: num_apps=%d\n", cfg
->numapps
);
1123 for (i
= 0; i
< cfg
->numapps
; i
++) {
1124 dev_info(&pf
->pdev
->dev
, "port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1125 i
, cfg
->app
[i
].priority
,
1126 cfg
->app
[i
].selector
,
1127 cfg
->app
[i
].protocolid
);
1129 /* Peer TLV DCBX data */
1130 dev_info(&pf
->pdev
->dev
,
1131 "remote port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1132 r_cfg
->etscfg
.willing
,
1133 r_cfg
->etscfg
.cbs
, r_cfg
->etscfg
.maxtcs
);
1134 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1135 dev_info(&pf
->pdev
->dev
, "remote port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1136 i
, r_cfg
->etscfg
.prioritytable
[i
],
1137 r_cfg
->etscfg
.tcbwtable
[i
],
1138 r_cfg
->etscfg
.tsatable
[i
]);
1140 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1141 dev_info(&pf
->pdev
->dev
, "remote port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1142 i
, r_cfg
->etsrec
.prioritytable
[i
],
1143 r_cfg
->etsrec
.tcbwtable
[i
],
1144 r_cfg
->etsrec
.tsatable
[i
]);
1146 dev_info(&pf
->pdev
->dev
,
1147 "remote port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1151 r_cfg
->pfc
.pfcenable
);
1152 dev_info(&pf
->pdev
->dev
,
1153 "remote port app_table: num_apps=%d\n",
1155 for (i
= 0; i
< r_cfg
->numapps
; i
++) {
1156 dev_info(&pf
->pdev
->dev
, "remote port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1157 i
, r_cfg
->app
[i
].priority
,
1158 r_cfg
->app
[i
].selector
,
1159 r_cfg
->app
[i
].protocolid
);
1161 } else if (strncmp(&cmd_buf
[5], "debug fwdata", 12) == 0) {
1162 int cluster_id
, table_id
;
1164 u16 buff_len
= 4096;
1170 cnt
= sscanf(&cmd_buf
[18], "%i %i %i",
1171 &cluster_id
, &table_id
, &index
);
1173 dev_info(&pf
->pdev
->dev
,
1174 "dump debug fwdata <cluster_id> <table_id> <index>\n");
1175 goto command_write_done
;
1178 dev_info(&pf
->pdev
->dev
,
1179 "AQ debug dump fwdata params %x %x %x %x\n",
1180 cluster_id
, table_id
, index
, buff_len
);
1181 buff
= kzalloc(buff_len
, GFP_KERNEL
);
1183 goto command_write_done
;
1185 ret
= i40e_aq_debug_dump(&pf
->hw
, cluster_id
, table_id
,
1186 index
, buff_len
, buff
, &rlen
,
1187 &next_table
, &next_index
,
1190 dev_info(&pf
->pdev
->dev
,
1191 "debug dump fwdata AQ Failed %d 0x%x\n",
1192 ret
, pf
->hw
.aq
.asq_last_status
);
1195 goto command_write_done
;
1197 dev_info(&pf
->pdev
->dev
,
1198 "AQ debug dump fwdata rlen=0x%x next_table=0x%x next_index=0x%x\n",
1199 rlen
, next_table
, next_index
);
1200 print_hex_dump(KERN_INFO
, "AQ buffer WB: ",
1201 DUMP_PREFIX_OFFSET
, 16, 1,
1206 dev_info(&pf
->pdev
->dev
,
1207 "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n");
1208 dev_info(&pf
->pdev
->dev
, "dump switch\n");
1209 dev_info(&pf
->pdev
->dev
, "dump vsi [seid]\n");
1210 dev_info(&pf
->pdev
->dev
, "dump reset stats\n");
1211 dev_info(&pf
->pdev
->dev
, "dump port\n");
1212 dev_info(&pf
->pdev
->dev
,
1213 "dump debug fwdata <cluster_id> <table_id> <index>\n");
1216 } else if (strncmp(cmd_buf
, "msg_enable", 10) == 0) {
1218 cnt
= sscanf(&cmd_buf
[10], "%i", &level
);
1220 if (I40E_DEBUG_USER
& level
) {
1221 pf
->hw
.debug_mask
= level
;
1222 dev_info(&pf
->pdev
->dev
,
1223 "set hw.debug_mask = 0x%08x\n",
1226 pf
->msg_enable
= level
;
1227 dev_info(&pf
->pdev
->dev
, "set msg_enable = 0x%08x\n",
1230 dev_info(&pf
->pdev
->dev
, "msg_enable = 0x%08x\n",
1233 } else if (strncmp(cmd_buf
, "pfr", 3) == 0) {
1234 dev_info(&pf
->pdev
->dev
, "debugfs: forcing PFR\n");
1235 i40e_do_reset_safe(pf
, BIT(__I40E_PF_RESET_REQUESTED
));
1237 } else if (strncmp(cmd_buf
, "corer", 5) == 0) {
1238 dev_info(&pf
->pdev
->dev
, "debugfs: forcing CoreR\n");
1239 i40e_do_reset_safe(pf
, BIT(__I40E_CORE_RESET_REQUESTED
));
1241 } else if (strncmp(cmd_buf
, "globr", 5) == 0) {
1242 dev_info(&pf
->pdev
->dev
, "debugfs: forcing GlobR\n");
1243 i40e_do_reset_safe(pf
, BIT(__I40E_GLOBAL_RESET_REQUESTED
));
1245 } else if (strncmp(cmd_buf
, "empr", 4) == 0) {
1246 dev_info(&pf
->pdev
->dev
, "debugfs: forcing EMPR\n");
1247 i40e_do_reset_safe(pf
, BIT(__I40E_EMP_RESET_REQUESTED
));
1249 } else if (strncmp(cmd_buf
, "read", 4) == 0) {
1253 cnt
= sscanf(&cmd_buf
[4], "%i", &address
);
1255 dev_info(&pf
->pdev
->dev
, "read <reg>\n");
1256 goto command_write_done
;
1259 /* check the range on address */
1260 if (address
> (pf
->ioremap_len
- sizeof(u32
))) {
1261 dev_info(&pf
->pdev
->dev
, "read reg address 0x%08x too large, max=0x%08lx\n",
1262 address
, (unsigned long int)(pf
->ioremap_len
- sizeof(u32
)));
1263 goto command_write_done
;
1266 value
= rd32(&pf
->hw
, address
);
1267 dev_info(&pf
->pdev
->dev
, "read: 0x%08x = 0x%08x\n",
1270 } else if (strncmp(cmd_buf
, "write", 5) == 0) {
1273 cnt
= sscanf(&cmd_buf
[5], "%i %i", &address
, &value
);
1275 dev_info(&pf
->pdev
->dev
, "write <reg> <value>\n");
1276 goto command_write_done
;
1279 /* check the range on address */
1280 if (address
> (pf
->ioremap_len
- sizeof(u32
))) {
1281 dev_info(&pf
->pdev
->dev
, "write reg address 0x%08x too large, max=0x%08lx\n",
1282 address
, (unsigned long int)(pf
->ioremap_len
- sizeof(u32
)));
1283 goto command_write_done
;
1285 wr32(&pf
->hw
, address
, value
);
1286 value
= rd32(&pf
->hw
, address
);
1287 dev_info(&pf
->pdev
->dev
, "write: 0x%08x = 0x%08x\n",
1289 } else if (strncmp(cmd_buf
, "clear_stats", 11) == 0) {
1290 if (strncmp(&cmd_buf
[12], "vsi", 3) == 0) {
1291 cnt
= sscanf(&cmd_buf
[15], "%i", &vsi_seid
);
1295 for (i
= 0; i
< pf
->num_alloc_vsi
; i
++)
1296 i40e_vsi_reset_stats(pf
->vsi
[i
]);
1297 dev_info(&pf
->pdev
->dev
, "vsi clear stats called for all vsi's\n");
1298 } else if (cnt
== 1) {
1299 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1301 dev_info(&pf
->pdev
->dev
,
1302 "clear_stats vsi: bad vsi %d\n",
1304 goto command_write_done
;
1306 i40e_vsi_reset_stats(vsi
);
1307 dev_info(&pf
->pdev
->dev
,
1308 "vsi clear stats called for vsi %d\n",
1311 dev_info(&pf
->pdev
->dev
, "clear_stats vsi [seid]\n");
1313 } else if (strncmp(&cmd_buf
[12], "port", 4) == 0) {
1314 if (pf
->hw
.partition_id
== 1) {
1315 i40e_pf_reset_stats(pf
);
1316 dev_info(&pf
->pdev
->dev
, "port stats cleared\n");
1318 dev_info(&pf
->pdev
->dev
, "clear port stats not allowed on this port partition\n");
1321 dev_info(&pf
->pdev
->dev
, "clear_stats vsi [seid] or clear_stats port\n");
1323 } else if (strncmp(cmd_buf
, "send aq_cmd", 11) == 0) {
1324 struct i40e_aq_desc
*desc
;
1327 desc
= kzalloc(sizeof(struct i40e_aq_desc
), GFP_KERNEL
);
1329 goto command_write_done
;
1330 cnt
= sscanf(&cmd_buf
[11],
1331 "%hi %hi %hi %hi %i %i %i %i %i %i",
1333 &desc
->opcode
, &desc
->datalen
, &desc
->retval
,
1334 &desc
->cookie_high
, &desc
->cookie_low
,
1335 &desc
->params
.internal
.param0
,
1336 &desc
->params
.internal
.param1
,
1337 &desc
->params
.internal
.param2
,
1338 &desc
->params
.internal
.param3
);
1340 dev_info(&pf
->pdev
->dev
,
1341 "send aq_cmd: bad command string, cnt=%d\n",
1345 goto command_write_done
;
1347 ret
= i40e_asq_send_command(&pf
->hw
, desc
, NULL
, 0, NULL
);
1349 dev_info(&pf
->pdev
->dev
, "AQ command sent Status : Success\n");
1350 } else if (ret
== I40E_ERR_ADMIN_QUEUE_ERROR
) {
1351 dev_info(&pf
->pdev
->dev
,
1352 "AQ command send failed Opcode %x AQ Error: %d\n",
1353 desc
->opcode
, pf
->hw
.aq
.asq_last_status
);
1355 dev_info(&pf
->pdev
->dev
,
1356 "AQ command send failed Opcode %x Status: %d\n",
1359 dev_info(&pf
->pdev
->dev
,
1360 "AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
1361 desc
->flags
, desc
->opcode
, desc
->datalen
, desc
->retval
,
1362 desc
->cookie_high
, desc
->cookie_low
,
1363 desc
->params
.internal
.param0
,
1364 desc
->params
.internal
.param1
,
1365 desc
->params
.internal
.param2
,
1366 desc
->params
.internal
.param3
);
1369 } else if (strncmp(cmd_buf
, "send indirect aq_cmd", 20) == 0) {
1370 struct i40e_aq_desc
*desc
;
1375 desc
= kzalloc(sizeof(struct i40e_aq_desc
), GFP_KERNEL
);
1377 goto command_write_done
;
1378 cnt
= sscanf(&cmd_buf
[20],
1379 "%hi %hi %hi %hi %i %i %i %i %i %i %hi",
1381 &desc
->opcode
, &desc
->datalen
, &desc
->retval
,
1382 &desc
->cookie_high
, &desc
->cookie_low
,
1383 &desc
->params
.internal
.param0
,
1384 &desc
->params
.internal
.param1
,
1385 &desc
->params
.internal
.param2
,
1386 &desc
->params
.internal
.param3
,
1389 dev_info(&pf
->pdev
->dev
,
1390 "send indirect aq_cmd: bad command string, cnt=%d\n",
1394 goto command_write_done
;
1396 /* Just stub a buffer big enough in case user messed up */
1397 if (buffer_len
== 0)
1400 buff
= kzalloc(buffer_len
, GFP_KERNEL
);
1404 goto command_write_done
;
1406 desc
->flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
1407 ret
= i40e_asq_send_command(&pf
->hw
, desc
, buff
,
1410 dev_info(&pf
->pdev
->dev
, "AQ command sent Status : Success\n");
1411 } else if (ret
== I40E_ERR_ADMIN_QUEUE_ERROR
) {
1412 dev_info(&pf
->pdev
->dev
,
1413 "AQ command send failed Opcode %x AQ Error: %d\n",
1414 desc
->opcode
, pf
->hw
.aq
.asq_last_status
);
1416 dev_info(&pf
->pdev
->dev
,
1417 "AQ command send failed Opcode %x Status: %d\n",
1420 dev_info(&pf
->pdev
->dev
,
1421 "AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
1422 desc
->flags
, desc
->opcode
, desc
->datalen
, desc
->retval
,
1423 desc
->cookie_high
, desc
->cookie_low
,
1424 desc
->params
.internal
.param0
,
1425 desc
->params
.internal
.param1
,
1426 desc
->params
.internal
.param2
,
1427 desc
->params
.internal
.param3
);
1428 print_hex_dump(KERN_INFO
, "AQ buffer WB: ",
1429 DUMP_PREFIX_OFFSET
, 16, 1,
1430 buff
, buffer_len
, true);
1435 } else if ((strncmp(cmd_buf
, "add fd_filter", 13) == 0) ||
1436 (strncmp(cmd_buf
, "rem fd_filter", 13) == 0)) {
1437 struct i40e_fdir_filter fd_data
;
1438 u16 packet_len
, i
, j
= 0;
1444 if (!(pf
->flags
& I40E_FLAG_FD_SB_ENABLED
))
1445 goto command_write_done
;
1447 if (strncmp(cmd_buf
, "add", 3) == 0)
1450 if (add
&& (pf
->auto_disable_flags
& I40E_FLAG_FD_SB_ENABLED
))
1451 goto command_write_done
;
1453 asc_packet
= kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE
,
1456 goto command_write_done
;
1458 raw_packet
= kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE
,
1464 goto command_write_done
;
1467 cnt
= sscanf(&cmd_buf
[13],
1468 "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %511s",
1470 &fd_data
.flex_off
, &fd_data
.pctype
,
1471 &fd_data
.dest_vsi
, &fd_data
.dest_ctl
,
1472 &fd_data
.fd_status
, &fd_data
.cnt_index
,
1473 &fd_data
.fd_id
, &packet_len
, asc_packet
);
1475 dev_info(&pf
->pdev
->dev
,
1476 "program fd_filter: bad command string, cnt=%d\n",
1481 goto command_write_done
;
1484 /* fix packet length if user entered 0 */
1485 if (packet_len
== 0)
1486 packet_len
= I40E_FDIR_MAX_RAW_PACKET_SIZE
;
1488 /* make sure to check the max as well */
1489 packet_len
= min_t(u16
,
1490 packet_len
, I40E_FDIR_MAX_RAW_PACKET_SIZE
);
1492 for (i
= 0; i
< packet_len
; i
++) {
1493 cnt
= sscanf(&asc_packet
[j
], "%2hhx ", &raw_packet
[i
]);
1498 dev_info(&pf
->pdev
->dev
, "FD raw packet dump\n");
1499 print_hex_dump(KERN_INFO
, "FD raw packet: ",
1500 DUMP_PREFIX_OFFSET
, 16, 1,
1501 raw_packet
, packet_len
, true);
1502 ret
= i40e_program_fdir_filter(&fd_data
, raw_packet
, pf
, add
);
1504 dev_info(&pf
->pdev
->dev
, "Filter command send Status : Success\n");
1506 dev_info(&pf
->pdev
->dev
,
1507 "Filter command send failed %d\n", ret
);
1513 } else if (strncmp(cmd_buf
, "fd current cnt", 14) == 0) {
1514 dev_info(&pf
->pdev
->dev
, "FD current total filter count for this interface: %d\n",
1515 i40e_get_current_fd_count(pf
));
1516 } else if (strncmp(cmd_buf
, "lldp", 4) == 0) {
1517 if (strncmp(&cmd_buf
[5], "stop", 4) == 0) {
1520 ret
= i40e_aq_stop_lldp(&pf
->hw
, false, NULL
);
1522 dev_info(&pf
->pdev
->dev
,
1523 "Stop LLDP AQ command failed =0x%x\n",
1524 pf
->hw
.aq
.asq_last_status
);
1525 goto command_write_done
;
1527 ret
= i40e_aq_add_rem_control_packet_filter(&pf
->hw
,
1530 pf
->vsi
[pf
->lan_vsi
]->seid
,
1531 0, true, NULL
, NULL
);
1533 dev_info(&pf
->pdev
->dev
,
1534 "%s: Add Control Packet Filter AQ command failed =0x%x\n",
1535 __func__
, pf
->hw
.aq
.asq_last_status
);
1536 goto command_write_done
;
1538 #ifdef CONFIG_I40E_DCB
1539 pf
->dcbx_cap
= DCB_CAP_DCBX_HOST
|
1540 DCB_CAP_DCBX_VER_IEEE
;
1541 #endif /* CONFIG_I40E_DCB */
1542 } else if (strncmp(&cmd_buf
[5], "start", 5) == 0) {
1545 ret
= i40e_aq_add_rem_control_packet_filter(&pf
->hw
,
1548 pf
->vsi
[pf
->lan_vsi
]->seid
,
1549 0, false, NULL
, NULL
);
1551 dev_info(&pf
->pdev
->dev
,
1552 "%s: Remove Control Packet Filter AQ command failed =0x%x\n",
1553 __func__
, pf
->hw
.aq
.asq_last_status
);
1554 /* Continue and start FW LLDP anyways */
1557 ret
= i40e_aq_start_lldp(&pf
->hw
, NULL
);
1559 dev_info(&pf
->pdev
->dev
,
1560 "Start LLDP AQ command failed =0x%x\n",
1561 pf
->hw
.aq
.asq_last_status
);
1562 goto command_write_done
;
1564 #ifdef CONFIG_I40E_DCB
1565 pf
->dcbx_cap
= DCB_CAP_DCBX_LLD_MANAGED
|
1566 DCB_CAP_DCBX_VER_IEEE
;
1567 #endif /* CONFIG_I40E_DCB */
1568 } else if (strncmp(&cmd_buf
[5],
1569 "get local", 9) == 0) {
1574 buff
= kzalloc(I40E_LLDPDU_SIZE
, GFP_KERNEL
);
1576 goto command_write_done
;
1578 ret
= i40e_aq_get_lldp_mib(&pf
->hw
, 0,
1579 I40E_AQ_LLDP_MIB_LOCAL
,
1580 buff
, I40E_LLDPDU_SIZE
,
1581 &llen
, &rlen
, NULL
);
1583 dev_info(&pf
->pdev
->dev
,
1584 "Get LLDP MIB (local) AQ command failed =0x%x\n",
1585 pf
->hw
.aq
.asq_last_status
);
1588 goto command_write_done
;
1590 dev_info(&pf
->pdev
->dev
, "LLDP MIB (local)\n");
1591 print_hex_dump(KERN_INFO
, "LLDP MIB (local): ",
1592 DUMP_PREFIX_OFFSET
, 16, 1,
1593 buff
, I40E_LLDPDU_SIZE
, true);
1596 } else if (strncmp(&cmd_buf
[5], "get remote", 10) == 0) {
1601 buff
= kzalloc(I40E_LLDPDU_SIZE
, GFP_KERNEL
);
1603 goto command_write_done
;
1605 ret
= i40e_aq_get_lldp_mib(&pf
->hw
,
1606 I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE
,
1607 I40E_AQ_LLDP_MIB_REMOTE
,
1608 buff
, I40E_LLDPDU_SIZE
,
1609 &llen
, &rlen
, NULL
);
1611 dev_info(&pf
->pdev
->dev
,
1612 "Get LLDP MIB (remote) AQ command failed =0x%x\n",
1613 pf
->hw
.aq
.asq_last_status
);
1616 goto command_write_done
;
1618 dev_info(&pf
->pdev
->dev
, "LLDP MIB (remote)\n");
1619 print_hex_dump(KERN_INFO
, "LLDP MIB (remote): ",
1620 DUMP_PREFIX_OFFSET
, 16, 1,
1621 buff
, I40E_LLDPDU_SIZE
, true);
1624 } else if (strncmp(&cmd_buf
[5], "event on", 8) == 0) {
1627 ret
= i40e_aq_cfg_lldp_mib_change_event(&pf
->hw
,
1630 dev_info(&pf
->pdev
->dev
,
1631 "Config LLDP MIB Change Event (on) AQ command failed =0x%x\n",
1632 pf
->hw
.aq
.asq_last_status
);
1633 goto command_write_done
;
1635 } else if (strncmp(&cmd_buf
[5], "event off", 9) == 0) {
1638 ret
= i40e_aq_cfg_lldp_mib_change_event(&pf
->hw
,
1641 dev_info(&pf
->pdev
->dev
,
1642 "Config LLDP MIB Change Event (off) AQ command failed =0x%x\n",
1643 pf
->hw
.aq
.asq_last_status
);
1644 goto command_write_done
;
1647 } else if (strncmp(cmd_buf
, "nvm read", 8) == 0) {
1648 u16 buffer_len
, bytes
;
1654 cnt
= sscanf(&cmd_buf
[8], "%hx %x %hx",
1655 &module
, &offset
, &buffer_len
);
1660 } else if (cnt
== 1) {
1663 } else if (cnt
== 2) {
1665 } else if (cnt
> 3) {
1666 dev_info(&pf
->pdev
->dev
,
1667 "nvm read: bad command string, cnt=%d\n", cnt
);
1668 goto command_write_done
;
1671 /* set the max length */
1672 buffer_len
= min_t(u16
, buffer_len
, I40E_MAX_AQ_BUF_SIZE
/2);
1674 bytes
= 2 * buffer_len
;
1676 /* read at least 1k bytes, no more than 4kB */
1677 bytes
= clamp(bytes
, (u16
)1024, (u16
)I40E_MAX_AQ_BUF_SIZE
);
1678 buff
= kzalloc(bytes
, GFP_KERNEL
);
1680 goto command_write_done
;
1682 ret
= i40e_acquire_nvm(&pf
->hw
, I40E_RESOURCE_READ
);
1684 dev_info(&pf
->pdev
->dev
,
1685 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
1686 ret
, pf
->hw
.aq
.asq_last_status
);
1688 goto command_write_done
;
1691 ret
= i40e_aq_read_nvm(&pf
->hw
, module
, (2 * offset
),
1692 bytes
, (u8
*)buff
, true, NULL
);
1693 i40e_release_nvm(&pf
->hw
);
1695 dev_info(&pf
->pdev
->dev
,
1696 "Read NVM AQ failed err=%d status=0x%x\n",
1697 ret
, pf
->hw
.aq
.asq_last_status
);
1699 dev_info(&pf
->pdev
->dev
,
1700 "Read NVM module=0x%x offset=0x%x words=%d\n",
1701 module
, offset
, buffer_len
);
1703 print_hex_dump(KERN_INFO
, "NVM Dump: ",
1704 DUMP_PREFIX_OFFSET
, 16, 2,
1710 dev_info(&pf
->pdev
->dev
, "unknown command '%s'\n", cmd_buf
);
1711 dev_info(&pf
->pdev
->dev
, "available commands\n");
1712 dev_info(&pf
->pdev
->dev
, " add vsi [relay_seid]\n");
1713 dev_info(&pf
->pdev
->dev
, " del vsi [vsi_seid]\n");
1714 dev_info(&pf
->pdev
->dev
, " add relay <uplink_seid> <vsi_seid>\n");
1715 dev_info(&pf
->pdev
->dev
, " del relay <relay_seid>\n");
1716 dev_info(&pf
->pdev
->dev
, " add macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1717 dev_info(&pf
->pdev
->dev
, " del macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1718 dev_info(&pf
->pdev
->dev
, " add pvid <vsi_seid> <vid>\n");
1719 dev_info(&pf
->pdev
->dev
, " del pvid <vsi_seid>\n");
1720 dev_info(&pf
->pdev
->dev
, " dump switch\n");
1721 dev_info(&pf
->pdev
->dev
, " dump vsi [seid]\n");
1722 dev_info(&pf
->pdev
->dev
, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1723 dev_info(&pf
->pdev
->dev
, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1724 dev_info(&pf
->pdev
->dev
, " dump desc aq\n");
1725 dev_info(&pf
->pdev
->dev
, " dump reset stats\n");
1726 dev_info(&pf
->pdev
->dev
, " dump debug fwdata <cluster_id> <table_id> <index>\n");
1727 dev_info(&pf
->pdev
->dev
, " msg_enable [level]\n");
1728 dev_info(&pf
->pdev
->dev
, " read <reg>\n");
1729 dev_info(&pf
->pdev
->dev
, " write <reg> <value>\n");
1730 dev_info(&pf
->pdev
->dev
, " clear_stats vsi [seid]\n");
1731 dev_info(&pf
->pdev
->dev
, " clear_stats port\n");
1732 dev_info(&pf
->pdev
->dev
, " pfr\n");
1733 dev_info(&pf
->pdev
->dev
, " corer\n");
1734 dev_info(&pf
->pdev
->dev
, " globr\n");
1735 dev_info(&pf
->pdev
->dev
, " send aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3>\n");
1736 dev_info(&pf
->pdev
->dev
, " send indirect aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3> <buffer_len>\n");
1737 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");
1738 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");
1739 dev_info(&pf
->pdev
->dev
, " fd current cnt");
1740 dev_info(&pf
->pdev
->dev
, " lldp start\n");
1741 dev_info(&pf
->pdev
->dev
, " lldp stop\n");
1742 dev_info(&pf
->pdev
->dev
, " lldp get local\n");
1743 dev_info(&pf
->pdev
->dev
, " lldp get remote\n");
1744 dev_info(&pf
->pdev
->dev
, " lldp event on\n");
1745 dev_info(&pf
->pdev
->dev
, " lldp event off\n");
1746 dev_info(&pf
->pdev
->dev
, " nvm read [module] [word_offset] [word_count]\n");
1755 static const struct file_operations i40e_dbg_command_fops
= {
1756 .owner
= THIS_MODULE
,
1757 .open
= simple_open
,
1758 .read
= i40e_dbg_command_read
,
1759 .write
= i40e_dbg_command_write
,
1762 /**************************************************************
1764 * The netdev_ops entry in debugfs is for giving the driver commands
1765 * to be executed from the netdev operations.
1766 **************************************************************/
1767 static char i40e_dbg_netdev_ops_buf
[256] = "";
1770 * i40e_dbg_netdev_ops - read for netdev_ops datum
1771 * @filp: the opened file
1772 * @buffer: where to write the data for the user to read
1773 * @count: the size of the user's buffer
1774 * @ppos: file position offset
1776 static ssize_t
i40e_dbg_netdev_ops_read(struct file
*filp
, char __user
*buffer
,
1777 size_t count
, loff_t
*ppos
)
1779 struct i40e_pf
*pf
= filp
->private_data
;
1780 int bytes_not_copied
;
1785 /* don't allow partal reads */
1788 if (count
< buf_size
)
1791 buf
= kzalloc(buf_size
, GFP_KERNEL
);
1795 len
= snprintf(buf
, buf_size
, "%s: %s\n",
1796 pf
->vsi
[pf
->lan_vsi
]->netdev
->name
,
1797 i40e_dbg_netdev_ops_buf
);
1799 bytes_not_copied
= copy_to_user(buffer
, buf
, len
);
1802 if (bytes_not_copied
)
1810 * i40e_dbg_netdev_ops_write - write into netdev_ops datum
1811 * @filp: the opened file
1812 * @buffer: where to find the user's data
1813 * @count: the length of the user's data
1814 * @ppos: file position offset
1816 static ssize_t
i40e_dbg_netdev_ops_write(struct file
*filp
,
1817 const char __user
*buffer
,
1818 size_t count
, loff_t
*ppos
)
1820 struct i40e_pf
*pf
= filp
->private_data
;
1821 int bytes_not_copied
;
1822 struct i40e_vsi
*vsi
;
1827 /* don't allow partial writes */
1830 if (count
>= sizeof(i40e_dbg_netdev_ops_buf
))
1833 memset(i40e_dbg_netdev_ops_buf
, 0, sizeof(i40e_dbg_netdev_ops_buf
));
1834 bytes_not_copied
= copy_from_user(i40e_dbg_netdev_ops_buf
,
1836 if (bytes_not_copied
)
1838 i40e_dbg_netdev_ops_buf
[count
] = '\0';
1840 buf_tmp
= strchr(i40e_dbg_netdev_ops_buf
, '\n');
1843 count
= buf_tmp
- i40e_dbg_netdev_ops_buf
+ 1;
1846 if (strncmp(i40e_dbg_netdev_ops_buf
, "tx_timeout", 10) == 0) {
1847 cnt
= sscanf(&i40e_dbg_netdev_ops_buf
[11], "%i", &vsi_seid
);
1849 dev_info(&pf
->pdev
->dev
, "tx_timeout <vsi_seid>\n");
1850 goto netdev_ops_write_done
;
1852 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1854 dev_info(&pf
->pdev
->dev
,
1855 "tx_timeout: VSI %d not found\n", vsi_seid
);
1856 } else if (!vsi
->netdev
) {
1857 dev_info(&pf
->pdev
->dev
, "tx_timeout: no netdev for VSI %d\n",
1859 } else if (test_bit(__I40E_DOWN
, &vsi
->state
)) {
1860 dev_info(&pf
->pdev
->dev
, "tx_timeout: VSI %d not UP\n",
1862 } else if (rtnl_trylock()) {
1863 vsi
->netdev
->netdev_ops
->ndo_tx_timeout(vsi
->netdev
);
1865 dev_info(&pf
->pdev
->dev
, "tx_timeout called\n");
1867 dev_info(&pf
->pdev
->dev
, "Could not acquire RTNL - please try again\n");
1869 } else if (strncmp(i40e_dbg_netdev_ops_buf
, "change_mtu", 10) == 0) {
1872 cnt
= sscanf(&i40e_dbg_netdev_ops_buf
[11], "%i %i",
1875 dev_info(&pf
->pdev
->dev
, "change_mtu <vsi_seid> <mtu>\n");
1876 goto netdev_ops_write_done
;
1878 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1880 dev_info(&pf
->pdev
->dev
,
1881 "change_mtu: VSI %d not found\n", vsi_seid
);
1882 } else if (!vsi
->netdev
) {
1883 dev_info(&pf
->pdev
->dev
, "change_mtu: no netdev for VSI %d\n",
1885 } else if (rtnl_trylock()) {
1886 vsi
->netdev
->netdev_ops
->ndo_change_mtu(vsi
->netdev
,
1889 dev_info(&pf
->pdev
->dev
, "change_mtu called\n");
1891 dev_info(&pf
->pdev
->dev
, "Could not acquire RTNL - please try again\n");
1894 } else if (strncmp(i40e_dbg_netdev_ops_buf
, "set_rx_mode", 11) == 0) {
1895 cnt
= sscanf(&i40e_dbg_netdev_ops_buf
[11], "%i", &vsi_seid
);
1897 dev_info(&pf
->pdev
->dev
, "set_rx_mode <vsi_seid>\n");
1898 goto netdev_ops_write_done
;
1900 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1902 dev_info(&pf
->pdev
->dev
,
1903 "set_rx_mode: VSI %d not found\n", vsi_seid
);
1904 } else if (!vsi
->netdev
) {
1905 dev_info(&pf
->pdev
->dev
, "set_rx_mode: no netdev for VSI %d\n",
1907 } else if (rtnl_trylock()) {
1908 vsi
->netdev
->netdev_ops
->ndo_set_rx_mode(vsi
->netdev
);
1910 dev_info(&pf
->pdev
->dev
, "set_rx_mode called\n");
1912 dev_info(&pf
->pdev
->dev
, "Could not acquire RTNL - please try again\n");
1915 } else if (strncmp(i40e_dbg_netdev_ops_buf
, "napi", 4) == 0) {
1916 cnt
= sscanf(&i40e_dbg_netdev_ops_buf
[4], "%i", &vsi_seid
);
1918 dev_info(&pf
->pdev
->dev
, "napi <vsi_seid>\n");
1919 goto netdev_ops_write_done
;
1921 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1923 dev_info(&pf
->pdev
->dev
, "napi: VSI %d not found\n",
1925 } else if (!vsi
->netdev
) {
1926 dev_info(&pf
->pdev
->dev
, "napi: no netdev for VSI %d\n",
1929 for (i
= 0; i
< vsi
->num_q_vectors
; i
++)
1930 napi_schedule(&vsi
->q_vectors
[i
]->napi
);
1931 dev_info(&pf
->pdev
->dev
, "napi called\n");
1934 dev_info(&pf
->pdev
->dev
, "unknown command '%s'\n",
1935 i40e_dbg_netdev_ops_buf
);
1936 dev_info(&pf
->pdev
->dev
, "available commands\n");
1937 dev_info(&pf
->pdev
->dev
, " tx_timeout <vsi_seid>\n");
1938 dev_info(&pf
->pdev
->dev
, " change_mtu <vsi_seid> <mtu>\n");
1939 dev_info(&pf
->pdev
->dev
, " set_rx_mode <vsi_seid>\n");
1940 dev_info(&pf
->pdev
->dev
, " napi <vsi_seid>\n");
1942 netdev_ops_write_done
:
1946 static const struct file_operations i40e_dbg_netdev_ops_fops
= {
1947 .owner
= THIS_MODULE
,
1948 .open
= simple_open
,
1949 .read
= i40e_dbg_netdev_ops_read
,
1950 .write
= i40e_dbg_netdev_ops_write
,
1954 * i40e_dbg_pf_init - setup the debugfs directory for the PF
1955 * @pf: the PF that is starting up
1957 void i40e_dbg_pf_init(struct i40e_pf
*pf
)
1959 struct dentry
*pfile
;
1960 const char *name
= pci_name(pf
->pdev
);
1961 const struct device
*dev
= &pf
->pdev
->dev
;
1963 pf
->i40e_dbg_pf
= debugfs_create_dir(name
, i40e_dbg_root
);
1964 if (!pf
->i40e_dbg_pf
)
1967 pfile
= debugfs_create_file("command", 0600, pf
->i40e_dbg_pf
, pf
,
1968 &i40e_dbg_command_fops
);
1972 pfile
= debugfs_create_file("netdev_ops", 0600, pf
->i40e_dbg_pf
, pf
,
1973 &i40e_dbg_netdev_ops_fops
);
1980 dev_info(dev
, "debugfs dir/file for %s failed\n", name
);
1981 debugfs_remove_recursive(pf
->i40e_dbg_pf
);
1985 * i40e_dbg_pf_exit - clear out the PF's debugfs entries
1986 * @pf: the PF that is stopping
1988 void i40e_dbg_pf_exit(struct i40e_pf
*pf
)
1990 debugfs_remove_recursive(pf
->i40e_dbg_pf
);
1991 pf
->i40e_dbg_pf
= NULL
;
1995 * i40e_dbg_init - start up debugfs for the driver
1997 void i40e_dbg_init(void)
1999 i40e_dbg_root
= debugfs_create_dir(i40e_driver_name
, NULL
);
2001 pr_info("init of debugfs failed\n");
2005 * i40e_dbg_exit - clean out the driver's debugfs entries
2007 void i40e_dbg_exit(void)
2009 debugfs_remove_recursive(i40e_dbg_root
);
2010 i40e_dbg_root
= NULL
;
2013 #endif /* CONFIG_DEBUG_FS */