From patchwork Fri Jan 10 23:32:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Daley X-Patchwork-Id: 13935591 X-Patchwork-Delegate: kuba@kernel.org Received: from rcdn-iport-1.cisco.com (rcdn-iport-1.cisco.com [173.37.86.72]) (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 D2A20222572 for ; Fri, 10 Jan 2025 23:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.86.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736551981; cv=none; b=OLh1kKQHiAdXL8NqFFe2lq+CGUo07uomYEnriSTR72SBWsAvN4skW2OKg/HpBEQm1T0QigexFwJOOtjv8yrWToBYmd+ieynR8vpgaRKz4th+ma872fD9awUvgGWpAFOVp+9dC7ZriMH8h9Py9vEJcid6SrSms+qt9XcoilB81dc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736551981; c=relaxed/simple; bh=arGXb5Rus1cUc0CwA06aBsGq1d5jQ96aor8Qrc5jpOc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L8hi11RrQb+eU1DsWCbzhtDRvNub/xyWzXYIjnG7J5LNi5lW1VdQVYPDtVhkN84fzz+IjmF+DxROZ3gsg2Y6+itHcdQ73xDjasxWhxjiviPUOODT9AFOEECj141EItCirlYDWr6SFOFvXw+q/NhEmZy68wbEeYeL/kLdyUmZiqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=JnvKXU7Y; arc=none smtp.client-ip=173.37.86.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="JnvKXU7Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=4447; q=dns/txt; s=iport; t=1736551979; x=1737761579; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XtwlElowJ1XLKo9eSWoN9x2HL1wNbegz7k2yKy69syY=; b=JnvKXU7YhtjPj8AbMBNK6IXyVUCXbcX6facxPNdsSrF/yrwtFhxJgXUj EuhnLI005EEHqvH+VRd9XxxLGBcRaPwlwwbv5CLScL7/PWqW40FaVJ0KU PiCDH/QiY1eoAE1FsmGrT5H2niOF+kGS4bJQxIk+e4d3trB80W0giU8bw o=; X-CSE-ConnectionGUID: uPS7pxIERp60vlphbLfa3w== X-CSE-MsgGUID: 0kKjGZBGQUG2OZID7SbKMw== X-IPAS-Result: A0ANAAD8rIFn/47/Ja1aGwEBAQEBAQEBBQEBARIBAQEDAwEBAYF/BgEBAQsBgkqBT0NIjHJfiHKeGxSBEQNWDwEBAQ9EBAEBhQcCinQCJjQJDgECBAEBAQEDAgMBAQEBAQEBAQEBAQsBAQUBAQECAQcFgQ4ThgiGWwIBAycLAUYQUSsrBxKDAYJlA7RNgXkzgQHeM4FtgUgBhWqHX3CEdycbgUlEglCBPm+EKoZdBIIyhTWeUkiBIQNZLAFVEw0KCwcFgTg6AyILCwwLFBwVAhUfEQYQBG1EN4JGaUs6Ag0CNYIeJFiCK4RchEeEVIJLVYJHghR6gRmEAUADCxgNSBEsNwYOGwY+bgebJzyDbgGBDxOCADEkApMVG5IVgTSKPpURhCWBY59jGjOqU5gDeSKjVVCEZoFnPIFZMxoIGxWDIlIZD4hchVEWFrxGJTI8AgcLAQEDCZA+YAEB IronPort-Data: A9a23:beXn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AAmKCETgxVrmNSVW09qo/jJ87 X-Talos-MUID: 9a23:j2dk0AuwCl9vGC8XLs2n3DJBNuhayYuXNW9Xtqcnl5a/Pw9VJGLI X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.12,305,1728950400"; d="scan'208";a="304804037" Received: from rcdn-l-core-05.cisco.com ([173.37.255.142]) by rcdn-iport-1.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 10 Jan 2025 23:32:53 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-l-core-05.cisco.com (Postfix) with ESMTP id 1B1231800023B; Fri, 10 Jan 2025 23:32:53 +0000 (GMT) Received: by cisco.com (Postfix, from userid 392789) id E9F2B20F2006; Fri, 10 Jan 2025 15:32:52 -0800 (PST) From: John Daley To: benve@cisco.com, satishkh@cisco.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: John Daley , Nelson Escobar Subject: [PATCH net-next v5 3/4] enic: Use function pointers for buf alloc, free and RQ service Date: Fri, 10 Jan 2025 15:32:48 -0800 Message-Id: <20250110233249.23258-4-johndale@cisco.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20250110233249.23258-1-johndale@cisco.com> References: <20250110233249.23258-1-johndale@cisco.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: rcdn-l-core-05.cisco.com X-Patchwork-Delegate: kuba@kernel.org In order to support more than one packet receive processing scheme, use pointers for allocate, free and RQ descrptor processing functions. No functional change. Co-developed-by: Nelson Escobar Signed-off-by: Nelson Escobar Co-developed-by: Satish Kharat Signed-off-by: Satish Kharat Signed-off-by: John Daley --- drivers/net/ethernet/cisco/enic/enic.h | 5 +++++ drivers/net/ethernet/cisco/enic/enic_main.c | 14 +++++++++----- drivers/net/ethernet/cisco/enic/enic_rq.c | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index 10b7e02ba4d0..51f80378d928 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -226,6 +226,11 @@ struct enic { u32 rx_copybreak; u8 rss_key[ENIC_RSS_LEN]; struct vnic_gen_stats gen_stats; + void (*rq_buf_service)(struct vnic_rq *rq, struct cq_desc *cq_desc, + struct vnic_rq_buf *buf, int skipped, + void *opaque); + int (*rq_alloc_buf)(struct vnic_rq *rq); + void (*rq_free_buf)(struct vnic_rq *rq, struct vnic_rq_buf *buf); }; static inline struct net_device *vnic_get_netdev(struct vnic_dev *vdev) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index fd3d34c1d4d4..d3319f62ad1b 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -1550,7 +1550,7 @@ static int enic_poll(struct napi_struct *napi, int budget) 0 /* don't unmask intr */, 0 /* don't reset intr timer */); - err = vnic_rq_fill(&enic->rq[0].vrq, enic_rq_alloc_buf); + err = vnic_rq_fill(&enic->rq[0].vrq, enic->rq_alloc_buf); /* Buffer allocation failed. Stay in polling * mode so we can try to fill the ring again. @@ -1678,7 +1678,7 @@ static int enic_poll_msix_rq(struct napi_struct *napi, int budget) 0 /* don't unmask intr */, 0 /* don't reset intr timer */); - err = vnic_rq_fill(&enic->rq[rq].vrq, enic_rq_alloc_buf); + err = vnic_rq_fill(&enic->rq[rq].vrq, enic->rq_alloc_buf); /* Buffer allocation failed. Stay in polling mode * so we can try to fill the ring again. @@ -1883,6 +1883,10 @@ static int enic_open(struct net_device *netdev) unsigned int i; int err, ret; + enic->rq_buf_service = enic_rq_indicate_buf; + enic->rq_alloc_buf = enic_rq_alloc_buf; + enic->rq_free_buf = enic_free_rq_buf; + err = enic_request_intr(enic); if (err) { netdev_err(netdev, "Unable to request irq.\n"); @@ -1901,7 +1905,7 @@ static int enic_open(struct net_device *netdev) for (i = 0; i < enic->rq_count; i++) { /* enable rq before updating rq desc */ vnic_rq_enable(&enic->rq[i].vrq); - vnic_rq_fill(&enic->rq[i].vrq, enic_rq_alloc_buf); + vnic_rq_fill(&enic->rq[i].vrq, enic->rq_alloc_buf); /* Need at least one buffer on ring to get going */ if (vnic_rq_desc_used(&enic->rq[i].vrq) == 0) { netdev_err(netdev, "Unable to alloc receive buffers\n"); @@ -1940,7 +1944,7 @@ static int enic_open(struct net_device *netdev) for (i = 0; i < enic->rq_count; i++) { ret = vnic_rq_disable(&enic->rq[i].vrq); if (!ret) - vnic_rq_clean(&enic->rq[i].vrq, enic_free_rq_buf); + vnic_rq_clean(&enic->rq[i].vrq, enic->rq_free_buf); } enic_dev_notify_unset(enic); err_out_free_intr: @@ -1999,7 +2003,7 @@ static int enic_stop(struct net_device *netdev) for (i = 0; i < enic->wq_count; i++) vnic_wq_clean(&enic->wq[i].vwq, enic_free_wq_buf); for (i = 0; i < enic->rq_count; i++) - vnic_rq_clean(&enic->rq[i].vrq, enic_free_rq_buf); + vnic_rq_clean(&enic->rq[i].vrq, enic->rq_free_buf); for (i = 0; i < enic->cq_count; i++) vnic_cq_clean(&enic->cq[i]); for (i = 0; i < enic->intr_count; i++) diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.c b/drivers/net/ethernet/cisco/enic/enic_rq.c index 571af8f31470..ae2ab5af87e9 100644 --- a/drivers/net/ethernet/cisco/enic/enic_rq.c +++ b/drivers/net/ethernet/cisco/enic/enic_rq.c @@ -114,7 +114,7 @@ int enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc, struct enic *enic = vnic_dev_priv(vdev); vnic_rq_service(&enic->rq[q_number].vrq, cq_desc, completed_index, - VNIC_RQ_RETURN_DESC, enic_rq_indicate_buf, opaque); + VNIC_RQ_RETURN_DESC, enic->rq_buf_service, opaque); return 0; }