diff options
author | Sathya Perla <sathya.perla@emulex.com> | 2015-02-23 04:20:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-23 15:08:32 -0500 |
commit | 9fa465c0ce0d99f098195d7b0a550aeb1b2a8c44 (patch) | |
tree | a266390bada462938fbeffdf9adb1a066dcd6a00 /drivers/net/ethernet | |
parent | d0e1b319bbf345e8b8cc8bd7702cc6c33db074d9 (diff) |
be2net: remove code duplication relating to Lancer reset sequence
The steps needed for Lancer's reset/initialization sequence are:
a) wait for SLIPORT_STAUS RDY bit to be set
b) set the SLIPORT_CONTROL IP bit
c) repeat step "a"
The code needed for this sequence is already covered by the be_func_init()
routine (with minor modifications.) So, get rid of the
lancer_test_and_set_rdy_state() and lancer_provisioning_error() routines
that unnecessarily duplicate this code. Also fixed the error recovery
function to take care of these changes
Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
Signed-off-by: Kalesh AP <kalesh.purayil@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/emulex/benet/be_cmds.c | 81 | ||||
-rw-r--r-- | drivers/net/ethernet/emulex/benet/be_main.c | 91 |
2 files changed, 55 insertions, 117 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 8a8a23030aff..f6db7b3e9b70 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c | |||
@@ -635,73 +635,16 @@ static int lancer_wait_ready(struct be_adapter *adapter) | |||
635 | for (i = 0; i < SLIPORT_READY_TIMEOUT; i++) { | 635 | for (i = 0; i < SLIPORT_READY_TIMEOUT; i++) { |
636 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); | 636 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); |
637 | if (sliport_status & SLIPORT_STATUS_RDY_MASK) | 637 | if (sliport_status & SLIPORT_STATUS_RDY_MASK) |
638 | break; | 638 | return 0; |
639 | |||
640 | msleep(1000); | ||
641 | } | ||
642 | |||
643 | if (i == SLIPORT_READY_TIMEOUT) | ||
644 | return sliport_status ? : -1; | ||
645 | |||
646 | return 0; | ||
647 | } | ||
648 | |||
649 | static bool lancer_provisioning_error(struct be_adapter *adapter) | ||
650 | { | ||
651 | u32 sliport_status = 0, sliport_err1 = 0, sliport_err2 = 0; | ||
652 | |||
653 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); | ||
654 | if (sliport_status & SLIPORT_STATUS_ERR_MASK) { | ||
655 | sliport_err1 = ioread32(adapter->db + SLIPORT_ERROR1_OFFSET); | ||
656 | sliport_err2 = ioread32(adapter->db + SLIPORT_ERROR2_OFFSET); | ||
657 | |||
658 | if (sliport_err1 == SLIPORT_ERROR_NO_RESOURCE1 && | ||
659 | sliport_err2 == SLIPORT_ERROR_NO_RESOURCE2) | ||
660 | return true; | ||
661 | } | ||
662 | return false; | ||
663 | } | ||
664 | |||
665 | int lancer_test_and_set_rdy_state(struct be_adapter *adapter) | ||
666 | { | ||
667 | int status; | ||
668 | u32 sliport_status, err, reset_needed; | ||
669 | bool resource_error; | ||
670 | 639 | ||
671 | resource_error = lancer_provisioning_error(adapter); | 640 | if (sliport_status & SLIPORT_STATUS_ERR_MASK && |
672 | if (resource_error) | 641 | !(sliport_status & SLIPORT_STATUS_RN_MASK)) |
673 | return -EAGAIN; | 642 | return -EIO; |
674 | 643 | ||
675 | status = lancer_wait_ready(adapter); | 644 | msleep(1000); |
676 | if (!status) { | ||
677 | sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); | ||
678 | err = sliport_status & SLIPORT_STATUS_ERR_MASK; | ||
679 | reset_needed = sliport_status & SLIPORT_STATUS_RN_MASK; | ||
680 | if (err && reset_needed) { | ||
681 | iowrite32(SLI_PORT_CONTROL_IP_MASK, | ||
682 | adapter->db + SLIPORT_CONTROL_OFFSET); | ||
683 | |||
684 | /* check if adapter has corrected the error */ | ||
685 | status = lancer_wait_ready(adapter); | ||
686 | sliport_status = ioread32(adapter->db + | ||
687 | SLIPORT_STATUS_OFFSET); | ||
688 | sliport_status &= (SLIPORT_STATUS_ERR_MASK | | ||
689 | SLIPORT_STATUS_RN_MASK); | ||
690 | if (status || sliport_status) | ||
691 | status = -1; | ||
692 | } else if (err || reset_needed) { | ||
693 | status = -1; | ||
694 | } | ||
695 | } | 645 | } |
696 | /* Stop error recovery if error is not recoverable. | ||
697 | * No resource error is temporary errors and will go away | ||
698 | * when PF provisions resources. | ||
699 | */ | ||
700 | resource_error = lancer_provisioning_error(adapter); | ||
701 | if (resource_error) | ||
702 | status = -EAGAIN; | ||
703 | 646 | ||
704 | return status; | 647 | return sliport_status ? : -1; |
705 | } | 648 | } |
706 | 649 | ||
707 | int be_fw_wait_ready(struct be_adapter *adapter) | 650 | int be_fw_wait_ready(struct be_adapter *adapter) |
@@ -738,7 +681,7 @@ int be_fw_wait_ready(struct be_adapter *adapter) | |||
738 | 681 | ||
739 | err: | 682 | err: |
740 | dev_err(dev, "POST timeout; stage=%#x\n", stage); | 683 | dev_err(dev, "POST timeout; stage=%#x\n", stage); |
741 | return -1; | 684 | return -ETIMEDOUT; |
742 | } | 685 | } |
743 | 686 | ||
744 | static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb) | 687 | static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb) |
@@ -2130,16 +2073,12 @@ int be_cmd_reset_function(struct be_adapter *adapter) | |||
2130 | int status; | 2073 | int status; |
2131 | 2074 | ||
2132 | if (lancer_chip(adapter)) { | 2075 | if (lancer_chip(adapter)) { |
2076 | iowrite32(SLI_PORT_CONTROL_IP_MASK, | ||
2077 | adapter->db + SLIPORT_CONTROL_OFFSET); | ||
2133 | status = lancer_wait_ready(adapter); | 2078 | status = lancer_wait_ready(adapter); |
2134 | if (!status) { | 2079 | if (status) |
2135 | iowrite32(SLI_PORT_CONTROL_IP_MASK, | ||
2136 | adapter->db + SLIPORT_CONTROL_OFFSET); | ||
2137 | status = lancer_test_and_set_rdy_state(adapter); | ||
2138 | } | ||
2139 | if (status) { | ||
2140 | dev_err(&adapter->pdev->dev, | 2080 | dev_err(&adapter->pdev->dev, |
2141 | "Adapter in non recoverable error\n"); | 2081 | "Adapter in non recoverable error\n"); |
2142 | } | ||
2143 | return status; | 2082 | return status; |
2144 | } | 2083 | } |
2145 | 2084 | ||
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 034ce7031ce2..4a29ff15a3cc 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
@@ -4903,18 +4903,54 @@ static void be_netdev_init(struct net_device *netdev) | |||
4903 | netdev->ethtool_ops = &be_ethtool_ops; | 4903 | netdev->ethtool_ops = &be_ethtool_ops; |
4904 | } | 4904 | } |
4905 | 4905 | ||
4906 | /* If any VFs are already enabled don't FLR the PF */ | ||
4907 | static bool be_reset_required(struct be_adapter *adapter) | ||
4908 | { | ||
4909 | return pci_num_vf(adapter->pdev) ? false : true; | ||
4910 | } | ||
4911 | |||
4912 | /* Wait for the FW to be ready and perform the required initialization */ | ||
4913 | static int be_func_init(struct be_adapter *adapter) | ||
4914 | { | ||
4915 | int status; | ||
4916 | |||
4917 | status = be_fw_wait_ready(adapter); | ||
4918 | if (status) | ||
4919 | return status; | ||
4920 | |||
4921 | if (be_reset_required(adapter)) { | ||
4922 | status = be_cmd_reset_function(adapter); | ||
4923 | if (status) | ||
4924 | return status; | ||
4925 | |||
4926 | /* Wait for interrupts to quiesce after an FLR */ | ||
4927 | msleep(100); | ||
4928 | |||
4929 | /* We can clear all errors when function reset succeeds */ | ||
4930 | be_clear_all_error(adapter); | ||
4931 | } | ||
4932 | |||
4933 | /* Tell FW we're ready to fire cmds */ | ||
4934 | status = be_cmd_fw_init(adapter); | ||
4935 | if (status) | ||
4936 | return status; | ||
4937 | |||
4938 | /* Allow interrupts for other ULPs running on NIC function */ | ||
4939 | be_intr_set(adapter, true); | ||
4940 | |||
4941 | return 0; | ||
4942 | } | ||
4943 | |||
4906 | static int be_err_recover(struct be_adapter *adapter) | 4944 | static int be_err_recover(struct be_adapter *adapter) |
4907 | { | 4945 | { |
4908 | struct net_device *netdev = adapter->netdev; | 4946 | struct net_device *netdev = adapter->netdev; |
4909 | struct device *dev = &adapter->pdev->dev; | 4947 | struct device *dev = &adapter->pdev->dev; |
4910 | int status; | 4948 | int status; |
4911 | 4949 | ||
4912 | status = lancer_test_and_set_rdy_state(adapter); | 4950 | status = be_func_init(adapter); |
4913 | if (status) | 4951 | if (status) |
4914 | goto err; | 4952 | goto err; |
4915 | 4953 | ||
4916 | be_clear_all_error(adapter); | ||
4917 | |||
4918 | status = be_setup(adapter); | 4954 | status = be_setup(adapter); |
4919 | if (status) | 4955 | if (status) |
4920 | goto err; | 4956 | goto err; |
@@ -4927,13 +4963,13 @@ static int be_err_recover(struct be_adapter *adapter) | |||
4927 | 4963 | ||
4928 | netif_device_attach(netdev); | 4964 | netif_device_attach(netdev); |
4929 | 4965 | ||
4930 | dev_err(dev, "Adapter recovery successful\n"); | 4966 | dev_info(dev, "Adapter recovery successful\n"); |
4931 | return 0; | 4967 | return 0; |
4932 | err: | 4968 | err: |
4933 | if (status == -EAGAIN) | 4969 | if (be_physfn(adapter)) |
4934 | dev_err(dev, "Waiting for resource provisioning\n"); | ||
4935 | else | ||
4936 | dev_err(dev, "Adapter recovery failed\n"); | 4970 | dev_err(dev, "Adapter recovery failed\n"); |
4971 | else | ||
4972 | dev_err(dev, "Re-trying adapter recovery\n"); | ||
4937 | 4973 | ||
4938 | return status; | 4974 | return status; |
4939 | } | 4975 | } |
@@ -4962,10 +4998,8 @@ static void be_err_detection_task(struct work_struct *work) | |||
4962 | status = be_err_recover(adapter); | 4998 | status = be_err_recover(adapter); |
4963 | } | 4999 | } |
4964 | 5000 | ||
4965 | /* In Lancer, for all errors other than provisioning error (-EAGAIN), | 5001 | /* Always attempt recovery on VFs */ |
4966 | * no need to attempt further recovery. | 5002 | if (!status || be_virtfn(adapter)) |
4967 | */ | ||
4968 | if (!status || status == -EAGAIN) | ||
4969 | be_schedule_err_detection(adapter); | 5003 | be_schedule_err_detection(adapter); |
4970 | } | 5004 | } |
4971 | 5005 | ||
@@ -5208,12 +5242,6 @@ static void be_remove(struct pci_dev *pdev) | |||
5208 | free_netdev(adapter->netdev); | 5242 | free_netdev(adapter->netdev); |
5209 | } | 5243 | } |
5210 | 5244 | ||
5211 | /* If any VFs are already enabled don't FLR the PF */ | ||
5212 | static bool be_reset_required(struct be_adapter *adapter) | ||
5213 | { | ||
5214 | return pci_num_vf(adapter->pdev) ? false : true; | ||
5215 | } | ||
5216 | |||
5217 | static char *mc_name(struct be_adapter *adapter) | 5245 | static char *mc_name(struct be_adapter *adapter) |
5218 | { | 5246 | { |
5219 | char *str = ""; /* default */ | 5247 | char *str = ""; /* default */ |
@@ -5269,35 +5297,6 @@ static inline char *nic_name(struct pci_dev *pdev) | |||
5269 | } | 5297 | } |
5270 | } | 5298 | } |
5271 | 5299 | ||
5272 | /* Wait for the FW to be ready and perform the required initialization */ | ||
5273 | static int be_func_init(struct be_adapter *adapter) | ||
5274 | { | ||
5275 | int status; | ||
5276 | |||
5277 | status = be_fw_wait_ready(adapter); | ||
5278 | if (status) | ||
5279 | return status; | ||
5280 | |||
5281 | if (be_reset_required(adapter)) { | ||
5282 | status = be_cmd_reset_function(adapter); | ||
5283 | if (status) | ||
5284 | return status; | ||
5285 | |||
5286 | /* Wait for interrupts to quiesce after an FLR */ | ||
5287 | msleep(100); | ||
5288 | } | ||
5289 | |||
5290 | /* Tell FW we're ready to fire cmds */ | ||
5291 | status = be_cmd_fw_init(adapter); | ||
5292 | if (status) | ||
5293 | return status; | ||
5294 | |||
5295 | /* Allow interrupts for other ULPs running on NIC function */ | ||
5296 | be_intr_set(adapter, true); | ||
5297 | |||
5298 | return 0; | ||
5299 | } | ||
5300 | |||
5301 | static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id) | 5300 | static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id) |
5302 | { | 5301 | { |
5303 | struct be_adapter *adapter; | 5302 | struct be_adapter *adapter; |