From patchwork Mon May 1 21:56:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Fontenot X-Patchwork-Id: 757243 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wGsqD5Xm5z9sN9 for ; Tue, 2 May 2017 04:08:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751156AbdEASIW (ORCPT ); Mon, 1 May 2017 14:08:22 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45698 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbdEASIS (ORCPT ); Mon, 1 May 2017 14:08:18 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v41I4F9d116054 for ; Mon, 1 May 2017 14:08:07 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a68vvu1r0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 01 May 2017 14:08:07 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 1 May 2017 14:08:05 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 1 May 2017 14:08:03 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v41I82Fb55574728; Mon, 1 May 2017 18:08:02 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8652612403F; Mon, 1 May 2017 14:07:57 -0400 (EDT) Received: from ltcalpine2-lp23.aus.stglabs.ibm.com (unknown [9.40.195.232]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 1B8B6124054; Mon, 1 May 2017 14:07:57 -0400 (EDT) Subject: [PATCH v2 net-next 02/11] ibmvnic: Replace is_closed with state field From: Nathan Fontenot To: netdev@vger.kernel.org Cc: brking@linux.vnet.ibm.com, jallen@linux.vnet.ibm.com, muvic@linux.vnet.ibm.com, tlfalcon@linux.vnet.ibm.com Date: Mon, 01 May 2017 17:56:50 -0400 In-Reply-To: <20170501215424.27224.53918.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com> References: <20170501215424.27224.53918.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17050118-0036-0000-0000-000001F5D585 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007007; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00854806; UDB=6.00422987; IPR=6.00633967; BA=6.00005321; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015256; XFM=3.00000014; UTC=2017-05-01 18:08:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050118-0037-0000-0000-0000401D545C Message-Id: <20170501215650.27224.49837.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-01_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705010114 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Replace the is_closed flag in the ibmvnic adapter strcut with a more comprehensive state field that tracks the current state of the driver. Signed-off-by: Nathan Fontenot --- drivers/net/ethernet/ibm/ibmvnic.c | 20 +++++++++++++------- drivers/net/ethernet/ibm/ibmvnic.h | 12 ++++++++++-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index c67f1d6..40a8ba0 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -669,7 +669,9 @@ static int ibmvnic_open(struct net_device *netdev) struct ibmvnic_adapter *adapter = netdev_priv(netdev); int i, rc; - if (adapter->is_closed) { + adapter->state = VNIC_OPENING; + + if (adapter->state == VNIC_CLOSED) { rc = ibmvnic_init(adapter); if (rc) return rc; @@ -704,7 +706,7 @@ static int ibmvnic_open(struct net_device *netdev) release_resources(adapter); } else { netif_tx_start_all_queues(netdev); - adapter->is_closed = false; + adapter->state = VNIC_OPEN; } return rc; @@ -733,7 +735,7 @@ static int ibmvnic_close(struct net_device *netdev) int rc = 0; int i; - adapter->closing = true; + adapter->state = VNIC_CLOSING; disable_sub_crqs(adapter); if (adapter->napi) { @@ -748,8 +750,7 @@ static int ibmvnic_close(struct net_device *netdev) release_resources(adapter); - adapter->is_closed = true; - adapter->closing = false; + adapter->state = VNIC_CLOSED; return rc; } @@ -1860,7 +1861,8 @@ static int pending_scrq(struct ibmvnic_adapter *adapter, { union sub_crq *entry = &scrq->msgs[scrq->cur]; - if (entry->generic.first & IBMVNIC_CRQ_CMD_RSP || adapter->closing) + if (entry->generic.first & IBMVNIC_CRQ_CMD_RSP || + adapter->state == VNIC_CLOSING) return 1; else return 0; @@ -3353,6 +3355,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) return -ENOMEM; adapter = netdev_priv(netdev); + adapter->state = VNIC_PROBING; dev_set_drvdata(&dev->dev, netdev); adapter->vdev = dev; adapter->netdev = netdev; @@ -3380,7 +3383,6 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) } netdev->mtu = adapter->req_mtu - ETH_HLEN; - adapter->is_closed = false; rc = register_netdev(netdev); if (rc) { @@ -3390,6 +3392,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) } dev_info(&dev->dev, "ibmvnic registered\n"); + adapter->state = VNIC_PROBED; return 0; } @@ -3398,12 +3401,15 @@ static int ibmvnic_remove(struct vio_dev *dev) struct net_device *netdev = dev_get_drvdata(&dev->dev); struct ibmvnic_adapter *adapter = netdev_priv(netdev); + adapter->state = VNIC_REMOVING; unregister_netdev(netdev); release_resources(adapter); release_sub_crqs(adapter); release_crq_queue(adapter); + adapter->state = VNIC_REMOVED; + free_netdev(netdev); dev_set_drvdata(&dev->dev, NULL); diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h index a69979f..03a866f 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.h +++ b/drivers/net/ethernet/ibm/ibmvnic.h @@ -913,6 +913,15 @@ struct ibmvnic_error_buff { __be32 error_id; }; +enum vnic_state {VNIC_PROBING = 1, + VNIC_PROBED, + VNIC_OPENING, + VNIC_OPEN, + VNIC_CLOSING, + VNIC_CLOSED, + VNIC_REMOVING, + VNIC_REMOVED}; + struct ibmvnic_adapter { struct vio_dev *vdev; struct net_device *netdev; @@ -962,7 +971,6 @@ struct ibmvnic_adapter { u64 promisc; struct ibmvnic_tx_pool *tx_pool; - bool closing; struct completion init_done; int init_done_rc; @@ -1011,5 +1019,5 @@ struct ibmvnic_adapter { struct work_struct ibmvnic_xport; struct tasklet_struct tasklet; bool failover; - bool is_closed; + enum vnic_state state; };