-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ice: Add code for DCB initialization part 1/4
This patch introduces a skeleton for ice_init_pf_dcb, the top level function for DCB initialization. Subsequent patches will add to this DCB init flow. In this patch, ice_init_pf_dcb checks if DCB is a supported capability. If so, an admin queue call to start the LLDP and DCBx in firmware is issued. If not, an error is reported. Note that we don't fail the driver init if DCB init fails. Reviewed-by: Bruce Allan <bruce.w.allan@intel.com> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
- Loading branch information
Anirudh Venkataramanan
authored and
Jeff Kirsher
committed
Apr 18, 2019
1 parent
802abbb
commit 37b6f64
Showing
10 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) 2019, Intel Corporation. */ | ||
|
||
#include "ice_common.h" | ||
#include "ice_sched.h" | ||
#include "ice_dcb.h" | ||
|
||
/** | ||
* ice_aq_start_lldp | ||
* @hw: pointer to the HW struct | ||
* @cd: pointer to command details structure or NULL | ||
* | ||
* Start the embedded LLDP Agent on all ports. (0x0A06) | ||
*/ | ||
enum ice_status ice_aq_start_lldp(struct ice_hw *hw, struct ice_sq_cd *cd) | ||
{ | ||
struct ice_aqc_lldp_start *cmd; | ||
struct ice_aq_desc desc; | ||
|
||
cmd = &desc.params.lldp_start; | ||
|
||
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_start); | ||
|
||
cmd->command = ICE_AQ_LLDP_AGENT_START; | ||
|
||
return ice_aq_send_cmd(hw, &desc, NULL, 0, cd); | ||
} | ||
|
||
/** | ||
* ice_get_dcbx_status | ||
* @hw: pointer to the HW struct | ||
* | ||
* Get the DCBX status from the Firmware | ||
*/ | ||
u8 ice_get_dcbx_status(struct ice_hw *hw) | ||
{ | ||
u32 reg; | ||
|
||
reg = rd32(hw, PRTDCB_GENS); | ||
return (u8)((reg & PRTDCB_GENS_DCBX_STATUS_M) >> | ||
PRTDCB_GENS_DCBX_STATUS_S); | ||
} | ||
|
||
/** | ||
* ice_aq_start_stop_dcbx - Start/Stop DCBx service in FW | ||
* @hw: pointer to the HW struct | ||
* @start_dcbx_agent: True if DCBx Agent needs to be started | ||
* False if DCBx Agent needs to be stopped | ||
* @dcbx_agent_status: FW indicates back the DCBx agent status | ||
* True if DCBx Agent is active | ||
* False if DCBx Agent is stopped | ||
* @cd: pointer to command details structure or NULL | ||
* | ||
* Start/Stop the embedded dcbx Agent. In case that this wrapper function | ||
* returns ICE_SUCCESS, caller will need to check if FW returns back the same | ||
* value as stated in dcbx_agent_status, and react accordingly. (0x0A09) | ||
*/ | ||
enum ice_status | ||
ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent, | ||
bool *dcbx_agent_status, struct ice_sq_cd *cd) | ||
{ | ||
struct ice_aqc_lldp_stop_start_specific_agent *cmd; | ||
enum ice_status status; | ||
struct ice_aq_desc desc; | ||
u16 opcode; | ||
|
||
cmd = &desc.params.lldp_agent_ctrl; | ||
|
||
opcode = ice_aqc_opc_lldp_stop_start_specific_agent; | ||
|
||
ice_fill_dflt_direct_cmd_desc(&desc, opcode); | ||
|
||
if (start_dcbx_agent) | ||
cmd->command = ICE_AQC_START_STOP_AGENT_START_DCBX; | ||
|
||
status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd); | ||
|
||
*dcbx_agent_status = false; | ||
|
||
if (!status && | ||
cmd->command == ICE_AQC_START_STOP_AGENT_START_DCBX) | ||
*dcbx_agent_status = true; | ||
|
||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (c) 2019, Intel Corporation. */ | ||
|
||
#ifndef _ICE_DCB_H_ | ||
#define _ICE_DCB_H_ | ||
|
||
#include "ice_type.h" | ||
|
||
#define ICE_DCBX_STATUS_IN_PROGRESS 1 | ||
#define ICE_DCBX_STATUS_DONE 2 | ||
|
||
u8 ice_get_dcbx_status(struct ice_hw *hw); | ||
#ifdef CONFIG_DCB | ||
enum ice_status ice_aq_start_lldp(struct ice_hw *hw, struct ice_sq_cd *cd); | ||
enum ice_status | ||
ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent, | ||
bool *dcbx_agent_status, struct ice_sq_cd *cd); | ||
#else /* CONFIG_DCB */ | ||
static inline enum ice_status | ||
ice_aq_start_lldp(struct ice_hw __always_unused *hw, | ||
struct ice_sq_cd __always_unused *cd) | ||
{ | ||
return 0; | ||
} | ||
|
||
static inline enum ice_status | ||
ice_aq_start_stop_dcbx(struct ice_hw __always_unused *hw, | ||
bool __always_unused start_dcbx_agent, | ||
bool *dcbx_agent_status, | ||
struct ice_sq_cd __always_unused *cd) | ||
{ | ||
*dcbx_agent_status = false; | ||
|
||
return 0; | ||
} | ||
#endif /* CONFIG_DCB */ | ||
#endif /* _ICE_DCB_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) 2019, Intel Corporation. */ | ||
|
||
#include "ice_dcb_lib.h" | ||
|
||
/** | ||
* ice_init_pf_dcb - initialize DCB for a PF | ||
* @pf: pf to initiialize DCB for | ||
*/ | ||
int ice_init_pf_dcb(struct ice_pf *pf) | ||
{ | ||
struct device *dev = &pf->pdev->dev; | ||
struct ice_port_info *port_info; | ||
struct ice_hw *hw = &pf->hw; | ||
|
||
port_info = hw->port_info; | ||
|
||
/* check if device is DCB capable */ | ||
if (!hw->func_caps.common_cap.dcb) { | ||
dev_dbg(dev, "DCB not supported\n"); | ||
return -EOPNOTSUPP; | ||
} | ||
|
||
/* Best effort to put DCBx and LLDP into a good state */ | ||
port_info->dcbx_status = ice_get_dcbx_status(hw); | ||
if (port_info->dcbx_status != ICE_DCBX_STATUS_DONE && | ||
port_info->dcbx_status != ICE_DCBX_STATUS_IN_PROGRESS) { | ||
bool dcbx_status; | ||
|
||
/* Attempt to start LLDP engine. Ignore errors | ||
* as this will error if it is already started | ||
*/ | ||
ice_aq_start_lldp(hw, NULL); | ||
|
||
/* Attempt to start DCBX. Ignore errors as this | ||
* will error if it is already started | ||
*/ | ||
ice_aq_start_stop_dcbx(hw, true, &dcbx_status, NULL); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (c) 2019, Intel Corporation. */ | ||
|
||
#ifndef _ICE_DCB_LIB_H_ | ||
#define _ICE_DCB_LIB_H_ | ||
|
||
#include "ice.h" | ||
#include "ice_lib.h" | ||
|
||
#ifdef CONFIG_DCB | ||
int ice_init_pf_dcb(struct ice_pf *pf); | ||
#else | ||
static inline int ice_init_pf_dcb(struct ice_pf *pf) | ||
{ | ||
dev_dbg(&pf->pdev->dev, "DCB not supported\n"); | ||
return -EOPNOTSUPP; | ||
} | ||
#endif /* CONFIG_DCB */ | ||
#endif /* _ICE_DCB_LIB_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters