Skip to content

Commit

Permalink
ixgbe: refactor common start_hw code for 82599 and x540
Browse files Browse the repository at this point in the history
Factored out the common start_hw code into a new function
ixgbe_start_hw_gen2() so that it can be used by x540 and 82599.

Signed-off-by: Emil Tantilov <[email protected]>
Acked-by: Don Skidmore <[email protected]>
Tested-by: Evan Swanson <[email protected]>
Signed-off-by: Jeff Kirsher <[email protected]>
  • Loading branch information
etantilov authored and Jeff Kirsher committed Apr 14, 2011
1 parent 75e3d3c commit 7184b7c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
22 changes: 10 additions & 12 deletions drivers/net/ixgbe/ixgbe_82599.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,30 +1740,28 @@ static s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val)
* ixgbe_start_hw_82599 - Prepare hardware for Tx/Rx
* @hw: pointer to hardware structure
*
* Starts the hardware using the generic start_hw function.
* Then performs device-specific:
* Clears the rate limiter registers.
* Starts the hardware using the generic start_hw function
* and the generation start_hw function.
* Then performs revision-specific operations, if any.
**/
static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
{
u32 q_num;
s32 ret_val;
s32 ret_val = 0;

ret_val = ixgbe_start_hw_generic(hw);
if (ret_val != 0)
goto out;

/* Clear the rate limiters */
for (q_num = 0; q_num < hw->mac.max_tx_queues; q_num++) {
IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, q_num);
IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, 0);
}
IXGBE_WRITE_FLUSH(hw);
ret_val = ixgbe_start_hw_gen2(hw);
if (ret_val != 0)
goto out;

/* We need to run link autotry after the driver loads */
hw->mac.autotry_restart = true;

if (ret_val == 0)
ret_val = ixgbe_verify_fw_version_82599(hw);

out:
return ret_val;
}

Expand Down
24 changes: 24 additions & 0 deletions drivers/net/ixgbe/ixgbe_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
return 0;
}

/**
* ixgbe_start_hw_gen2 - Init sequence for common device family
* @hw: pointer to hw structure
*
* Performs the init sequence common to the second generation
* of 10 GbE devices.
* Devices in the second generation:
* 82599
* X540
**/
s32 ixgbe_start_hw_gen2(struct ixgbe_hw *hw)
{
u32 i;

/* Clear the rate limiters */
for (i = 0; i < hw->mac.max_tx_queues; i++) {
IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, i);
IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, 0);
}
IXGBE_WRITE_FLUSH(hw);

return 0;
}

/**
* ixgbe_init_hw_generic - Generic hardware initialization
* @hw: pointer to hardware structure
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ixgbe/ixgbe_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ u32 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw);
s32 ixgbe_init_ops_generic(struct ixgbe_hw *hw);
s32 ixgbe_init_hw_generic(struct ixgbe_hw *hw);
s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw);
s32 ixgbe_start_hw_gen2(struct ixgbe_hw *hw);
s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw);
s32 ixgbe_read_pba_string_generic(struct ixgbe_hw *hw, u8 *pba_num,
u32 pba_num_size);
Expand Down
24 changes: 23 additions & 1 deletion drivers/net/ixgbe/ixgbe_x540.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,28 @@ static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw)
return status;
}

/**
* ixgbe_start_hw_X540 - Prepare hardware for Tx/Rx
* @hw: pointer to hardware structure
*
* Starts the hardware using the generic start_hw function
* and the generation start_hw function.
* Then performs revision-specific operations, if any.
**/
static s32 ixgbe_start_hw_X540(struct ixgbe_hw *hw)
{
s32 ret_val = 0;

ret_val = ixgbe_start_hw_generic(hw);
if (ret_val != 0)
goto out;

ret_val = ixgbe_start_hw_gen2(hw);

out:
return ret_val;
}

/**
* ixgbe_get_supported_physical_layer_X540 - Returns physical layer type
* @hw: pointer to hardware structure
Expand Down Expand Up @@ -660,7 +682,7 @@ static void ixgbe_release_swfw_sync_semaphore(struct ixgbe_hw *hw)
static struct ixgbe_mac_operations mac_ops_X540 = {
.init_hw = &ixgbe_init_hw_generic,
.reset_hw = &ixgbe_reset_hw_X540,
.start_hw = &ixgbe_start_hw_generic,
.start_hw = &ixgbe_start_hw_X540,
.clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
.get_media_type = &ixgbe_get_media_type_X540,
.get_supported_physical_layer =
Expand Down

0 comments on commit 7184b7c

Please sign in to comment.