.. | .. |
---|
322 | 322 | } |
---|
323 | 323 | |
---|
324 | 324 | /** |
---|
| 325 | + * i40e_read_nvm_module_data - Reads NVM Buffer to specified memory location |
---|
| 326 | + * @hw: Pointer to the HW structure |
---|
| 327 | + * @module_ptr: Pointer to module in words with respect to NVM beginning |
---|
| 328 | + * @module_offset: Offset in words from module start |
---|
| 329 | + * @data_offset: Offset in words from reading data area start |
---|
| 330 | + * @words_data_size: Words to read from NVM |
---|
| 331 | + * @data_ptr: Pointer to memory location where resulting buffer will be stored |
---|
| 332 | + **/ |
---|
| 333 | +enum i40e_status_code i40e_read_nvm_module_data(struct i40e_hw *hw, |
---|
| 334 | + u8 module_ptr, |
---|
| 335 | + u16 module_offset, |
---|
| 336 | + u16 data_offset, |
---|
| 337 | + u16 words_data_size, |
---|
| 338 | + u16 *data_ptr) |
---|
| 339 | +{ |
---|
| 340 | + i40e_status status; |
---|
| 341 | + u16 specific_ptr = 0; |
---|
| 342 | + u16 ptr_value = 0; |
---|
| 343 | + u32 offset = 0; |
---|
| 344 | + |
---|
| 345 | + if (module_ptr != 0) { |
---|
| 346 | + status = i40e_read_nvm_word(hw, module_ptr, &ptr_value); |
---|
| 347 | + if (status) { |
---|
| 348 | + i40e_debug(hw, I40E_DEBUG_ALL, |
---|
| 349 | + "Reading nvm word failed.Error code: %d.\n", |
---|
| 350 | + status); |
---|
| 351 | + return I40E_ERR_NVM; |
---|
| 352 | + } |
---|
| 353 | + } |
---|
| 354 | +#define I40E_NVM_INVALID_PTR_VAL 0x7FFF |
---|
| 355 | +#define I40E_NVM_INVALID_VAL 0xFFFF |
---|
| 356 | + |
---|
| 357 | + /* Pointer not initialized */ |
---|
| 358 | + if (ptr_value == I40E_NVM_INVALID_PTR_VAL || |
---|
| 359 | + ptr_value == I40E_NVM_INVALID_VAL) { |
---|
| 360 | + i40e_debug(hw, I40E_DEBUG_ALL, "Pointer not initialized.\n"); |
---|
| 361 | + return I40E_ERR_BAD_PTR; |
---|
| 362 | + } |
---|
| 363 | + |
---|
| 364 | + /* Check whether the module is in SR mapped area or outside */ |
---|
| 365 | + if (ptr_value & I40E_PTR_TYPE) { |
---|
| 366 | + /* Pointer points outside of the Shared RAM mapped area */ |
---|
| 367 | + i40e_debug(hw, I40E_DEBUG_ALL, |
---|
| 368 | + "Reading nvm data failed. Pointer points outside of the Shared RAM mapped area.\n"); |
---|
| 369 | + |
---|
| 370 | + return I40E_ERR_PARAM; |
---|
| 371 | + } else { |
---|
| 372 | + /* Read from the Shadow RAM */ |
---|
| 373 | + |
---|
| 374 | + status = i40e_read_nvm_word(hw, ptr_value + module_offset, |
---|
| 375 | + &specific_ptr); |
---|
| 376 | + if (status) { |
---|
| 377 | + i40e_debug(hw, I40E_DEBUG_ALL, |
---|
| 378 | + "Reading nvm word failed.Error code: %d.\n", |
---|
| 379 | + status); |
---|
| 380 | + return I40E_ERR_NVM; |
---|
| 381 | + } |
---|
| 382 | + |
---|
| 383 | + offset = ptr_value + module_offset + specific_ptr + |
---|
| 384 | + data_offset; |
---|
| 385 | + |
---|
| 386 | + status = i40e_read_nvm_buffer(hw, offset, &words_data_size, |
---|
| 387 | + data_ptr); |
---|
| 388 | + if (status) { |
---|
| 389 | + i40e_debug(hw, I40E_DEBUG_ALL, |
---|
| 390 | + "Reading nvm buffer failed.Error code: %d.\n", |
---|
| 391 | + status); |
---|
| 392 | + } |
---|
| 393 | + } |
---|
| 394 | + |
---|
| 395 | + return status; |
---|
| 396 | +} |
---|
| 397 | + |
---|
| 398 | +/** |
---|
325 | 399 | * i40e_read_nvm_buffer_srctl - Reads Shadow RAM buffer via SRCTL register |
---|
326 | 400 | * @hw: pointer to the HW structure |
---|
327 | 401 | * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF). |
---|
.. | .. |
---|
427 | 501 | return i40e_read_nvm_buffer_aq(hw, offset, words, data); |
---|
428 | 502 | |
---|
429 | 503 | return i40e_read_nvm_buffer_srctl(hw, offset, words, data); |
---|
| 504 | +} |
---|
| 505 | + |
---|
| 506 | +/** |
---|
| 507 | + * i40e_read_nvm_buffer - Reads Shadow RAM buffer and acquire lock if necessary |
---|
| 508 | + * @hw: pointer to the HW structure |
---|
| 509 | + * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF). |
---|
| 510 | + * @words: (in) number of words to read; (out) number of words actually read |
---|
| 511 | + * @data: words read from the Shadow RAM |
---|
| 512 | + * |
---|
| 513 | + * Reads 16 bit words (data buffer) from the SR using the i40e_read_nvm_srrd() |
---|
| 514 | + * method. The buffer read is preceded by the NVM ownership take |
---|
| 515 | + * and followed by the release. |
---|
| 516 | + **/ |
---|
| 517 | +i40e_status i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset, |
---|
| 518 | + u16 *words, u16 *data) |
---|
| 519 | +{ |
---|
| 520 | + i40e_status ret_code = 0; |
---|
| 521 | + |
---|
| 522 | + if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) { |
---|
| 523 | + ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); |
---|
| 524 | + if (!ret_code) { |
---|
| 525 | + ret_code = i40e_read_nvm_buffer_aq(hw, offset, words, |
---|
| 526 | + data); |
---|
| 527 | + i40e_release_nvm(hw); |
---|
| 528 | + } |
---|
| 529 | + } else { |
---|
| 530 | + ret_code = i40e_read_nvm_buffer_srctl(hw, offset, words, data); |
---|
| 531 | + } |
---|
| 532 | + |
---|
| 533 | + return ret_code; |
---|
430 | 534 | } |
---|
431 | 535 | |
---|
432 | 536 | /** |
---|
.. | .. |
---|
578 | 682 | __le16 le_sum; |
---|
579 | 683 | |
---|
580 | 684 | ret_code = i40e_calc_nvm_checksum(hw, &checksum); |
---|
581 | | - if (!ret_code) { |
---|
582 | | - le_sum = cpu_to_le16(checksum); |
---|
| 685 | + le_sum = cpu_to_le16(checksum); |
---|
| 686 | + if (!ret_code) |
---|
583 | 687 | ret_code = i40e_write_nvm_aq(hw, 0x00, I40E_SR_SW_CHECKSUM_WORD, |
---|
584 | 688 | 1, &le_sum, true); |
---|
585 | | - } |
---|
586 | 689 | |
---|
587 | 690 | return ret_code; |
---|
588 | 691 | } |
---|