Commit 8396fb8d authored by David S. Miller's avatar David S. Miller

Merge branch 'refactoring-of-ibmvnic-code'

Lijun Pan says:

====================
refactoring of ibmvnic code

This patch series refactor reset_init and init functions,
and make some other cosmetic changes to make the code
easier to read and debug. v2 removes __func__ and v1's 1/5.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents bf82d565 635e442f
...@@ -104,8 +104,7 @@ static int send_login(struct ibmvnic_adapter *adapter); ...@@ -104,8 +104,7 @@ static int send_login(struct ibmvnic_adapter *adapter);
static void send_cap_queries(struct ibmvnic_adapter *adapter); static void send_cap_queries(struct ibmvnic_adapter *adapter);
static int init_sub_crqs(struct ibmvnic_adapter *); static int init_sub_crqs(struct ibmvnic_adapter *);
static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter); static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter);
static int ibmvnic_init(struct ibmvnic_adapter *); static int ibmvnic_reset_init(struct ibmvnic_adapter *, bool reset);
static int ibmvnic_reset_init(struct ibmvnic_adapter *);
static void release_crq_queue(struct ibmvnic_adapter *); static void release_crq_queue(struct ibmvnic_adapter *);
static int __ibmvnic_set_mac(struct net_device *, u8 *); static int __ibmvnic_set_mac(struct net_device *, u8 *);
static int init_crq_queue(struct ibmvnic_adapter *adapter); static int init_crq_queue(struct ibmvnic_adapter *adapter);
...@@ -963,7 +962,7 @@ static int set_link_state(struct ibmvnic_adapter *adapter, u8 link_state) ...@@ -963,7 +962,7 @@ static int set_link_state(struct ibmvnic_adapter *adapter, u8 link_state)
return -1; return -1;
} }
if (adapter->init_done_rc == 1) { if (adapter->init_done_rc == PARTIALSUCCESS) {
/* Partuial success, delay and re-send */ /* Partuial success, delay and re-send */
mdelay(1000); mdelay(1000);
resend = true; resend = true;
...@@ -1856,7 +1855,7 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter, ...@@ -1856,7 +1855,7 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter,
return rc; return rc;
} }
rc = ibmvnic_reset_init(adapter); rc = ibmvnic_reset_init(adapter, true);
if (rc) if (rc)
return IBMVNIC_INIT_FAILED; return IBMVNIC_INIT_FAILED;
...@@ -1974,7 +1973,7 @@ static int do_reset(struct ibmvnic_adapter *adapter, ...@@ -1974,7 +1973,7 @@ static int do_reset(struct ibmvnic_adapter *adapter,
goto out; goto out;
} }
rc = ibmvnic_reset_init(adapter); rc = ibmvnic_reset_init(adapter, true);
if (rc) { if (rc) {
rc = IBMVNIC_INIT_FAILED; rc = IBMVNIC_INIT_FAILED;
goto out; goto out;
...@@ -2081,7 +2080,7 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter, ...@@ -2081,7 +2080,7 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter,
return rc; return rc;
} }
rc = ibmvnic_init(adapter); rc = ibmvnic_reset_init(adapter, false);
if (rc) if (rc)
return rc; return rc;
...@@ -3556,8 +3555,7 @@ static int ibmvnic_send_crq(struct ibmvnic_adapter *adapter, ...@@ -3556,8 +3555,7 @@ static int ibmvnic_send_crq(struct ibmvnic_adapter *adapter,
if (rc) { if (rc) {
if (rc == H_CLOSED) { if (rc == H_CLOSED) {
dev_warn(dev, "CRQ Queue closed\n"); dev_warn(dev, "CRQ Queue closed\n");
if (test_bit(0, &adapter->resetting)) /* do not reset, report the fail, wait for passive init from server */
ibmvnic_reset(adapter, VNIC_RESET_FATAL);
} }
dev_warn(dev, "Send error (rc=%d)\n", rc); dev_warn(dev, "Send error (rc=%d)\n", rc);
...@@ -4988,7 +4986,7 @@ static int init_crq_queue(struct ibmvnic_adapter *adapter) ...@@ -4988,7 +4986,7 @@ static int init_crq_queue(struct ibmvnic_adapter *adapter)
return retrc; return retrc;
} }
static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter) static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter, bool reset)
{ {
struct device *dev = &adapter->vdev->dev; struct device *dev = &adapter->vdev->dev;
unsigned long timeout = msecs_to_jiffies(30000); unsigned long timeout = msecs_to_jiffies(30000);
...@@ -4997,12 +4995,19 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter) ...@@ -4997,12 +4995,19 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter)
adapter->from_passive_init = false; adapter->from_passive_init = false;
if (reset) {
old_num_rx_queues = adapter->req_rx_queues; old_num_rx_queues = adapter->req_rx_queues;
old_num_tx_queues = adapter->req_tx_queues; old_num_tx_queues = adapter->req_tx_queues;
reinit_completion(&adapter->init_done); reinit_completion(&adapter->init_done);
}
adapter->init_done_rc = 0; adapter->init_done_rc = 0;
ibmvnic_send_crq_init(adapter); rc = ibmvnic_send_crq_init(adapter);
if (rc) {
dev_err(dev, "Send crq init failed with error %d\n", rc);
return rc;
}
if (!wait_for_completion_timeout(&adapter->init_done, timeout)) { if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
dev_err(dev, "Initialization sequence timed out\n"); dev_err(dev, "Initialization sequence timed out\n");
return -1; return -1;
...@@ -5013,13 +5018,8 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter) ...@@ -5013,13 +5018,8 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter)
return adapter->init_done_rc; return adapter->init_done_rc;
} }
if (adapter->from_passive_init) { if (reset &&
adapter->state = VNIC_OPEN; test_bit(0, &adapter->resetting) && !adapter->wait_for_reset &&
adapter->from_passive_init = false;
return -1;
}
if (test_bit(0, &adapter->resetting) && !adapter->wait_for_reset &&
adapter->reset_reason != VNIC_RESET_MOBILITY) { adapter->reset_reason != VNIC_RESET_MOBILITY) {
if (adapter->req_rx_queues != old_num_rx_queues || if (adapter->req_rx_queues != old_num_rx_queues ||
adapter->req_tx_queues != old_num_tx_queues) { adapter->req_tx_queues != old_num_tx_queues) {
...@@ -5047,48 +5047,6 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter) ...@@ -5047,48 +5047,6 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter)
return rc; return rc;
} }
static int ibmvnic_init(struct ibmvnic_adapter *adapter)
{
struct device *dev = &adapter->vdev->dev;
unsigned long timeout = msecs_to_jiffies(30000);
int rc;
adapter->from_passive_init = false;
adapter->init_done_rc = 0;
ibmvnic_send_crq_init(adapter);
if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
dev_err(dev, "Initialization sequence timed out\n");
return -1;
}
if (adapter->init_done_rc) {
release_crq_queue(adapter);
return adapter->init_done_rc;
}
if (adapter->from_passive_init) {
adapter->state = VNIC_OPEN;
adapter->from_passive_init = false;
return -1;
}
rc = init_sub_crqs(adapter);
if (rc) {
dev_err(dev, "Initialization of sub crqs failed\n");
release_crq_queue(adapter);
return rc;
}
rc = init_sub_crq_irqs(adapter);
if (rc) {
dev_err(dev, "Failed to initialize sub crq irqs\n");
release_crq_queue(adapter);
}
return rc;
}
static struct device_attribute dev_attr_failover; static struct device_attribute dev_attr_failover;
static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
...@@ -5151,7 +5109,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) ...@@ -5151,7 +5109,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
goto ibmvnic_init_fail; goto ibmvnic_init_fail;
} }
rc = ibmvnic_init(adapter); rc = ibmvnic_reset_init(adapter, false);
if (rc && rc != EAGAIN) if (rc && rc != EAGAIN)
goto ibmvnic_init_fail; goto ibmvnic_init_fail;
} while (rc == EAGAIN); } while (rc == EAGAIN);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment