Deleted Added
full compact
e1000_manage.c (205869) e1000_manage.c (218530)
1/******************************************************************************
2
3 Copyright (c) 2001-2010, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8

--- 16 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
1/******************************************************************************
2
3 Copyright (c) 2001-2010, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8

--- 16 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
33/*$FreeBSD: head/sys/dev/e1000/e1000_manage.c 205869 2010-03-29 23:36:34Z jfv $*/
33/*$FreeBSD: head/sys/dev/e1000/e1000_manage.c 218530 2011-02-11 01:00:26Z jfv $*/
34
35#include "e1000_api.h"
36
34
35#include "e1000_api.h"
36
37static u8 e1000_calculate_checksum(u8 *buffer, u32 length);
38
39/**
40 * e1000_calculate_checksum - Calculate checksum for buffer
41 * @buffer: pointer to EEPROM
42 * @length: size of EEPROM to calculate a checksum for
43 *
44 * Calculates the checksum for some buffer on a specified length. The
45 * checksum calculated is returned.
46 **/
37/**
38 * e1000_calculate_checksum - Calculate checksum for buffer
39 * @buffer: pointer to EEPROM
40 * @length: size of EEPROM to calculate a checksum for
41 *
42 * Calculates the checksum for some buffer on a specified length. The
43 * checksum calculated is returned.
44 **/
47static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
45u8 e1000_calculate_checksum(u8 *buffer, u32 length)
48{
49 u32 i;
46{
47 u32 i;
50 u8 sum = 0;
48 u8 sum = 0;
51
52 DEBUGFUNC("e1000_calculate_checksum");
53
54 if (!buffer)
55 return 0;
56
57 for (i = 0; i < length; i++)
58 sum += buffer[i];

--- 340 unchanged lines hidden (view full) ---

399 ret_val = TRUE;
400 goto out;
401 }
402
403out:
404 return ret_val;
405}
406
49
50 DEBUGFUNC("e1000_calculate_checksum");
51
52 if (!buffer)
53 return 0;
54
55 for (i = 0; i < length; i++)
56 sum += buffer[i];

--- 340 unchanged lines hidden (view full) ---

397 ret_val = TRUE;
398 goto out;
399 }
400
401out:
402 return ret_val;
403}
404
405/**
406 * e1000_host_interface_command - Writes buffer to host interface
407 * @hw: pointer to the HW structure
408 * @buffer: contains a command to write
409 * @length: the byte length of the buffer, must be multiple of 4 bytes
410 *
411 * Writes a buffer to the Host Interface. Upon success, returns E1000_SUCCESS
412 * else returns E1000_ERR_HOST_INTERFACE_COMMAND.
413 **/
414s32 e1000_host_interface_command(struct e1000_hw *hw, u8 *buffer, u32 length)
415{
416 u32 hicr, i;
417 s32 ret_val = E1000_SUCCESS;
418
419 DEBUGFUNC("e1000_host_interface_command");
420
421 if (!(hw->mac.arc_subsystem_valid)) {
422 DEBUGOUT("Hardware doesn't support host interface command.\n");
423 goto out;
424 }
425
426 if (!hw->mac.asf_firmware_present) {
427 DEBUGOUT("Firmware is not present.\n");
428 goto out;
429 }
430
431 if (length == 0 || length & 0x3 ||
432 length > E1000_HI_MAX_BLOCK_BYTE_LENGTH) {
433 DEBUGOUT("Buffer length failure.\n");
434 ret_val = -E1000_ERR_HOST_INTERFACE_COMMAND;
435 goto out;
436 }
437
438 /* Check that the host interface is enabled. */
439 hicr = E1000_READ_REG(hw, E1000_HICR);
440 if ((hicr & E1000_HICR_EN) == 0) {
441 DEBUGOUT("E1000_HOST_EN bit disabled.\n");
442 ret_val = -E1000_ERR_HOST_INTERFACE_COMMAND;
443 goto out;
444 }
445
446 /* Calculate length in DWORDs */
447 length >>= 2;
448
449 /*
450 * The device driver writes the relevant command block
451 * into the ram area.
452 */
453 for (i = 0; i < length; i++)
454 E1000_WRITE_REG_ARRAY_DWORD(hw,
455 E1000_HOST_IF,
456 i,
457 *((u32 *)buffer + i));
458
459 /* Setting this bit tells the ARC that a new command is pending. */
460 E1000_WRITE_REG(hw, E1000_HICR, hicr | E1000_HICR_C);
461
462 for (i = 0; i < E1000_HI_COMMAND_TIMEOUT; i++) {
463 hicr = E1000_READ_REG(hw, E1000_HICR);
464 if (!(hicr & E1000_HICR_C))
465 break;
466 msec_delay(1);
467 }
468
469 /* Check command successful completion. */
470 if (i == E1000_HI_COMMAND_TIMEOUT ||
471 (!(E1000_READ_REG(hw, E1000_HICR) & E1000_HICR_SV))) {
472 DEBUGOUT("Command has failed with no status valid.\n");
473 ret_val = -E1000_ERR_HOST_INTERFACE_COMMAND;
474 goto out;
475 }
476
477 for (i = 0; i < length; i++)
478 *((u32 *)buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw,
479 E1000_HOST_IF,
480 i);
481
482out:
483 return ret_val;
484}
485