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