From patchwork Fri Dec 27 03:14:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Daley X-Patchwork-Id: 13921518 X-Patchwork-Delegate: kuba@kernel.org Received: from alln-iport-2.cisco.com (alln-iport-2.cisco.com [173.37.142.89]) (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 188D73595E for ; Fri, 27 Dec 2024 03:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.142.89 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269352; cv=none; b=o7tArm7huI5n/zhQkMTFIVgtRqK01S4lPi3ZPdrWGUdo3sVdalaVxnyuo7q6TJJKuOR/8KF8VkYDrDCz6ARlQfgfO5T+mJuT1cvE983UJIsH5GxWOBsH+RIDGbMptndm1y15Dj4lFnXAqFy8AXBcopBaua9xneBc+kfh4bY1oCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269352; c=relaxed/simple; bh=G18Lp5NB/377r4ZItaiEwYiT0g8v5rQu0qz7CTBWzdQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PDNfX7bxsckleXL2YTOZbHV2FH50MaiuXq0r0d7YyHWbfRfi2Pnp2o8VJlcF7VOasNtnW7/iwpfpbdogM/Hhdl9sMi/W/DiWDM9mdtSf2lw6BaCLNa2ct0QjT2SpJyyxueJPt1buMdaZpKaAKPCP1n5Wc/ix6GIfWNtfkqH+buA= 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=SF1ShbAE; arc=none smtp.client-ip=173.37.142.89 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="SF1ShbAE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=11381; q=dns/txt; s=iport; t=1735269350; x=1736478950; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6UMZSEFMCqsQvKnMVoSaYcfhydkuEqOPZPpeuzYbpks=; b=SF1ShbAECWBMudBISbyXAisHDDi3FIf0AWVSC5Q3vpqsf5gjDsHl/tG6 TkDBZ5cJF4Ob1XZtriaxQ/qG8P4eVvdvkpt7GVDK4GpZrVQKdkbH1rRpi w1hgW7lPO+jPzZmmhy+VaoFizk+45nIZ9jH5+UErWDQPl9UIOkI8NE6Ed 4=; X-CSE-ConnectionGUID: 1B8tWTy+QgOeLpPksT5/mQ== X-CSE-MsgGUID: +Vb7aXAqRdyhKWvZ6GLhKQ== X-IPAS-Result: A0ANAABSG25nj5L/Ja1aHAEBAQEBAQcBARIBAQQEAQGBfwcBAQsBhBlDSIxyX4hynhsUgREDVg8BAQEPRAQBAYUHAopuAiY0CQ4BAgQBAQEBAwIDAQEBAQEBAQEBAQELAQEFAQEBAgEHBRQBAQEBAQE5BUmGCIZbAgEDJwsBRhBRKysHEoMBgmUDrw2BeTOBAd4zgW2BSAGFaodfcIR3JxuBSUSBFYE7gT5vhAaHAQSJFZ51SIEhA1ksAVUTDQoLBwWBOToDIgwLDAsUHBUCgR6BAQEUBhUEgQtFPYJKaUk3Ag0CNoIgJFiCTYUXhGGEV4JJVYJ7ghd8gR2CJUADCxgNSBEsNwYOGwY+bgecZEaDbQeBDgGCBQ5VkyiSH6EDhCSBY59jGjOqUph8IqQkhGaBZzqBWzMaCBsVgyJSGQ+IXIVRDQm2EiUyPAIHCwEB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vjsTPj9q owGbpDbkX2zrsWjPXWIreb/0mzm3VBgWMip8JYIHgJyCgFnA2omQ+TA2q8sfpctnqJe0I/1E oKVBCdlJK7ErSSfc22iMyk7AJu2BMYXhSxgZ0QEYw33s0XPlK7zt8/zgbNrJuF/rISODJdcE 5E4Ril3Kq8QE26boGVAMcaVQU4LXE3DuD9i9hGNOFAXF6OMjSSWkjM4VmMDLBUzMxc= IronPort-HdrOrdr: A9a23:8HuaBaFLbdhZ3W/upLqE78eALOsnbusQ8zAXPo5KJiC9Ffbo8P xG88576faZslsssTQb6LK90cq7MBfhHOBOgbX5VI3KNGKNhILrFvAG0WKI+VPd8kPFmtK1rZ 0QEJSXzLbLfCFHZQGQ2njfL+od X-Talos-CUID: 9a23:3rn+CW651VMSCNN3mNssrWREBv8ZYz7kw1DdB1eACn1VFfqQcArF X-Talos-MUID: 9a23:8V0xJQlksUUTz1gNgT+fdnohCs036pSHEXoBgJUlhNe2awNUOxSk2WE= X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.12,268,1728950400"; d="scan'208";a="402842745" Received: from rcdn-l-core-09.cisco.com ([173.37.255.146]) by alln-iport-2.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 27 Dec 2024 03:14:34 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-l-core-09.cisco.com (Postfix) with ESMTP id E3E0A1800022C; Fri, 27 Dec 2024 03:14:33 +0000 (GMT) Received: by cisco.com (Postfix, from userid 392789) id B8FDB20F2004; Thu, 26 Dec 2024 19:14:33 -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 v2 1/5] enic: Refactor RX path common code into helper functions Date: Thu, 26 Dec 2024 19:14:06 -0800 Message-Id: <20241227031410.25607-2-johndale@cisco.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20241227031410.25607-1-johndale@cisco.com> References: <20241227031410.25607-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-09.cisco.com X-Patchwork-Delegate: kuba@kernel.org In order to more easily support future packet receive processing schemes and to simplify the receive path, put common code into helper functions in a separate file. 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/Makefile | 2 +- drivers/net/ethernet/cisco/enic/enic_main.c | 100 ++-------------- drivers/net/ethernet/cisco/enic/enic_rq.c | 120 ++++++++++++++++++++ drivers/net/ethernet/cisco/enic/enic_rq.h | 22 ++++ 4 files changed, 150 insertions(+), 94 deletions(-) create mode 100644 drivers/net/ethernet/cisco/enic/enic_rq.c create mode 100644 drivers/net/ethernet/cisco/enic/enic_rq.h diff --git a/drivers/net/ethernet/cisco/enic/Makefile b/drivers/net/ethernet/cisco/enic/Makefile index c3b6febfdbe4..b3b5196b2dfc 100644 --- a/drivers/net/ethernet/cisco/enic/Makefile +++ b/drivers/net/ethernet/cisco/enic/Makefile @@ -3,5 +3,5 @@ obj-$(CONFIG_ENIC) := enic.o enic-y := enic_main.o vnic_cq.o vnic_intr.o vnic_wq.o \ enic_res.o enic_dev.o enic_pp.o vnic_dev.o vnic_rq.o vnic_vic.o \ - enic_ethtool.o enic_api.o enic_clsf.o + enic_ethtool.o enic_api.o enic_clsf.o enic_rq.o diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 9913952ccb42..33890e26b8e5 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -55,6 +55,7 @@ #include "vnic_vic.h" #include "enic_res.h" #include "enic.h" +#include "enic_rq.h" #include "enic_dev.h" #include "enic_pp.h" #include "enic_clsf.h" @@ -83,7 +84,6 @@ MODULE_AUTHOR("Scott Feldman "); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, enic_id_table); -#define ENIC_LARGE_PKT_THRESHOLD 1000 #define ENIC_MAX_COALESCE_TIMERS 10 /* Interrupt moderation table, which will be used to decide the * coalescing timer values @@ -1330,15 +1330,6 @@ static int enic_rq_alloc_buf(struct vnic_rq *rq) return 0; } -static void enic_intr_update_pkt_size(struct vnic_rx_bytes_counter *pkt_size, - u32 pkt_len) -{ - if (ENIC_LARGE_PKT_THRESHOLD <= pkt_len) - pkt_size->large_pkt_bytes_cnt += pkt_len; - else - pkt_size->small_pkt_bytes_cnt += pkt_len; -} - static bool enic_rxcopybreak(struct net_device *netdev, struct sk_buff **skb, struct vnic_rq_buf *buf, u16 len) { @@ -1358,9 +1349,8 @@ static bool enic_rxcopybreak(struct net_device *netdev, struct sk_buff **skb, return true; } -static void enic_rq_indicate_buf(struct vnic_rq *rq, - struct cq_desc *cq_desc, struct vnic_rq_buf *buf, - int skipped, void *opaque) +void enic_rq_indicate_buf(struct vnic_rq *rq, struct cq_desc *cq_desc, + struct vnic_rq_buf *buf, int skipped, void *opaque) { struct enic *enic = vnic_dev_priv(rq->vdev); struct net_device *netdev = enic->netdev; @@ -1375,7 +1365,6 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq, u8 packet_error; u16 q_number, completed_index, bytes_written, vlan_tci, checksum; u32 rss_hash; - bool outer_csum_ok = true, encap = false; rqstats->packets++; if (skipped) { @@ -1395,15 +1384,7 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq, &ipv4_csum_ok, &ipv6, &ipv4, &ipv4_fragment, &fcs_ok); - if (packet_error) { - - if (!fcs_ok) { - if (bytes_written > 0) - rqstats->bad_fcs++; - else if (bytes_written == 0) - rqstats->pkt_truncated++; - } - + if (enic_rq_pkt_error(rq, packet_error, fcs_ok, bytes_written)) { dma_unmap_single(&enic->pdev->dev, buf->dma_addr, buf->len, DMA_FROM_DEVICE); dev_kfree_skb_any(skb); @@ -1427,66 +1408,11 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq, skb_put(skb, bytes_written); skb->protocol = eth_type_trans(skb, netdev); skb_record_rx_queue(skb, q_number); - if ((netdev->features & NETIF_F_RXHASH) && rss_hash && - (type == 3)) { - switch (rss_type) { - case CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4: - case CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6: - case CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX: - skb_set_hash(skb, rss_hash, PKT_HASH_TYPE_L4); - rqstats->l4_rss_hash++; - break; - case CQ_ENET_RQ_DESC_RSS_TYPE_IPv4: - case CQ_ENET_RQ_DESC_RSS_TYPE_IPv6: - case CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX: - skb_set_hash(skb, rss_hash, PKT_HASH_TYPE_L3); - rqstats->l3_rss_hash++; - break; - } - } - if (enic->vxlan.vxlan_udp_port_number) { - switch (enic->vxlan.patch_level) { - case 0: - if (fcoe) { - encap = true; - outer_csum_ok = fcoe_fc_crc_ok; - } - break; - case 2: - if ((type == 7) && - (rss_hash & BIT(0))) { - encap = true; - outer_csum_ok = (rss_hash & BIT(1)) && - (rss_hash & BIT(2)); - } - break; - } - } - /* Hardware does not provide whole packet checksum. It only - * provides pseudo checksum. Since hw validates the packet - * checksum but not provide us the checksum value. use - * CHECSUM_UNNECESSARY. - * - * In case of encap pkt tcp_udp_csum_ok/tcp_udp_csum_ok is - * inner csum_ok. outer_csum_ok is set by hw when outer udp - * csum is correct or is zero. - */ - if ((netdev->features & NETIF_F_RXCSUM) && !csum_not_calc && - tcp_udp_csum_ok && outer_csum_ok && - (ipv4_csum_ok || ipv6)) { - skb->ip_summed = CHECKSUM_UNNECESSARY; - skb->csum_level = encap; - if (encap) - rqstats->csum_unnecessary_encap++; - else - rqstats->csum_unnecessary++; - } + enic_rq_set_skb_flags(rq, type, rss_hash, rss_type, fcoe, fcoe_fc_crc_ok, + vlan_stripped, csum_not_calc, tcp_udp_csum_ok, ipv6, + ipv4_csum_ok, vlan_tci, skb); - if (vlan_stripped) { - __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci); - rqstats->vlan_stripped++; - } skb_mark_napi_id(skb, &enic->napi[rq->index]); if (!(netdev->features & NETIF_F_GRO)) netif_receive_skb(skb); @@ -1507,18 +1433,6 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq, } } -static int enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc, - u8 type, u16 q_number, u16 completed_index, void *opaque) -{ - 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); - - return 0; -} - static void enic_set_int_moderation(struct enic *enic, struct vnic_rq *rq) { unsigned int intr = enic_msix_rq_intr(enic, rq->index); diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.c b/drivers/net/ethernet/cisco/enic/enic_rq.c new file mode 100644 index 000000000000..571af8f31470 --- /dev/null +++ b/drivers/net/ethernet/cisco/enic/enic_rq.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright 2024 Cisco Systems, Inc. All rights reserved. + +#include +#include +#include "enic.h" +#include "enic_rq.h" +#include "vnic_rq.h" +#include "cq_enet_desc.h" + +#define ENIC_LARGE_PKT_THRESHOLD 1000 + +void enic_intr_update_pkt_size(struct vnic_rx_bytes_counter *pkt_size, + u32 pkt_len) +{ + if (pkt_len >= ENIC_LARGE_PKT_THRESHOLD) + pkt_size->large_pkt_bytes_cnt += pkt_len; + else + pkt_size->small_pkt_bytes_cnt += pkt_len; +} + +void enic_rq_set_skb_flags(struct vnic_rq *vrq, u8 type, u32 rss_hash, u8 rss_type, u8 fcoe, + u8 fcoe_fc_crc_ok, u8 vlan_stripped, u8 csum_not_calc, + u8 tcp_udp_csum_ok, u8 ipv6, u8 ipv4_csum_ok, u16 vlan_tci, + struct sk_buff *skb) +{ + struct enic *enic = vnic_dev_priv(vrq->vdev); + struct net_device *netdev = enic->netdev; + struct enic_rq_stats *rqstats = &enic->rq[vrq->index].stats; + bool outer_csum_ok = true, encap = false; + + if ((netdev->features & NETIF_F_RXHASH) && rss_hash && type == 3) { + switch (rss_type) { + case CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4: + case CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6: + case CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX: + skb_set_hash(skb, rss_hash, PKT_HASH_TYPE_L4); + rqstats->l4_rss_hash++; + break; + case CQ_ENET_RQ_DESC_RSS_TYPE_IPv4: + case CQ_ENET_RQ_DESC_RSS_TYPE_IPv6: + case CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX: + skb_set_hash(skb, rss_hash, PKT_HASH_TYPE_L3); + rqstats->l3_rss_hash++; + break; + } + } + if (enic->vxlan.vxlan_udp_port_number) { + switch (enic->vxlan.patch_level) { + case 0: + if (fcoe) { + encap = true; + outer_csum_ok = fcoe_fc_crc_ok; + } + break; + case 2: + if (type == 7 && (rss_hash & BIT(0))) { + encap = true; + outer_csum_ok = (rss_hash & BIT(1)) && + (rss_hash & BIT(2)); + } + break; + } + } + + /* Hardware does not provide whole packet checksum. It only + * provides pseudo checksum. Since hw validates the packet + * checksum but not provide us the checksum value. use + * CHECSUM_UNNECESSARY. + * + * In case of encap pkt tcp_udp_csum_ok/tcp_udp_csum_ok is + * inner csum_ok. outer_csum_ok is set by hw when outer udp + * csum is correct or is zero. + */ + if ((netdev->features & NETIF_F_RXCSUM) && !csum_not_calc && + tcp_udp_csum_ok && outer_csum_ok && (ipv4_csum_ok || ipv6)) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + skb->csum_level = encap; + if (encap) + rqstats->csum_unnecessary_encap++; + else + rqstats->csum_unnecessary++; + } + + if (vlan_stripped) { + __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci); + rqstats->vlan_stripped++; + } +} + +int enic_rq_pkt_error(struct vnic_rq *vrq, u8 packet_error, u8 fcs_ok, u16 bytes_written) +{ + struct enic *enic = vnic_dev_priv(vrq->vdev); + struct enic_rq_stats *rqstats = &enic->rq[vrq->index].stats; + int ret = 0; + + if (packet_error) { + if (!fcs_ok) { + if (bytes_written > 0) { + rqstats->bad_fcs++; + ret = 1; + } else if (bytes_written == 0) { + rqstats->pkt_truncated++; + ret = 2; + } + } + } + return ret; +} + +int enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc, + u8 type, u16 q_number, u16 completed_index, void *opaque) +{ + 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); + + return 0; +} diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.h b/drivers/net/ethernet/cisco/enic/enic_rq.h new file mode 100644 index 000000000000..46ab75fd74a0 --- /dev/null +++ b/drivers/net/ethernet/cisco/enic/enic_rq.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved. + * Copyright 2007 Nuova Systems, Inc. All rights reserved. + */ + +#ifndef _ENIC_RQ_H_ +#define _ENIC_RQ_H_ + +void enic_intr_update_pkt_size(struct vnic_rx_bytes_counter *pkt_size, + u32 pkt_len); +void enic_rq_set_skb_flags(struct vnic_rq *rq, u8 type, u32 rss_hash, u8 rss_type, + u8 fcoe, u8 fcoe_fc_crc_ok, u8 vlan_stripped, + u8 csum_not_calc, u8 tcp_udp_csum_ok, u8 ipv6, + u8 ipv4_csum_ok, u16 vlan_tci, struct sk_buff *skb); +int enic_rq_pkt_error(struct vnic_rq *rq, u8 packet_error, u8 fcs_ok, + u16 bytes_written); +int enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc, + u8 type, u16 q_number, u16 completed_index, void *opaque); +void enic_rq_indicate_buf(struct vnic_rq *rq, struct cq_desc *cq_desc, + struct vnic_rq_buf *buf, int skipped, void *opaque); +#endif /* _ENIC_RQ_H_ */ From patchwork Fri Dec 27 03:14:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Daley X-Patchwork-Id: 13921515 X-Patchwork-Delegate: kuba@kernel.org Received: from alln-iport-7.cisco.com (alln-iport-7.cisco.com [173.37.142.94]) (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 66C121CA84 for ; Fri, 27 Dec 2024 03:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.142.94 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269345; cv=none; b=e6t10W0Jx105tPM+C8nuPmPSdQT20VFo8EhqcaVSb8fi0Qk6myWh2jvYczluyUXzG98/lC8UPv3S0zgMiBnRuPhvgYFoMvAKYjsjp7bUdgaVJvEwJFU9tmGKh39dSn+r9+Lk3Tgj/aN1U7HbeqLDsw6bYrsEYW0JhCEwSZ9IlGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269345; c=relaxed/simple; bh=T4hWg15WZP+lApfrr9Y/thSG09sNb0ZXX0qr/vwtnN8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rRLtPK84BviHcpG8QV+PYnsM+X2Doek/UWa9xyDZvyS+yJiRIH4zYkLb1NASFQP/ra+cVb/aZM7zpvJgTZsN685ER4GjoR9z8zUAzDZ1BUYKMgz7OGHN2ARWEJEFfe8b75p9wSxV9Nj/xX7kprhfVGjebx3A37j3j346Rv9upzg= 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=WfP/klk5; arc=none smtp.client-ip=173.37.142.94 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="WfP/klk5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=2510; q=dns/txt; s=iport; t=1735269343; x=1736478943; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mJaW4D8IoGJsrpAQ4RXWrveI+HMg7JYPf5VPwYrwcqs=; b=WfP/klk5G4AomOjfS8bb7J4Pzr/KNuDPnU01P9NBcQ6SX4FXfyFx7y7g IGzJ24ZJXYqyTe1EM8XgaLHoAGw/GuDKgWY2KSQx0vvnnTxmiWeGKMSw2 byfrCAtClJMQgiWUzHEtOuUeTsDY13uYIH+tiO+AI98a9ltLzLHl8Ff7u A=; X-CSE-ConnectionGUID: 1kgAxxt6SAiaV9R/RzGxHQ== X-CSE-MsgGUID: 4Amo/IZDRdqxT3jLxyH3Aw== X-IPAS-Result: A0ANAADbGm5nj5P/Ja1aHAEBAQEBAQcBARIBAQQEAQGBfwcBAQsBhBlDSIxyX6EwhV2BJQNWDwEBAQ9EBAEBhQcCim4CJjQJDgECBAEBAQEDAgMBAQEBAQEBAQEBAQsBAQUBAQECAQcFFAEBAQEBATkFDjuGCIZbAgEDJwsBRhBRKysHEoMBgmUDrxWBeTOBAd4zgW2BSAGFaodfcIR3JxuBSUSCUIE+b4UQhXcEiRWedUiBIQNZLAFVEw0KCwcFgTk6AyIMCwwLFBwVAoEeg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zoBZPmqgOvFlDyFdVDyoSRdP+j KbuVeJtCH17YSHCgUxfOt7Z5yEWIU7ISY6Nuhf8NYYmX3SJXFXblByCnGbJt4wXrGAikLskJ bCQetu2AHARBMxPlWXtGr1Gju96nXFjnQs/oKwXKTz5iNJyg1bIGd843KemNLtRAF6s+V+Mq o0ObaNmNT0CD7GhPkE7DrL/3XhRcCBkXsqpwyCmXuWCOQFhUHowEOPcxKhpeopu2cxoehTgo BmAtrtj4AOn3xXvcFzSAlg6Me+Hdcgk9xoTY3dzVWtELlB/Ou5DGo9DLMNvJdHKNYVLkZZJc hXyU57fW64TEWWap2t1gFuUhNUKSSlHTDmmZ0KNCAXTtbY5L+AV0rcIpjfSyRQ= IronPort-HdrOrdr: A9a23:l2k8NqH9qB38ANE5pLqE78eALOsnbusQ8zAXPo5KJiC9Ffbo8P xG88576faZslsssTQb6LK90cq7MBfhHOBOgbX5VI3KNGKNhILrFvAG0WKI+VPd8kPFmtK1rZ 0QEJSXzLbLfCFHZQGQ2njfL+od X-Talos-CUID: 9a23:C/pLHWnT/s7fkylp0dTweLaisELXOSTew17AM1PmMk9oQYPEcxiq6ox0s/M7zg== X-Talos-MUID: 9a23:AKT6fgyUtoED6NMmWZ8MMkn8O0eaqPiHDUdKsKcqgcWdJRArORONnRTsa5Byfw== X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.12,268,1728950400"; d="scan'208";a="404699745" Received: from rcdn-l-core-10.cisco.com ([173.37.255.147]) by alln-iport-7.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 27 Dec 2024 03:14:34 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-l-core-10.cisco.com (Postfix) with ESMTP id E59EF1800026B; Fri, 27 Dec 2024 03:14:33 +0000 (GMT) Received: by cisco.com (Postfix, from userid 392789) id B97B520F2005; Thu, 26 Dec 2024 19:14:33 -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 v2 2/5] enic: Remove an unnecessary parameter from function enic_queue_rq_desc Date: Thu, 26 Dec 2024 19:14:07 -0800 Message-Id: <20241227031410.25607-3-johndale@cisco.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20241227031410.25607-1-johndale@cisco.com> References: <20241227031410.25607-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-10.cisco.com X-Patchwork-Delegate: kuba@kernel.org The function enic_queue_rq_desc has a parameter os_buf_index which was only called with a hard coded 0. Remove it. 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_main.c | 8 ++------ drivers/net/ethernet/cisco/enic/enic_res.h | 10 +++------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 33890e26b8e5..f8d0011486d7 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -1301,14 +1301,11 @@ static int enic_rq_alloc_buf(struct vnic_rq *rq) struct net_device *netdev = enic->netdev; struct sk_buff *skb; unsigned int len = netdev->mtu + VLAN_ETH_HLEN; - unsigned int os_buf_index = 0; dma_addr_t dma_addr; struct vnic_rq_buf *buf = rq->to_use; if (buf->os_buf) { - enic_queue_rq_desc(rq, buf->os_buf, os_buf_index, buf->dma_addr, - buf->len); - + enic_queue_rq_desc(rq, buf->os_buf, buf->dma_addr, buf->len); return 0; } skb = netdev_alloc_skb_ip_align(netdev, len); @@ -1324,8 +1321,7 @@ static int enic_rq_alloc_buf(struct vnic_rq *rq) return -ENOMEM; } - enic_queue_rq_desc(rq, skb, os_buf_index, - dma_addr, len); + enic_queue_rq_desc(rq, skb, dma_addr, len); return 0; } diff --git a/drivers/net/ethernet/cisco/enic/enic_res.h b/drivers/net/ethernet/cisco/enic/enic_res.h index b8ee42d297aa..dad5c45b684a 100644 --- a/drivers/net/ethernet/cisco/enic/enic_res.h +++ b/drivers/net/ethernet/cisco/enic/enic_res.h @@ -107,19 +107,15 @@ static inline void enic_queue_wq_desc_tso(struct vnic_wq *wq, } static inline void enic_queue_rq_desc(struct vnic_rq *rq, - void *os_buf, unsigned int os_buf_index, - dma_addr_t dma_addr, unsigned int len) + void *os_buf, dma_addr_t dma_addr, unsigned int len) { struct rq_enet_desc *desc = vnic_rq_next_desc(rq); - u64 wrid = 0; - u8 type = os_buf_index ? - RQ_ENET_TYPE_NOT_SOP : RQ_ENET_TYPE_ONLY_SOP; rq_enet_desc_enc(desc, (u64)dma_addr | VNIC_PADDR_TARGET, - type, (u16)len); + RQ_ENET_TYPE_ONLY_SOP, (u16)len); - vnic_rq_post(rq, os_buf, os_buf_index, dma_addr, len, wrid); + vnic_rq_post(rq, os_buf, 0, dma_addr, len, 0); } struct enic; From patchwork Fri Dec 27 03:14:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Daley X-Patchwork-Id: 13921514 X-Patchwork-Delegate: kuba@kernel.org Received: from rcdn-iport-8.cisco.com (rcdn-iport-8.cisco.com [173.37.86.79]) (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 4B314F50F for ; Fri, 27 Dec 2024 03:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.86.79 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269345; cv=none; b=nDgtQnTtMDpR3w6fa3kyLImLB5zncx2zJpqOzgFotKa29++kQ0lSuMNfTQnaPzxF4hcIDoHhDgH1YmVeypYLQWvgRIDKKdUpjOzByEnh5BLTOfKWeNYSSd32QPGSjwPI8th7BaRaugAXzAovsMB0YjVkNAgpIvbjM6ksx6wkhfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269345; c=relaxed/simple; bh=NuqZEEZYpyP7CXsdCdrvAvNGYHjuVQ4ARqCZDeRC1V0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=drXSQiXdi8dp3nFuGRy4zclGybU6SMygRwuP4k13c98E89dw03fKaY4DyTw3i9qhZx0BM3U2OA5vjuJNAQmUdQVSNqk62MEVZ9z9sLFnlO0cEF6NImqoXcqocQBIkVApp2nfJzpAJupGivsblh2VnoRBTivMo5VkOL6gX4pJQXs= 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=chCCE+NV; arc=none smtp.client-ip=173.37.86.79 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="chCCE+NV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=4422; q=dns/txt; s=iport; t=1735269344; x=1736478944; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CwJxi8Cye5/I6LCh20clnomwhtRsYxMDQYpTcQE5Aq4=; b=chCCE+NVGNcQTIUc00fpEU4fsiuwycnMizvLC0bc3gGzi8RBs5Fb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q8iCAn3aMqURp+VTK00Qz MVAchUpaT29xOWt2rWSH7wEasQLdKEHPasFsX1miDWcBvE8TNWaGuPB5MRT23E7gcUm8fT2P pVCL2EwKk6dPlsWZgd/5JEWxI9EglH9dD1epFuRqII84nPYy0p6172F3N/9II3TFZUKxBvCz o7A12D/PT0WNfOf8B6EyHelrLKXnyLKabtHQdVU8dYv2jV/3Fc7BBQIWF6TrfCnh0u6XNxDb UoZ5kIGoKQv8UW5Q8XVUBq/r3qJ+BUbXrJ4EPAw4SmOx7DS7gLfAXILJhZIbtA8udB1QzE22 lKXt9f0Azopu739YWqU/LqSrBuoNCQVJHNEbigBJSMD7sXvrZ8bkB3CVJBgHbSzg9mzHiv/q w1mtwAkjLkVyMpO3KKh8BWe2nSnp4PCSUg+4QC/sn+Z0z6VrbWNP+SAgWU3J94ZRGpFZjFtZ EQ5pvU= IronPort-HdrOrdr: A9a23:wPf7LalGmVZaG4QiY1uZEaJfi73pDfIr3DAbv31ZSRFFG/FwWf rAoB19726StN9/YhAdcLy7VZVoBEmsl6KdgrNhWYtKIjOHhILAFugLhuHfKn/bakjDH4Vmu5 uIHZITNDSJNykYsS4/izPIaurJB7K8gcaVuds= X-Talos-CUID: 9a23:6EDI4WuLvfwV3lV+R1jzdKbK6IssL3755luOGnbgU0NNT5CrCliL4qRNxp8= X-Talos-MUID: 9a23:lC3gXgr5Ujzt+XYTjKMezzVkC+tk4ouuMWQMq5APkZTcNy1BCg7I2Q== X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.12,268,1728950400"; d="scan'208";a="291887252" Received: from rcdn-l-core-11.cisco.com ([173.37.255.148]) by rcdn-iport-8.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 27 Dec 2024 03:14:34 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-l-core-11.cisco.com (Postfix) with ESMTP id DD65B18000256; Fri, 27 Dec 2024 03:14:33 +0000 (GMT) Received: by cisco.com (Postfix, from userid 392789) id B9EC520F2006; Thu, 26 Dec 2024 19:14:33 -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 v2 3/5] enic: Use function pointers for buf alloc, free and RQ service Date: Thu, 26 Dec 2024 19:14:08 -0800 Message-Id: <20241227031410.25607-4-johndale@cisco.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20241227031410.25607-1-johndale@cisco.com> References: <20241227031410.25607-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-11.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. 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 f8d0011486d7..45ab6b670563 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -1519,7 +1519,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. @@ -1647,7 +1647,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. @@ -1882,6 +1882,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"); @@ -1900,7 +1904,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"); @@ -1939,7 +1943,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: @@ -1998,7 +2002,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; } From patchwork Fri Dec 27 03:14:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Daley X-Patchwork-Id: 13921516 X-Patchwork-Delegate: kuba@kernel.org Received: from alln-iport-6.cisco.com (alln-iport-6.cisco.com [173.37.142.93]) (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 1EABC8821 for ; Fri, 27 Dec 2024 03:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.142.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269345; cv=none; b=AOQJUZsCOKwJgr7pYo/jENQI5QJDKxnOeTim8HABc9OXftiPmdkN2iu4hSEDt+ziwhbqSieSN+BBdE4zQV8uVqGfuZ4mPQHmRiS0qSRJpiXpzT7lFTqnaktqUA7fkr+//016G7Jk8pK4vy3ShWgmf9i3jq0MTLvtCrKpUg03sw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269345; c=relaxed/simple; bh=oz2fWwvx81rFge50egn/1VlY2jaPRMGlPFcGhZXOQCo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fII8oIpVB3P/QFUyup5dO9roJKsryZQMQI6E5YLuoeOkXavJW45iPp2Z6lTeBQ8zno2yL1sMV0l5pK79ihUlda1mI8dOulSLBlr0ZdKk19cKMPqlzjzeyZPyp0jXI76IZ/m3GtaipmR+OzG4dw2bFR5yBrk2ItK/vdJm4NGxs3U= 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=XPIR7KHm; arc=none smtp.client-ip=173.37.142.93 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="XPIR7KHm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=11892; q=dns/txt; s=iport; t=1735269343; x=1736478943; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xH1rjzpEFaJGZH+Owb7ksqdWelNWS2+mOAi0VL0Hhjw=; b=XPI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QpuW6zA== X-Talos-CUID: 9a23:0KFvH25TnsnpgPpJNNss1mkNFdl1MX/h7S38LRfnVFd0b+zJcArF X-Talos-MUID: 9a23:VQ7c3Q8j3f1RYjylvInst/qQf4Bxu5TwNmtdqrUtkdaNMylWB2uNqx3iFw== X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.12,268,1728950400"; d="scan'208";a="404613181" Received: from rcdn-l-core-12.cisco.com ([173.37.255.149]) by alln-iport-6.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 27 Dec 2024 03:14:34 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-l-core-12.cisco.com (Postfix) with ESMTP id E828B180001D3; Fri, 27 Dec 2024 03:14:33 +0000 (GMT) Received: by cisco.com (Postfix, from userid 392789) id C187A20F2007; Thu, 26 Dec 2024 19:14:33 -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 v2 4/5] enic: Use the Page Pool API for RX when MTU is less than page size Date: Thu, 26 Dec 2024 19:14:09 -0800 Message-Id: <20241227031410.25607-5-johndale@cisco.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20241227031410.25607-1-johndale@cisco.com> References: <20241227031410.25607-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-12.cisco.com X-Patchwork-Delegate: kuba@kernel.org The Page Pool API improves bandwidth and CPU overhead by recycling pages instead of allocating new buffers in the driver. Make use of page pool fragment allocation for smaller MTUs so that multiple packets can share a page. Added 'pp_alloc_error' per RQ ethtool statistic to count page_pool_dev_alloc() failures. 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 | 10 ++ .../net/ethernet/cisco/enic/enic_ethtool.c | 1 + drivers/net/ethernet/cisco/enic/enic_main.c | 51 ++++++- drivers/net/ethernet/cisco/enic/enic_rq.c | 141 ++++++++++++++++++ drivers/net/ethernet/cisco/enic/enic_rq.h | 5 + drivers/net/ethernet/cisco/enic/vnic_rq.h | 2 + 6 files changed, 204 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index 51f80378d928..19e22aba71a8 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -17,6 +17,8 @@ #include "vnic_nic.h" #include "vnic_rss.h" #include +#include +#include #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" @@ -158,6 +160,7 @@ struct enic_rq_stats { u64 pkt_truncated; /* truncated pkts */ u64 no_skb; /* out of skbs */ u64 desc_skip; /* Rx pkt went into later buffer */ + u64 pp_alloc_error; /* page alloc error */ }; struct enic_wq { @@ -169,6 +172,7 @@ struct enic_wq { struct enic_rq { struct vnic_rq vrq; struct enic_rq_stats stats; + struct page_pool *pool; } ____cacheline_aligned; /* Per-instance private data structure */ @@ -231,8 +235,14 @@ struct enic { void *opaque); int (*rq_alloc_buf)(struct vnic_rq *rq); void (*rq_free_buf)(struct vnic_rq *rq, struct vnic_rq_buf *buf); + void (*rq_cleanup)(struct enic_rq *rq); }; +static inline unsigned int get_max_pkt_len(struct enic *enic) +{ + return enic->netdev->mtu + VLAN_ETH_HLEN; +} + static inline struct net_device *vnic_get_netdev(struct vnic_dev *vdev) { struct enic *enic = vdev->priv; diff --git a/drivers/net/ethernet/cisco/enic/enic_ethtool.c b/drivers/net/ethernet/cisco/enic/enic_ethtool.c index d607b4f0542c..799f44b95bfc 100644 --- a/drivers/net/ethernet/cisco/enic/enic_ethtool.c +++ b/drivers/net/ethernet/cisco/enic/enic_ethtool.c @@ -51,6 +51,7 @@ static const struct enic_stat enic_per_rq_stats[] = { ENIC_PER_RQ_STAT(napi_repoll), ENIC_PER_RQ_STAT(no_skb), ENIC_PER_RQ_STAT(desc_skip), + ENIC_PER_RQ_STAT(pp_alloc_error), }; #define NUM_ENIC_PER_RQ_STATS ARRAY_SIZE(enic_per_rq_stats) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 45ab6b670563..5bfd89749237 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -1282,6 +1282,11 @@ static int enic_get_vf_port(struct net_device *netdev, int vf, return -EMSGSIZE; } +/* nothing to do for buffers based allocation */ +static void enic_rq_buf_cleanup(struct enic_rq *rq) +{ +} + static void enic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf) { struct enic *enic = vnic_dev_priv(rq->vdev); @@ -1881,10 +1886,33 @@ static int enic_open(struct net_device *netdev) struct enic *enic = netdev_priv(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; + bool use_page_pool; + struct page_pool_params pp_params = { 0 }; + + /* Use the Page Pool API for MTUs <= PAGE_SIZE */ + use_page_pool = (get_max_pkt_len(enic) <= PAGE_SIZE); + + if (use_page_pool) { + /* use the page pool API */ + pp_params.order = 0; + pp_params.pool_size = enic->config.rq_desc_count; + pp_params.nid = dev_to_node(&enic->pdev->dev); + pp_params.dev = &enic->pdev->dev; + pp_params.dma_dir = DMA_FROM_DEVICE; + pp_params.max_len = PAGE_SIZE; + pp_params.netdev = netdev; + pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV; + + enic->rq_buf_service = enic_rq_indicate_page; + enic->rq_alloc_buf = enic_rq_alloc_page; + enic->rq_free_buf = enic_rq_free_page; + enic->rq_cleanup = enic_rq_page_cleanup; + } else { + enic->rq_buf_service = enic_rq_indicate_buf; + enic->rq_alloc_buf = enic_rq_alloc_buf; + enic->rq_free_buf = enic_free_rq_buf; + enic->rq_cleanup = enic_rq_buf_cleanup; + } err = enic_request_intr(enic); if (err) { @@ -1902,6 +1930,13 @@ static int enic_open(struct net_device *netdev) } for (i = 0; i < enic->rq_count; i++) { + /* create a page pool for each RQ */ + if (use_page_pool) { + pp_params.napi = &enic->napi[i]; + pp_params.queue_idx = i; + enic->rq[i].pool = page_pool_create(&pp_params); + } + /* enable rq before updating rq desc */ vnic_rq_enable(&enic->rq[i].vrq); vnic_rq_fill(&enic->rq[i].vrq, enic->rq_alloc_buf); @@ -1942,8 +1977,10 @@ static int enic_open(struct net_device *netdev) err_out_free_rq: for (i = 0; i < enic->rq_count; i++) { ret = vnic_rq_disable(&enic->rq[i].vrq); - if (!ret) + if (!ret) { vnic_rq_clean(&enic->rq[i].vrq, enic->rq_free_buf); + enic->rq_cleanup(&enic->rq[i]); + } } enic_dev_notify_unset(enic); err_out_free_intr: @@ -2001,8 +2038,10 @@ 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++) + for (i = 0; i < enic->rq_count; i++) { vnic_rq_clean(&enic->rq[i].vrq, enic->rq_free_buf); + enic->rq_cleanup(&enic->rq[i]); + } 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 ae2ab5af87e9..4d520af3033d 100644 --- a/drivers/net/ethernet/cisco/enic/enic_rq.c +++ b/drivers/net/ethernet/cisco/enic/enic_rq.c @@ -7,6 +7,7 @@ #include "enic_rq.h" #include "vnic_rq.h" #include "cq_enet_desc.h" +#include "enic_res.h" #define ENIC_LARGE_PKT_THRESHOLD 1000 @@ -118,3 +119,143 @@ int enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc, return 0; } + +void enic_rq_page_cleanup(struct enic_rq *rq) +{ + struct vnic_rq *vrq = &rq->vrq; + struct enic *enic = vnic_dev_priv(vrq->vdev); + struct napi_struct *napi = &enic->napi[vrq->index]; + + napi_free_frags(napi); + page_pool_destroy(rq->pool); +} + +void enic_rq_free_page(struct vnic_rq *vrq, struct vnic_rq_buf *buf) +{ + struct enic *enic = vnic_dev_priv(vrq->vdev); + struct enic_rq *rq = &enic->rq[vrq->index]; + + if (!buf->os_buf) + return; + + page_pool_put_page(rq->pool, (struct page *)buf->os_buf, + get_max_pkt_len(enic), true); + buf->os_buf = NULL; +} + +int enic_rq_alloc_page(struct vnic_rq *vrq) +{ + struct enic *enic = vnic_dev_priv(vrq->vdev); + struct enic_rq *rq = &enic->rq[vrq->index]; + struct enic_rq_stats *rqstats = &rq->stats; + struct vnic_rq_buf *buf = vrq->to_use; + dma_addr_t dma_addr; + struct page *page; + unsigned int offset = 0; + unsigned int len; + unsigned int truesize; + + len = get_max_pkt_len(enic); + truesize = len; + + if (buf->os_buf) { + dma_addr = buf->dma_addr; + } else { + page = page_pool_dev_alloc(rq->pool, &offset, &truesize); + if (unlikely(!page)) { + rqstats->pp_alloc_error++; + return -ENOMEM; + } + buf->os_buf = (void *)page; + buf->offset = offset; + buf->truesize = truesize; + dma_addr = page_pool_get_dma_addr(page) + offset; + } + + enic_queue_rq_desc(vrq, buf->os_buf, dma_addr, len); + + return 0; +} + +/* Unmap and free pages fragments making up the error packet. + */ +static void enic_rq_error_reset(struct vnic_rq *vrq) +{ + struct enic *enic = vnic_dev_priv(vrq->vdev); + struct napi_struct *napi = &enic->napi[vrq->index]; + + napi_free_frags(napi); +} + +void enic_rq_indicate_page(struct vnic_rq *vrq, struct cq_desc *cq_desc, + struct vnic_rq_buf *buf, int skipped, void *opaque) +{ + struct enic *enic = vnic_dev_priv(vrq->vdev); + struct sk_buff *skb; + struct enic_rq *rq = &enic->rq[vrq->index]; + struct enic_rq_stats *rqstats = &rq->stats; + struct vnic_cq *cq = &enic->cq[enic_cq_rq(enic, vrq->index)]; + struct napi_struct *napi; + u8 type, color, eop, sop, ingress_port, vlan_stripped; + u8 fcoe, fcoe_sof, fcoe_fc_crc_ok, fcoe_enc_error, fcoe_eof; + u8 tcp_udp_csum_ok, udp, tcp, ipv4_csum_ok; + u8 ipv6, ipv4, ipv4_fragment, fcs_ok, rss_type, csum_not_calc; + u8 packet_error; + u16 q_number, completed_index, bytes_written, vlan_tci, checksum; + u32 rss_hash; + + if (skipped) { + rqstats->desc_skip++; + return; + } + + if (!buf || !buf->dma_addr) { + net_warn_ratelimited("%s: !buf || !buf->dma_addr!!\n", + enic->netdev->name); + return; + } + + cq_enet_rq_desc_dec((struct cq_enet_rq_desc *)cq_desc, + &type, &color, &q_number, &completed_index, + &ingress_port, &fcoe, &eop, &sop, &rss_type, + &csum_not_calc, &rss_hash, &bytes_written, + &packet_error, &vlan_stripped, &vlan_tci, &checksum, + &fcoe_sof, &fcoe_fc_crc_ok, &fcoe_enc_error, + &fcoe_eof, &tcp_udp_csum_ok, &udp, &tcp, + &ipv4_csum_ok, &ipv6, &ipv4, &ipv4_fragment, + &fcs_ok); + + if (enic_rq_pkt_error(vrq, packet_error, fcs_ok, bytes_written)) { + enic_rq_error_reset(vrq); + return; + } + + napi = &enic->napi[vrq->index]; + skb = napi_get_frags(napi); + if (unlikely(!skb)) { + net_warn_ratelimited("%s: skb alloc error rq[%d], desc[%d]\n", + enic->netdev->name, vrq->index, + completed_index); + rqstats->no_skb++; + return; + } + + dma_sync_single_for_cpu(&enic->pdev->dev, buf->dma_addr, bytes_written, + DMA_FROM_DEVICE); + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, (struct page *)buf->os_buf, + buf->offset, bytes_written, buf->truesize); + + buf->os_buf = NULL; + buf->dma_addr = 0; + buf = buf->next; + + enic_rq_set_skb_flags(vrq, type, rss_hash, rss_type, fcoe, fcoe_fc_crc_ok, + vlan_stripped, csum_not_calc, tcp_udp_csum_ok, ipv6, + ipv4_csum_ok, vlan_tci, skb); + if (enic->rx_coalesce_setting.use_adaptive_rx_coalesce) + enic_intr_update_pkt_size(&cq->pkt_size_counter, skb->len); + skb_mark_for_recycle(skb); + skb_record_rx_queue(skb, vrq->index); + napi_gro_frags(napi); + rqstats->packets++; +} diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.h b/drivers/net/ethernet/cisco/enic/enic_rq.h index 46ab75fd74a0..f429f31b6172 100644 --- a/drivers/net/ethernet/cisco/enic/enic_rq.h +++ b/drivers/net/ethernet/cisco/enic/enic_rq.h @@ -19,4 +19,9 @@ int enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc, u8 type, u16 q_number, u16 completed_index, void *opaque); void enic_rq_indicate_buf(struct vnic_rq *rq, struct cq_desc *cq_desc, struct vnic_rq_buf *buf, int skipped, void *opaque); +void enic_rq_indicate_page(struct vnic_rq *rq, struct cq_desc *cq_desc, + struct vnic_rq_buf *buf, int skipped, void *opaque); +int enic_rq_alloc_page(struct vnic_rq *rq); +void enic_rq_free_page(struct vnic_rq *rq, struct vnic_rq_buf *buf); +void enic_rq_page_cleanup(struct enic_rq *rq); #endif /* _ENIC_RQ_H_ */ diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.h b/drivers/net/ethernet/cisco/enic/vnic_rq.h index 0bc595abc03b..2ee4be2b9a34 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_rq.h +++ b/drivers/net/ethernet/cisco/enic/vnic_rq.h @@ -61,6 +61,8 @@ struct vnic_rq_buf { unsigned int index; void *desc; uint64_t wr_id; + unsigned int offset; + unsigned int truesize; }; enum enic_poll_state { From patchwork Fri Dec 27 03:14:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Daley X-Patchwork-Id: 13921517 X-Patchwork-Delegate: kuba@kernel.org Received: from alln-iport-2.cisco.com (alln-iport-2.cisco.com [173.37.142.89]) (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 4700250276 for ; Fri, 27 Dec 2024 03:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.142.89 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269349; cv=none; b=LTniKN/4bo5P6ucaeWRTpUHOoKy3Fhj8nxDjxo+1JZWNPTSn0h5gru1LEnPhpuy/e9bmRPA3K38cTjjHzY86oYWH6y47K+S/h+hYqfh7h0O0oePLswf8dE9WRaUJxZ5ZUCfaJVe3XouUX0Xqk1YcGRuiKx+nONSAQIlDIRJ7YY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735269349; c=relaxed/simple; bh=QzqODc2yYFu5IqkEV2LuefBllbBxuQeUrTCk6sDnI/Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mrXOTwXN8mX5DMck+VGrI5MetWyP04rqAZ5kcwlXrIhsiZkBfwwNBLYTBCUjdF72LZ+vpE/GWZhHpFlP6gprez6MZLJMxFK4+OyRxUSVQBwnD/tol6pUv+ilySEJp2RnyhtDg4DMF6HCXLlnJwkBOzk5uTCxhltJWopJ04teyrY= 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=NhuWExsY; arc=none smtp.client-ip=173.37.142.89 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="NhuWExsY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=2543; q=dns/txt; s=iport; t=1735269348; x=1736478948; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lnjinSy/aS7zRu5fiK4HVq2lup4kqm6HcWbCh/R+te4=; b=NhuWExsY0On5H6kGlA6cvjI5PbmbrZ1gY2G8IzSon3DpkOlqTIROeCrF +TgodpeB1mDNiMHnh6HwGccukP9iV6GI0BTLr9AK6UEps1Mhd5ZGfoeQV Pb0QCS4lrV0wNcrYHrQROukYj7UAQMHnSRij5wU6+MbiWIGR7QHEJ9yKP s=; X-CSE-ConnectionGUID: 3VyCpJEyQbeO5vIHBFVGDQ== X-CSE-MsgGUID: MS0+egy1TDSuU+E47eBJSQ== X-IPAS-Result: A0ANAABSG25nj4v/Ja1aHAEBAQEBAQcBARIBAQQEAQGBfwcBAQsBhBlDSIxyX6cNFIERA1YPAQEBD0QEAQGFBwKKbgImNAkOAQIEAQEBAQMCAwEBAQEBAQEBAQEBCwEBBQEBAQIBBwUUAQEBAQEBOQUOO4YIhlsCAQMnCwE0EhBRKysHEoMBgmUDrw2BeTOBAd4zgW2BSAGFaodfcIR3JxuBSUSCUIE+b4QqZoV3BIkVnnVIgSEDWSwBVRMNCgsHBYE5OgMiDAsMCxQcFQKBHoEBARQGFQSBC0U9gkppSTcCDQI2giAkWIJNhReEYYRXgklVgnuCF3yBHYIlQAMLGA1IESw3Bg4bBj5uB5xkRoNzAYEOfKc0oQOEJIFjn2MaM6pSmHwioztphGaBZzqBWzMaCBsVgyJSGQ+OKgMNCbYSJTI8AgcLAQEDCZE3AQE IronPort-Data: A9a23:Zcxhu6PcSmK8rBrvrR1Bl8FynXyQoLVcMsEvi/4bfWQNrUojhWBSm mMfX2/TM6yDYmLwfd11a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kAhUw4AOm3RXvcFzWAlg9M+mHdcgk8hoG0dkEYQ3AN44LPd33tP93mlpeVeVPydGPOtYvE KBfJ57RX6gQItkFkhxEBaTAQEVZXEzDrWqz0+CNMFDTo7YIq9T1x+LZ IronPort-HdrOrdr: A9a23:KQLnia1xNi3quwob5JPRIAqjBLUkLtp133Aq2lEZdPWaSKOlfq eV7ZMmPHDP6Qr5NEtMpTnEAtjjfZq+z+8Q3WBuB9eftWDd0QPCRr2Kr7GSpgEIcBeRygcy78 tdmtBFeb7N5ZwQt7eC3OF+eOxQpuW6zA== X-Talos-CUID: 9a23:z4rSAmseWa4yx+XfqIlAibQ06It+TGz21FX9MnayBEE0Vpy1Y3Gu149dxp8= X-Talos-MUID: 9a23:YHi3/AgiZUUOmlwErj8u28MpEfwwoKmhGRkxva4bhoqpaXN9ERWmtWHi X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.12,268,1728950400"; d="scan'208";a="402842747" Received: from rcdn-l-core-02.cisco.com ([173.37.255.139]) by alln-iport-2.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 27 Dec 2024 03:14:34 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-l-core-02.cisco.com (Postfix) with ESMTP id 2D0A51800022C; Fri, 27 Dec 2024 03:14:34 +0000 (GMT) Received: by cisco.com (Postfix, from userid 392789) id C831920F2008; Thu, 26 Dec 2024 19:14:33 -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 v2 5/5] enic: Obtain the Link speed only after the link comes up Date: Thu, 26 Dec 2024 19:14:10 -0800 Message-Id: <20241227031410.25607-6-johndale@cisco.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20241227031410.25607-1-johndale@cisco.com> References: <20241227031410.25607-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-02.cisco.com X-Patchwork-Delegate: kuba@kernel.org The link speed that is used to index the table of minimum RX adaptive coalescing values is incorrect because the link speed was being checked before the link was up. Change the adaptive RX coalescing setup function to run after the Link comes up. There could be a minor bandwidth impact when adaptive interrupts were enabled. The low end of the adaptive interrupt range was being set to 0 for all packets instead of 3us for packets less the 1000 bytes and 6us for larger packet for link speeds greater 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_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 5bfd89749237..7c2bfe4b7997 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -84,6 +84,8 @@ MODULE_AUTHOR("Scott Feldman "); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, enic_id_table); +static void enic_set_rx_coal_setting(struct enic *enic); + #define ENIC_MAX_COALESCE_TIMERS 10 /* Interrupt moderation table, which will be used to decide the * coalescing timer values @@ -109,7 +111,7 @@ static struct enic_intr_mod_table mod_table[ENIC_MAX_COALESCE_TIMERS + 1] = { static struct enic_intr_mod_range mod_range[ENIC_MAX_LINK_SPEEDS] = { {0, 0}, /* 0 - 4 Gbps */ {0, 3}, /* 4 - 10 Gbps */ - {3, 6}, /* 10 - 40 Gbps */ + {3, 6}, /* 10+ Gbps */ }; static void enic_init_affinity_hint(struct enic *enic) @@ -436,6 +438,7 @@ static void enic_link_check(struct enic *enic) if (link_status && !carrier_ok) { netdev_info(enic->netdev, "Link UP\n"); netif_carrier_on(enic->netdev); + enic_set_rx_coal_setting(enic); } else if (!link_status && carrier_ok) { netdev_info(enic->netdev, "Link DOWN\n"); netif_carrier_off(enic->netdev); @@ -3016,7 +3019,6 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) timer_setup(&enic->notify_timer, enic_notify_timer, 0); enic_rfs_flw_tbl_init(enic); - enic_set_rx_coal_setting(enic); INIT_WORK(&enic->reset, enic_reset); INIT_WORK(&enic->tx_hang_reset, enic_tx_hang_reset); INIT_WORK(&enic->change_mtu_work, enic_change_mtu_work);