From nobody Tue Nov 26 02:04:53 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5CC21CC89E; Wed, 23 Oct 2024 16:19:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729700347; cv=none; b=nUAuwHkF4b5SZqzo5xxPsWm4w/WSFL0VIDQGJB6J7lX3Q7l0HPJkcxqonGPGaXl+ZTgs9/2h4sehiOSe9maFzoGZLUvG8dnQefZH9J9FT4HY8GbvWvyUE6HhZag3MPY8pxwCpetWOwtxmWwsY9xSIv48xRBIJO3Pa2yAA47l4mE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729700347; c=relaxed/simple; bh=7Wduzv348ymE8N/bR07DAcDadov1N4W3f4P//gN4c8k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FRjzuB+pJmhTgSrq54wEeEJFBd+iLa6CeWf+xdcSSKovDLObKC2wYYBxqZ74zOD6h8bCYDTZfLS1RJFMXTuX7J0PZPoGwAiTNde3qvOdhW6poVYCh9MKYbLTHGgnvQkFySvgnMmtnmokjAJsGwIK5QgrsElDZ9Y01HhEBbHgSPo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=QCyYoK+s; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="QCyYoK+s" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49NBVKdp017534; Wed, 23 Oct 2024 09:18:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pfpt0220; bh=hG8dLHX/EScfEvrJIjoN213CA p3wYzhYPiFaikKyqJU=; b=QCyYoK+sEjAaKDCe1qfzYF0sjQMHXkcuOOxpU4XcX zPLycMxR7ihVByxMuDUEs68VQZNNT4ICMuReIKeNzNCroA4EZVjmogyoiwO71auB J/iaulXXlsgMkJCVuh2mURU6oZtjgHPJWXq3QzEyJX9ZOzeGz86HpmqkOLq6b6aE jnVANXv08rPiMciaPLGfGxgqv4Uxw8iPLUyQVBMbUaNGu6tMxvyW1ulpy5lvVK1Y JQsL6WCB2yXBt4VUcYrqD9Z11vg+dDUrEEwckB7vzIauly00OIhEl2MdQ8AtDDc3 p+zfjVIxKzqe9sqUMaKTxf6rKXGXnjrFj/QiwrBd2mA8w== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42em2c2bkk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Oct 2024 09:18:57 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 23 Oct 2024 09:18:56 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 23 Oct 2024 09:18:56 -0700 Received: from hyd1soter3.marvell.com (unknown [10.29.37.12]) by maili.marvell.com (Postfix) with ESMTP id E6A293F7086; Wed, 23 Oct 2024 09:18:52 -0700 (PDT) From: Geetha sowjanya To: , CC: , , , , , , , , Subject: [net-next PATCH v4 2/4] octeontx2-pf: Add new APIs for queue memory alloc/free. Date: Wed, 23 Oct 2024 21:48:41 +0530 Message-ID: <20241023161843.15543-3-gakula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241023161843.15543-1-gakula@marvell.com> References: <20241023161843.15543-1-gakula@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: iL--c-gqc8DT0thGnlGE49L9ldAPlmfV X-Proofpoint-ORIG-GUID: iL--c-gqc8DT0thGnlGE49L9ldAPlmfV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Group the queue(RX/TX/CQ) memory allocation and free code to single APIs. Signed-off-by: Geetha sowjanya Reviewed-by: Pavan Chebbi Reviewed-by: Simon Horman --- .../marvell/octeontx2/nic/otx2_common.h | 2 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 53 +++++++++++++------ 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/dri= vers/net/ethernet/marvell/octeontx2/nic/otx2_common.h index a47001a2b93f..df548aeffecf 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h @@ -997,6 +997,8 @@ int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id, int otx2_aura_init(struct otx2_nic *pfvf, int aura_id, int pool_id, int numptrs); int otx2_init_rsrc(struct pci_dev *pdev, struct otx2_nic *pf); +void otx2_free_queue_mem(struct otx2_qset *qset); +int otx2_alloc_queue_mem(struct otx2_nic *pf); =20 /* RSS configuration APIs*/ int otx2_rss_init(struct otx2_nic *pfvf); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers= /net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 180a16b42ac3..1185f1bdfa01 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1770,15 +1770,23 @@ static void otx2_dim_work(struct work_struct *w) dim->state =3D DIM_START_MEASURE; } =20 -int otx2_open(struct net_device *netdev) +void otx2_free_queue_mem(struct otx2_qset *qset) +{ + kfree(qset->sq); + qset->sq =3D NULL; + kfree(qset->cq); + qset->cq =3D NULL; + kfree(qset->rq); + qset->rq =3D NULL; + kfree(qset->napi); + qset->napi =3D NULL; +} + +int otx2_alloc_queue_mem(struct otx2_nic *pf) { - struct otx2_nic *pf =3D netdev_priv(netdev); - struct otx2_cq_poll *cq_poll =3D NULL; struct otx2_qset *qset =3D &pf->qset; - int err =3D 0, qidx, vec; - char *irq_name; + struct otx2_cq_poll *cq_poll; =20 - netif_carrier_off(netdev); =20 /* RQ and SQs are mapped to different CQs, * so find out max CQ IRQs (i.e CINTs) needed. @@ -1798,7 +1806,6 @@ int otx2_open(struct net_device *netdev) /* CQ size of SQ */ qset->sqe_cnt =3D qset->sqe_cnt ? qset->sqe_cnt : Q_COUNT(Q_SIZE_4K); =20 - err =3D -ENOMEM; qset->cq =3D kcalloc(pf->qset.cq_cnt, sizeof(struct otx2_cq_queue), GFP_KERNEL); if (!qset->cq) @@ -1814,6 +1821,27 @@ int otx2_open(struct net_device *netdev) if (!qset->rq) goto err_free_mem; =20 + return 0; + +err_free_mem: + otx2_free_queue_mem(qset); + return -ENOMEM; +} + +int otx2_open(struct net_device *netdev) +{ + struct otx2_nic *pf =3D netdev_priv(netdev); + struct otx2_cq_poll *cq_poll =3D NULL; + struct otx2_qset *qset =3D &pf->qset; + int err =3D 0, qidx, vec; + char *irq_name; + + netif_carrier_off(netdev); + + err =3D otx2_alloc_queue_mem(pf); + if (err) + return err; + err =3D otx2_init_hw_resources(pf); if (err) goto err_free_mem; @@ -1979,10 +2007,7 @@ int otx2_open(struct net_device *netdev) otx2_disable_napi(pf); otx2_free_hw_resources(pf); err_free_mem: - kfree(qset->sq); - kfree(qset->cq); - kfree(qset->rq); - kfree(qset->napi); + otx2_free_queue_mem(qset); return err; } EXPORT_SYMBOL(otx2_open); @@ -2047,11 +2072,7 @@ int otx2_stop(struct net_device *netdev) for (qidx =3D 0; qidx < netdev->num_tx_queues; qidx++) netdev_tx_reset_queue(netdev_get_tx_queue(netdev, qidx)); =20 - - kfree(qset->sq); - kfree(qset->cq); - kfree(qset->rq); - kfree(qset->napi); + otx2_free_queue_mem(qset); /* Do not clear RQ/SQ ringsize settings */ memset_startat(qset, 0, sqe_cnt); return 0; --=20 2.25.1