提交 5e3d3189 编写于 作者: D David S. Miller

Merge branch 'be2net-next'

Sathya Perla says:

====================
be2net: patch set

Hi Dave, the following patch set reduces code duplication
in probe/pci-resume/eeh-resume and remove/pci-suspend/eeh-error and UE-error
detect/recovery paths. New helper routines have been introduced for this
purpose. Pls apply this set to the net-next tree. Thanks!

Patch 1 refactors the alloc/free code of adapter struct's fields into
a new set of helper routines -- be_drv_init/cleanup().

Patch 2 gets rid of the be_get_initial_config() routine as be_get_config()
is the place holder for related code.

Patch 3 introduces a new helper routine be_func_init() to execute the
initialization code used in probe/pci-resume/eeh-resume to remove
code duplication.

Patch 4 introduces a wrapper for scheduling/canceling error detection
task on similar lines to the be_worker task.

Patch 5 refactors UE error detection and recovery code on similar lines
to EEH code. Cleaning up resources is done in the error detection routine
followed by error recovery.

Patch 6 gets rid of the lancer_test_and_set_rdy_state() routine as the
same code now available in be_func_init().

Patch 7 creates a new helper routine be_resume() for all the common code
in be_probe(), be_pci_resume() and be_eeh_resume(), to reduce code duplication.

Patch 8 creates a new helper routine be_cleanup() for all the common
cleanup code duplicated in the suspend/EEH err detection paths.

Patch 9 moves be_func_init() inside be_setup() as everytime be_setup()
is called, the driver will have to wait for the function/FW to be be
initialized.
====================
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
......@@ -376,6 +376,7 @@ enum vf_state {
#define BE_FLAGS_VXLAN_OFFLOADS BIT(8)
#define BE_FLAGS_SETUP_DONE BIT(9)
#define BE_FLAGS_EVT_INCOMPATIBLE_SFP BIT(10)
#define BE_FLAGS_ERR_DETECTION_SCHEDULED BIT(11)
#define BE_UC_PMAC_COUNT 30
#define BE_VF_UC_PMAC_COUNT 2
......@@ -501,7 +502,7 @@ struct be_adapter {
struct delayed_work work;
u16 work_counter;
struct delayed_work func_recovery_work;
struct delayed_work be_err_detection_work;
u32 flags;
u32 cmd_privileges;
/* Ethtool knobs and info */
......
......@@ -635,73 +635,16 @@ static int lancer_wait_ready(struct be_adapter *adapter)
for (i = 0; i < SLIPORT_READY_TIMEOUT; i++) {
sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET);
if (sliport_status & SLIPORT_STATUS_RDY_MASK)
break;
msleep(1000);
}
if (i == SLIPORT_READY_TIMEOUT)
return sliport_status ? : -1;
return 0;
}
static bool lancer_provisioning_error(struct be_adapter *adapter)
{
u32 sliport_status = 0, sliport_err1 = 0, sliport_err2 = 0;
sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET);
if (sliport_status & SLIPORT_STATUS_ERR_MASK) {
sliport_err1 = ioread32(adapter->db + SLIPORT_ERROR1_OFFSET);
sliport_err2 = ioread32(adapter->db + SLIPORT_ERROR2_OFFSET);
if (sliport_err1 == SLIPORT_ERROR_NO_RESOURCE1 &&
sliport_err2 == SLIPORT_ERROR_NO_RESOURCE2)
return true;
}
return false;
}
int lancer_test_and_set_rdy_state(struct be_adapter *adapter)
{
int status;
u32 sliport_status, err, reset_needed;
bool resource_error;
return 0;
resource_error = lancer_provisioning_error(adapter);
if (resource_error)
return -EAGAIN;
if (sliport_status & SLIPORT_STATUS_ERR_MASK &&
!(sliport_status & SLIPORT_STATUS_RN_MASK))
return -EIO;
status = lancer_wait_ready(adapter);
if (!status) {
sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET);
err = sliport_status & SLIPORT_STATUS_ERR_MASK;
reset_needed = sliport_status & SLIPORT_STATUS_RN_MASK;
if (err && reset_needed) {
iowrite32(SLI_PORT_CONTROL_IP_MASK,
adapter->db + SLIPORT_CONTROL_OFFSET);
/* check if adapter has corrected the error */
status = lancer_wait_ready(adapter);
sliport_status = ioread32(adapter->db +
SLIPORT_STATUS_OFFSET);
sliport_status &= (SLIPORT_STATUS_ERR_MASK |
SLIPORT_STATUS_RN_MASK);
if (status || sliport_status)
status = -1;
} else if (err || reset_needed) {
status = -1;
}
msleep(1000);
}
/* Stop error recovery if error is not recoverable.
* No resource error is temporary errors and will go away
* when PF provisions resources.
*/
resource_error = lancer_provisioning_error(adapter);
if (resource_error)
status = -EAGAIN;
return status;
return sliport_status ? : -1;
}
int be_fw_wait_ready(struct be_adapter *adapter)
......@@ -720,6 +663,10 @@ int be_fw_wait_ready(struct be_adapter *adapter)
}
do {
/* There's no means to poll POST state on BE2/3 VFs */
if (BEx_chip(adapter) && be_virtfn(adapter))
return 0;
stage = be_POST_stage_get(adapter);
if (stage == POST_STAGE_ARMFW_RDY)
return 0;
......@@ -734,7 +681,7 @@ int be_fw_wait_ready(struct be_adapter *adapter)
err:
dev_err(dev, "POST timeout; stage=%#x\n", stage);
return -1;
return -ETIMEDOUT;
}
static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
......@@ -2126,16 +2073,12 @@ int be_cmd_reset_function(struct be_adapter *adapter)
int status;
if (lancer_chip(adapter)) {
iowrite32(SLI_PORT_CONTROL_IP_MASK,
adapter->db + SLIPORT_CONTROL_OFFSET);
status = lancer_wait_ready(adapter);
if (!status) {
iowrite32(SLI_PORT_CONTROL_IP_MASK,
adapter->db + SLIPORT_CONTROL_OFFSET);
status = lancer_test_and_set_rdy_state(adapter);
}
if (status) {
if (status)
dev_err(&adapter->pdev->dev,
"Adapter in non recoverable error\n");
}
return status;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册