Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp784281rdb; Fri, 22 Dec 2023 05:10:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwP0p9+h7jPmT/OxWnBIAyEZtrws6wuAslVaTindgCmgNEl6+kTSZWSobwC3qQVjN+r/PB X-Received: by 2002:a05:6870:2214:b0:203:f926:5b6c with SMTP id i20-20020a056870221400b00203f9265b6cmr1704331oaf.39.1703250633044; Fri, 22 Dec 2023 05:10:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703250633; cv=none; d=google.com; s=arc-20160816; b=LMBsWOtM2EOviBqgHMaNpv638ZxAjVNdnHAnlvLoyRBRU72QahZHglMejeKx+FHM06 hGrv3DRYzI/2TdpCjvEtl5SKshUhi0tS120K7rUn038PwF9tiKETkfQhjE5P1FMCishc G8auxt+9NGBcy4yexP5yuL7X3oUrhlhU5GPxdxe6O1GFU4nK6YTU4OS+xlzli4xLAMxR P6Qc0rq9I+5K7GIEZwh1i66ULQlusqyTKz89T4ib9EZOXlcWEQKLKALTq6rWtxXUXs/9 KQagRWVWrSfimUjpLI+k2N9r0VpVa+9ph+czw/GEp8DoO3S5RwePHh8t3fDHHRuVUMlm Ingg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JXsg1zQ/smJXLpk1LCgt9q+hPCj9+LrosYVo0Lnm984=; fh=aFPJnVppJEV9aOZfP+Za+YMqlNk7894nUZ4RkBuhc+8=; b=oMffX2mJaARbH4+qdsLVsql2eIqLnYn0yCdUkLz2pv7GSnf2IbcS/h6rG76hkUSC9g OYdq7OhRgvcvYUqO/dYboVssNu0VofjqbIca1dV4b+Um1BikJAWGwsxozScFk9WDHFST yWre+e34PF0Ckluuok83mzmYhix1WtElk6QapR0tHmnCKwbZ5rRg9UXiHgehFc7Rtxzs v+ikGKKbuAdMHUR95K2e75KlByt5i6T78mFV0K0ca8kCvxKfKsREDfH+cTP7nxHJstbQ AWY28DQ/I2TS+ceNTn5uXqjis3ZUFC72P4FeeuruRIHY9nObrhFkFqrzw4zX2B+geOfM iumQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n3uscbi9; spf=pass (google.com: domain of linux-kernel+bounces-9741-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9741-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j19-20020a635953000000b005893a7c438esi3266417pgm.689.2023.12.22.05.10.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 05:10:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9741-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n3uscbi9; spf=pass (google.com: domain of linux-kernel+bounces-9741-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9741-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 961622834AF for ; Fri, 22 Dec 2023 13:10:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 994AF199A4; Fri, 22 Dec 2023 13:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n3uscbi9" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CF1DE182A1; Fri, 22 Dec 2023 13:10:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02C95C433C8; Fri, 22 Dec 2023 13:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703250621; bh=FvnyuJhk+7r4BtcMqRVLyVhaGuE1vRlM7xCE2lBtl7A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n3uscbi9mTpk09tfQXWBQ9C4fr4b7ys8h9nWXJ+dSxDHEvAhtzC0LA8Mpmq7UU9bh /O+Hbhgj4cTQjhxCD6LWD9Wrbw3+MDFQC/4GoOYK7VkfhqC26sWFVxOjz4XsUoJ3uO zy2noqDBRjs9Rt+8kevLk1rOqHEm0xIk5VsggD7a4HwgE8saYXz1Icj5lwBWDvLqDC 3S5d9o7MIkkqBj+cKblTWKrpwGdL5VjPyKVzhhp+uUYMkJv1UrAsp4NjPp0UufB6nQ GkmluEfetP6hcN9BONpkijLX6AGQkXLjqwZBkKVE1EmQj2jtuejkasB8hQRTzgUzfN OHX/sIUETpHbQ== Date: Fri, 22 Dec 2023 14:10:12 +0100 From: Simon Horman To: Shinas Rasheed Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, hgani@marvell.com, vimleshk@marvell.com, sedara@marvell.com, egallen@redhat.com, mschmidt@redhat.com, pabeni@redhat.com, kuba@kernel.org, wizhao@redhat.com, kheib@redhat.com, konguyen@redhat.com, Veerasenareddy Burru , Satananda Burla , "David S. Miller" , Eric Dumazet Subject: Re: [PATCH net-next v1 4/8] octeon_ep_vf: add Tx/Rx ring resource setup and cleanup Message-ID: <20231222131012.GG1202958@kernel.org> References: <20231221092844.2885872-1-srasheed@marvell.com> <20231221092844.2885872-5-srasheed@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231221092844.2885872-5-srasheed@marvell.com> On Thu, Dec 21, 2023 at 01:28:40AM -0800, Shinas Rasheed wrote: > Implement Tx/Rx ring resource allocation and cleanup. > > Signed-off-by: Shinas Rasheed Hi Shinas, some minor feedback from my side which you might consider addressing if you have to respin the series for some other reason. ... > +/** > + * octep_vf_setup_oq() - Setup a Rx queue. > + * > + * @oct: Octeon device private data structure. > + * @q_no: Rx queue number to be setup. > + * > + * Allocate resources for a Rx queue. > + */ > +static int octep_vf_setup_oq(struct octep_vf_device *oct, int q_no) > +{ > + struct octep_vf_oq *oq; > + u32 desc_ring_size; > + > + oq = vzalloc(sizeof(*oq)); > + if (!oq) > + goto create_oq_fail; > + oct->oq[q_no] = oq; > + > + oq->octep_vf_dev = oct; > + oq->netdev = oct->netdev; > + oq->dev = &oct->pdev->dev; > + oq->q_no = q_no; > + oq->max_count = CFG_GET_OQ_NUM_DESC(oct->conf); > + oq->ring_size_mask = oq->max_count - 1; > + oq->buffer_size = CFG_GET_OQ_BUF_SIZE(oct->conf); > + oq->max_single_buffer_size = oq->buffer_size - OCTEP_VF_OQ_RESP_HW_SIZE; > + > + /* When the hardware/firmware supports additional capabilities, > + * additional header is filled-in by Octeon after length field in > + * Rx packets. this header contains additional packet information. > + */ > + if (oct->fw_info.rx_ol_flags) > + oq->max_single_buffer_size -= OCTEP_VF_OQ_RESP_HW_EXT_SIZE; > + > + oq->refill_threshold = CFG_GET_OQ_REFILL_THRESHOLD(oct->conf); > + > + desc_ring_size = oq->max_count * OCTEP_VF_OQ_DESC_SIZE; > + oq->desc_ring = dma_alloc_coherent(oq->dev, desc_ring_size, > + &oq->desc_ring_dma, GFP_KERNEL); > + > + if (unlikely(!oq->desc_ring)) { > + dev_err(oq->dev, > + "Failed to allocate DMA memory for OQ-%d !!\n", q_no); > + goto desc_dma_alloc_err; > + } > + > + oq->buff_info = (struct octep_vf_rx_buffer *) > + vzalloc(oq->max_count * OCTEP_VF_OQ_RECVBUF_SIZE); nit: There is no need to cast the return value of vzalloc() oq->buff_info = vzalloc(oq->max_count * OCTEP_VF_OQ_RECVBUF_SIZE); > + if (unlikely(!oq->buff_info)) { > + dev_err(&oct->pdev->dev, > + "Failed to allocate buffer info for OQ-%d\n", q_no); > + goto buf_list_err; > + } > + > + if (octep_vf_oq_fill_ring_buffers(oq)) > + goto oq_fill_buff_err; > + > + octep_vf_oq_reset_indices(oq); > + oct->hw_ops.setup_oq_regs(oct, q_no); > + oct->num_oqs++; > + > + return 0; > + > +oq_fill_buff_err: > + vfree(oq->buff_info); > + oq->buff_info = NULL; > +buf_list_err: > + dma_free_coherent(oq->dev, desc_ring_size, > + oq->desc_ring, oq->desc_ring_dma); > + oq->desc_ring = NULL; > +desc_dma_alloc_err: > + vfree(oq); > + oct->oq[q_no] = NULL; > +create_oq_fail: > + return -1; > +} ... > +/** > + * octep_vf_free_iq() - Free Tx queue resources. > + * > + * @iq: Octeon Tx queue data structure. > + * > + * Free all the resources allocated for a Tx queue. > + */ > +static void octep_vf_free_iq(struct octep_vf_iq *iq) > +{ > + struct octep_vf_device *oct = iq->octep_vf_dev; > + u64 desc_ring_size, sglist_size; > + int q_no = iq->q_no; > + > + desc_ring_size = OCTEP_VF_IQ_DESC_SIZE * CFG_GET_IQ_NUM_DESC(oct->conf); > + > + if (iq->buff_info) > + vfree(iq->buff_info); nit: vfree can handle a NULL argument, so there is no need to protect it with a if condition > + > + if (iq->desc_ring) > + dma_free_coherent(iq->dev, desc_ring_size, > + iq->desc_ring, iq->desc_ring_dma); > + > + sglist_size = OCTEP_VF_SGLIST_SIZE_PER_PKT * > + CFG_GET_IQ_NUM_DESC(oct->conf); > + if (iq->sglist) > + dma_free_coherent(iq->dev, sglist_size, > + iq->sglist, iq->sglist_dma); > + > + vfree(iq); > + oct->iq[q_no] = NULL; > + oct->num_iqs--; > } ...