From patchwork Wed Jun 26 16:42:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713185 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C445E18FC8C for ; Wed, 26 Jun 2024 16:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420216; cv=none; b=Hw4UqJKjvYtek2ZJmY0nSU9XtcSAprOrjoGJ0jEgTBmqQQXDgYGZe7uscy6RRhbiTE5GfGAETpxrUnsdCiCKxz52WCZGalS7ESQGmGeKph1iCYrh3boPuyDm8klcVEPMrrZdtSm1x+cKmiVYUZnA8Z3JZCqjefIpjdKsUiaC/hY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420216; c=relaxed/simple; bh=VwoVeAnF7sXXn2+QvAd8ZA7yQG5Gg7PBAurFVZvFOEs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Wz04Psxy5m4Bzp3M0YSE14dFN6Sik9gcCKpOwej/pH1s67YJEsFA0dTKOJhdKlTKJCF51DBwyKJD3qWMtFwMQ/rFShSkQh/bdQk9O8MJgGNvp1NPoPB8qBYwYMOwKUNSl2Da5umnKYu/HcZpiwnSZERCguTAAxc2d/F6R+Q581Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Z890qIKJ; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Z890qIKJ" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-795a4fde8bfso406269685a.2 for ; Wed, 26 Jun 2024 09:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420214; x=1720025014; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=wXPJ8Wq+xQjKAbn0W6a+yEhetIHGX5/uROKicxN+ZFw=; b=Z890qIKJ73PXcU/RzJ4g0TtqPCnTMGrm4n8COKkZmn7AdMZe1q25G3AW0WvRkzfM1B LQpD+cXbn7RzesTKiOVlUE+ws6SpEZhrUUrqBLDPnoF9h9ZeyWua8p+NMNIP88/NazG1 zWu1M6+j21q4tu2eosX+eQZ6G9UZInWlDEM+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420214; x=1720025014; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wXPJ8Wq+xQjKAbn0W6a+yEhetIHGX5/uROKicxN+ZFw=; b=royu4Y24+zQKz0GFHDAHV5Y4SJCevfMJRkOTRKYeXRt95ufZK/pZyesWpXsSKffiCm WD1nJZvGk22wkuoH+8dL2dUp2hbqxweze8AtyUOncrE31Wkc7LkfoD8Qk90ay6v6Mo4x 77AJcoDzYH+D1qoj58gFZXCOr51j8E0fboh6yzyzK+yRcPcybZ8GytGtg9jugchgyDOa K73yfvwGJ75oHqJ7JOVTkpsAS5RFVp8RiJtWjRJKeraLhbn9rCEUOTWIBTOAT5a8Zy2n B/ZB7A+z3rGK/73ZmOpCE3quxFjAw6AUHvqeJuUoBtp8X5JkPTAL9E9FigDDzLcVpbvM +AXw== X-Gm-Message-State: AOJu0YzXzU1g5GhC8o/KArGDBRox4n/Z1hFnz5YPLzJPgadFh0I/Pwyc MpyA/3hieeY/Ham0feetpq9eopuJxX7GDR1ZQvGoXAOyc9iUSKNEwCzQHjV8Pw== X-Google-Smtp-Source: AGHT+IFxvOLaIKgw0VEiESu6jxwSNQWcaTzAqKnSHV6Cbb95+qUW347DckR8RhMG9jADQHW5Ek5csQ== X-Received: by 2002:a05:620a:25d0:b0:79b:f963:d25 with SMTP id af79cd13be357-79bf9630d29mr874415385a.75.1719420213421; Wed, 26 Jun 2024 09:43:33 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:32 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 01/10] bnxt_en: Add new TX timestamp completion definitions Date: Wed, 26 Jun 2024 09:42:58 -0700 Message-ID: <20240626164307.219568-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The new BCM5760X chips will generate this new TX timestamp completion when a TX packet's timestamp has been taken right before transmission. The driver logic to retreive the timestamp will be added in the next few patches. Reviewed-by: Pavan Chebbi Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 9cf0acfa04e5..d3ad73d4c00a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -181,6 +181,32 @@ struct tx_cmp { #define TX_CMP_SQ_CONS_IDX(txcmp) \ (le32_to_cpu((txcmp)->sq_cons_idx) & TX_CMP_SQ_CONS_IDX_MASK) +struct tx_ts_cmp { + __le32 tx_ts_cmp_flags_type; + #define TX_TS_CMP_FLAGS_ERROR (1 << 6) + #define TX_TS_CMP_FLAGS_TS_TYPE (1 << 7) + #define TX_TS_CMP_FLAGS_TS_TYPE_PM (0 << 7) + #define TX_TS_CMP_FLAGS_TS_TYPE_PA (1 << 7) + #define TX_TS_CMP_FLAGS_TS_FALLBACK (1 << 8) + #define TX_TS_CMP_TS_SUB_NS (0xf << 12) + #define TX_TS_CMP_TS_NS_MID (0xffff << 16) + #define TX_TS_CMP_TS_NS_MID_SFT 16 + u32 tx_ts_cmp_opaque; + __le32 tx_ts_cmp_errors_v; + #define TX_TS_CMP_V (1 << 0) + #define TX_TS_CMP_TS_INVALID_ERR (1 << 10) + __le32 tx_ts_cmp_ts_ns_lo; +}; + +#define BNXT_GET_TX_TS_48B_NS(tscmp) \ + (le32_to_cpu((tscmp)->tx_ts_cmp_ts_ns_lo) | \ + ((u64)(le32_to_cpu((tscmp)->tx_ts_cmp_flags_type) & \ + TX_TS_CMP_TS_NS_MID) << TX_TS_CMP_TS_NS_MID_SFT)) + +#define BNXT_TX_TS_ERR(tscmp) \ + (((tscmp)->tx_ts_cmp_flags_type & cpu_to_le32(TX_TS_CMP_FLAGS_ERROR)) &&\ + ((tscmp)->tx_ts_cmp_errors_v & cpu_to_le32(TX_TS_CMP_TS_INVALID_ERR))) + struct rx_cmp { __le32 rx_cmp_len_flags_type; #define RX_CMP_CMP_TYPE (0x3f << 0) From patchwork Wed Jun 26 16:42:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713186 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA5D118FDA0 for ; Wed, 26 Jun 2024 16:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420218; cv=none; b=nu16apnPKqR8C6TuWZV3FHylwJ47ZsfzZzVdqtsjvObTAW3vjSSUrD+FVsECpxaVZBptdubG2zwEfxxVuj+QZk8v0q7drcKKD07lxKxR6DdWtePh1OjtiioiIVkqLtD7irpkMz5nhcHwBCePeWR89XD+yNyxS3Tj2ccRvDcX8J0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420218; c=relaxed/simple; bh=4qCRiuAIxkS2KsFQMrIIu7MFiCn2R6NxwQ1lRtqrjgQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S5fvslBxOQD5oF9hxTmOzf81iEPDYggIJSso+FVCyubQwLGnlF38tE0ln9LVZv+wjvEIGcAMTcAJR2FZQqO2mFbytkrthvUqswlavLqglCCfFZvpSc3tvyNfsH1nOQPRy4xxfgYuE7GJBPFGlesoe7aw3YxkKl/SD+ISAIr5Fl0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=LglsErDo; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="LglsErDo" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-79c05313eb5so185054285a.1 for ; Wed, 26 Jun 2024 09:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420216; x=1720025016; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=wylplTsl9+X29Ih842Wvjx/gfzneAFAm8hjfRQ0utlw=; b=LglsErDoAanONEQbYv0zPJOnjsUeTIVlvkmx0MYJ2UkOzb7OoP4sH5t6IFHMuYoWOO qRq0oNCvGgY+A+2P8bK/SlDP0JQkVqi5wbyCyc85C42TDV6S0PK3vlBZZRFuyloQlYyB fTVrDLjBPGAD57Dvjzb0GodDciqcaeNuscea0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420216; x=1720025016; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wylplTsl9+X29Ih842Wvjx/gfzneAFAm8hjfRQ0utlw=; b=U3gfniPqWaFOy7fgzlyyjm+zGWYfMxqIKvp/AyaZSOiq3ZhpsfisD7uK0bHRnMCPbD kZoJRiHZrIr7tAJfNRAiogPqJ9azqPMcpj6UBmpEnSk4SGghs5vBqY9rL6fSFyXWxR35 J2UhavoHokYuKDZHYLGGY3UtxPSJbopM4wPg+Cu3jv3yq+jhWTcAVP1HuKh2Kquq+4wm tbPOTgRPTYg2BS65dAM2JQLpvGr7OCtcmzudVKvlQf/ji3DSAhCVoZoaXgQBzO21rv1G EYO0WAqHItvjvrze1S0VMtXO7m0oVk6ewqHo+aTC4jcHoNTNYDEgGYxaTeG2cJTxKB86 6n2w== X-Gm-Message-State: AOJu0YxBSNc+2SA8vzb9i3lgQUHKDDX/ZJzteQMfyN/HvyFFrpUCgkgR n/6Yi2vknPmGwbkwXB1Bn0sjSb4ztWuV2KrfcsOp+yCQmy6ynC53XOtS5gjXs3ULy+8020mmxe0 = X-Google-Smtp-Source: AGHT+IF5VGtN/eRx/odG3USVxYAzHvCDiqvy1qPNIPP8uD8XbNqBpei1LgPeD/MNSzRWDtPo8jcszg== X-Received: by 2002:a05:620a:2946:b0:79c:116a:b782 with SMTP id af79cd13be357-79d5a1123f9mr33025785a.74.1719420215087; Wed, 26 Jun 2024 09:43:35 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:34 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 02/10] bnxt_en: Add is_ts_pkt field to struct bnxt_sw_tx_bd Date: Wed, 26 Jun 2024 09:42:59 -0700 Message-ID: <20240626164307.219568-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Remove the unused is_gso field and add the is_ts_pkt field to struct bnxt_sw_tx_bd. This field will mark the TX BD that has requested HW TX timestamp. The field needs to be cleared if the timestamp packet is later aborted. This field will be useful when processing the new TX timestamp completion from the hardware in the next patches. Reviewed-by: Pavan Chebbi Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 +++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1bd0c5973252..996d9fe80495 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -522,6 +522,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) if (vlan_tag_flags) ptp->tx_hdr_off += VLAN_HLEN; lflags |= cpu_to_le32(TX_BD_FLAGS_STAMP); + tx_buf->is_ts_pkt = 1; skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; } else { atomic_inc(&bp->ptp_cfg->tx_avail); @@ -612,9 +613,11 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) normal_tx: if (length < BNXT_MIN_PKT_SIZE) { pad = BNXT_MIN_PKT_SIZE - length; - if (skb_pad(skb, pad)) + if (skb_pad(skb, pad)) { /* SKB already freed. */ + tx_buf->is_ts_pkt = 0; goto tx_kick_pending; + } length = BNXT_MIN_PKT_SIZE; } @@ -741,6 +744,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) /* start back at beginning and unmap skb */ prod = txr->tx_prod; tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; + tx_buf->is_ts_pkt = 0; dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), skb_headlen(skb), DMA_TO_DEVICE); prod = NEXT_TX(prod); @@ -781,6 +785,7 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, while (RING_TX(bp, cons) != hw_cons) { struct bnxt_sw_tx_bd *tx_buf; struct sk_buff *skb; + bool is_ts_pkt; int j, last; tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; @@ -800,6 +805,8 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, tx_buf->is_push = 0; goto next_tx_int; } + is_ts_pkt = tx_buf->is_ts_pkt; + tx_buf->is_ts_pkt = 0; dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), skb_headlen(skb), DMA_TO_DEVICE); @@ -814,7 +821,7 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, skb_frag_size(&skb_shinfo(skb)->frags[j]), DMA_TO_DEVICE); } - if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { + if (unlikely(is_ts_pkt)) { if (BNXT_CHIP_P5(bp)) { /* PTP worker takes ownership of the skb */ if (!bnxt_get_tx_ts_p5(bp, skb)) { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index d3ad73d4c00a..00976e8a1e6a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -874,7 +874,7 @@ struct bnxt_sw_tx_bd { DEFINE_DMA_UNMAP_ADDR(mapping); DEFINE_DMA_UNMAP_LEN(len); struct page *page; - u8 is_gso; + u8 is_ts_pkt; u8 is_push; u8 action; unsigned short nr_frags; From patchwork Wed Jun 26 16:43:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713187 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D028318F2EB for ; Wed, 26 Jun 2024 16:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420219; cv=none; b=sRJM28WPt+VM7G2TDrA3Py0P2NGxIsNrDYdo2HKwYf45mEu5tckhaVuuAQfwcBa8n0nwTHYauyLx5qy8b5OcCBYUWtZDYT3TYZhuRqfNHFQyBu5C4uYarRO9nnD3GDhAPwaDqRGOtUPiTFR6yuv6O88ncSmStvD4UPpBH7us/aI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420219; c=relaxed/simple; bh=zd1+5YHnmYGebQdRIrenpzsuChk9p/WJMl/pqwP9Fzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TMAksoac64FGWM1eHRarRO003Dai68yXaE2E5mB0paYyOTTP8qRFCqZ8uI5oCC3Zd/v6ZhLhyxWNUVl6Kmy3rSbXEZmqScOGBzRvqTllxvwlmIq6Mtuhkq/Z7Jh2p4ACt+PoJ0t5WYaeH4B7wWjYsS4emJfOMnX0KZSkmy5lX4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=hLhoR57o; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="hLhoR57o" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-700cf7e2779so758726a34.1 for ; Wed, 26 Jun 2024 09:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420217; x=1720025017; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=0c74ncTltVL8E8rT3+LoyxLtEXCltjgcRGPmIFQTpBg=; b=hLhoR57o+KDzEf9jt1inh2WgBhkeChUyqH9HHdwvABD2W9bT+HzWvTAWBSOyLVHW/O p0W4e5ETNu7SXd3Ed9wf9Abg4cHsb8l2MAUUo7rON5VT3rp7CBSyOc+T4mjOKslPPZ/C O2mh9eo4wb31G8oxwVPttwc53x8w73BqpO4ZU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420217; x=1720025017; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0c74ncTltVL8E8rT3+LoyxLtEXCltjgcRGPmIFQTpBg=; b=Sm5vA8LPRFxKjZFqSa+yFwhzeS/o+Czl3pIYHffy+J2HbZ/9TEWdmCm2BKEhC7f5OH nMd33fpK4qe4Tmc9jiLfR9Eg6XIko2JuXaUDVJcaZVgSs77QnagTf0luTOC+tEZRwQQA JVlHLe4CtzYOT+bGI7dVIC7kMiKtE32lRu+yK53pS5BSAeFx1ssMKFPzNDQldQf6ji6G 3cg+S5ENRcFw6fgMQ+OBxNhlOYaRau4ury9ikikviyBXYIseT2FkaLrzRnHZIPJxwCOv owdlv13tw+BPleOtan+bpL5KMG9vh7gqiXNaiZxRy1u3Byhdra69SCWoyQJ24XHU/McW iaQA== X-Gm-Message-State: AOJu0YzpIGE1SMwuBOKl01SZ0mTc/AIH85WrFRG7LsQgiWriZNoZQrh+ 8quoA/42K4nkkgi5AcNxQjajerI3HdGBK02ip4FswpyvMgxL+IrpuMO4rfmt3w== X-Google-Smtp-Source: AGHT+IE5TVZHAQCPCVlXjGPHZSgq0stip2mSMmEgvj+OuefV+e8YZzbkgZUcqRrI3jLjoP2p4NFaXw== X-Received: by 2002:a9d:76d1:0:b0:6f9:75c9:854c with SMTP id 46e09a7af769-700b1271e04mr10941412a34.27.1719420216635; Wed, 26 Jun 2024 09:43:36 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:36 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 03/10] bnxt_en: Allow some TX packets to be unprocessed in NAPI Date: Wed, 26 Jun 2024 09:43:00 -0700 Message-ID: <20240626164307.219568-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The driver's current logic will always free all the TX SKBs up to txr->tx_hw_cons within NAPI. In the next patches, we'll be adding logic to handle TX timestamp completion and we may need to hold some remaining TX SKBs if we don't have the timestamp completions yet. Modify __bnxt_poll_work_done() to clear each event bit separately to allow bnapi->tx_int() to decide whether to clear BNXT_TX_CMP_EVENT or not. bnapi->tx_int() will not clear BNXT_TX_CMP_EVENT if some TX SKBs are held waiting for TX timestamps. Note that legacy chips will never hold any SKBs this way. The SKB is always deferred to the PTP worker slow path to retrieve the timestamp from firmware. On the new P7 chips, the timestamp is returned by the hardware directly and we can retrieve it directly from NAPI. Reviewed-by: Pavan Chebbi Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 996d9fe80495..784787a09dba 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -772,7 +772,8 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_OK; } -static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, +/* Returns true if some remaining TX packets not processed. */ +static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, int budget) { struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index); @@ -795,7 +796,7 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, if (unlikely(!skb)) { bnxt_sched_reset_txr(bp, txr, cons); - return; + return false; } tx_pkts++; @@ -844,18 +845,22 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, __netif_txq_completed_wake(txq, tx_pkts, tx_bytes, bnxt_tx_avail(bp, txr), bp->tx_wake_thresh, READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING); + + return false; } static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) { struct bnxt_tx_ring_info *txr; + bool more = false; int i; bnxt_for_each_napi_tx(i, bnapi, txr) { if (txr->tx_hw_cons != RING_TX(bp, txr->tx_cons)) - __bnxt_tx_int(bp, txr, budget); + more |= __bnxt_tx_int(bp, txr, budget); } - bnapi->events &= ~BNXT_TX_CMP_EVENT; + if (!more) + bnapi->events &= ~BNXT_TX_CMP_EVENT; } static struct page *__bnxt_alloc_rx_page(struct bnxt *bp, dma_addr_t *mapping, @@ -2952,8 +2957,10 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, } } - if (event & BNXT_REDIRECT_EVENT) + if (event & BNXT_REDIRECT_EVENT) { xdp_do_flush(); + event &= ~BNXT_REDIRECT_EVENT; + } if (event & BNXT_TX_EVENT) { struct bnxt_tx_ring_info *txr = bnapi->tx_ring[0]; @@ -2963,6 +2970,7 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, wmb(); bnxt_db_write_relaxed(bp, &txr->tx_db, prod); + event &= ~BNXT_TX_EVENT; } cpr->cp_raw_cons = raw_cons; @@ -2980,13 +2988,14 @@ static void __bnxt_poll_work_done(struct bnxt *bp, struct bnxt_napi *bnapi, struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); + bnapi->events &= ~BNXT_RX_EVENT; } if (bnapi->events & BNXT_AGG_EVENT) { struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); + bnapi->events &= ~BNXT_AGG_EVENT; } - bnapi->events &= BNXT_TX_CMP_EVENT; } static int bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, From patchwork Wed Jun 26 16:43:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713188 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFE3118FDB5 for ; Wed, 26 Jun 2024 16:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420221; cv=none; b=Mn0BZ/BW9KVnRYef0ZV/HBp8vmQBJgISMrihww4fcptsYZC8Z1sbkXNqfPYUuCVWgQTv/c6tKJ0OWlBZMrKkUJmwc8DzJ00BK5LkhuGzDEVPppmkJPCM+ZYo4nDWcV/H7BVqVxR9SkPaxw/OqJi0LYtDJvl77hIJZPF8I6v4Luo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420221; c=relaxed/simple; bh=1t2j5hK0pUMDtphH6AYcomX8hzyzcOJHxryjBbsM528=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TsDEfYe9avBzhCj3h3I3vhEXCEBzFc/6b82ZzEniVtrHrBMXiKkWJpA0e289cCNP2gzjp7l6ubRIz/VxArEGjqO+V9kcdqJg1dpRR6xog0mEr2V6MHvf+cdLDkTW9zIR4g2iuZPTbdhpjz64jlhGOaoXEMkQJ2EmHPEzJN32x50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=HOrGf/Jb; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="HOrGf/Jb" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-79c11e92afaso85094085a.2 for ; Wed, 26 Jun 2024 09:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420219; x=1720025019; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=fHEkQmE7U/zo+3YVTvYlXuTc+1/hnKEzMuy07tZ4EHM=; b=HOrGf/JbZt9WJlTnzxEph5R5Hkf3IEEOoohTMCgqAOsDK0FnpDxv2Kpz1Abz/Qrc9s H2LY4GDwlZ3KiXXW4yg37CymDyMlbRrvXC1ruzW3W9UAHtXdkTq18AwQ5Dffyv7LL45k zeL7quxiNUXRyS0HG0XrjzbJgL6S9kTg6BFKk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420219; x=1720025019; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fHEkQmE7U/zo+3YVTvYlXuTc+1/hnKEzMuy07tZ4EHM=; b=PB5+PZNtapYvwUB7Ehh1SrO7gZV8hTmUJtjgdX5UTLVWbv8Td3y7qp350DYm1k32jt 8+SohqdKgb1GToJPXRRe0JCXV8ooJfG7ej+Zu7eXBpqFxJ9pO+MhXVTk64Efi2q55mok 1YiQINh/eQ6EU+B+BSW/BmRUGXdosC4fovKCOSzL2V3MXdWs/REJ0ZJ6nFzPxexon3Dj YjCIqQBBUQ7aLLfH7S0MK7b7slAqK5iLcC62SBO5T2mQHwgHOMn2mIHiMoDuaYXcfBgQ +ae3DR/D9G5QLBc8H5YJNUFpGJ39VxTNc30h7IqaA1r/yXGrXGVjpd1qO7yDMpo3i/hZ zf4Q== X-Gm-Message-State: AOJu0YzGX1CYAkfv0JBCzKJU3TQFf7YpQAxcAxQUnW6ciHgdfdPcEmDX iCgpYtbyOXTcXp7WjXpFvA3mgUfsgHCKgFivr6yLoL75WCMrxOhPhbNYNZK9uJJyX+cOY6NVdlg = X-Google-Smtp-Source: AGHT+IG+fURLQxjaZPbGd0K9wnTBOfIB69jlqMOneYNSwDAasILInAGGLdRHoVmurFB0vOPsvt4C1Q== X-Received: by 2002:a05:620a:170c:b0:797:8ee4:46a1 with SMTP id af79cd13be357-79be6cdc68amr1113652585a.10.1719420218221; Wed, 26 Jun 2024 09:43:38 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:37 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 04/10] bnxt_en: Add TX timestamp completion logic Date: Wed, 26 Jun 2024 09:43:01 -0700 Message-ID: <20240626164307.219568-5-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The new BCM5760X chips will return the timestamp of TX packets in a new completion. Add logic in __bnxt_poll_work() to handle this completion type to retrieve the timestamp. This feature eliminates the limit on the number of in-flight PTP TX packets. Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 39 +++++++++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 32 +++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 2 + 4 files changed, 63 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 784787a09dba..e16f50d822c8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -456,6 +456,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) dma_addr_t mapping; unsigned int length, pad = 0; u32 len, free_size, vlan_tag_flags, cfa_action, flags; + struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; u16 prod, last_frag; struct pci_dev *pdev = bp->pdev; struct bnxt_tx_ring_info *txr; @@ -509,10 +510,12 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) vlan_tag_flags |= 1 << TX_BD_CFA_META_TPID_SHIFT; } - if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { - struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; - - if (ptp && ptp->tx_tstamp_en && !skb_is_gso(skb)) { + if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && ptp && + ptp->tx_tstamp_en) { + if (bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP) { + lflags |= cpu_to_le32(TX_BD_FLAGS_STAMP); + tx_buf->is_ts_pkt = 1; + } else if (!skb_is_gso(skb)) { if (atomic_dec_if_positive(&ptp->tx_avail) < 0) { atomic64_inc(&ptp->stats.ts_err); goto tx_no_ts; @@ -782,6 +785,7 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, unsigned int tx_bytes = 0; u16 cons = txr->tx_cons; int tx_pkts = 0; + bool rc = false; while (RING_TX(bp, cons) != hw_cons) { struct bnxt_sw_tx_bd *tx_buf; @@ -790,24 +794,29 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, int j, last; tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; - cons = NEXT_TX(cons); skb = tx_buf->skb; - tx_buf->skb = NULL; if (unlikely(!skb)) { bnxt_sched_reset_txr(bp, txr, cons); - return false; + return rc; + } + + is_ts_pkt = tx_buf->is_ts_pkt; + if (is_ts_pkt && (bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) { + rc = true; + break; } + cons = NEXT_TX(cons); tx_pkts++; tx_bytes += skb->len; + tx_buf->skb = NULL; + tx_buf->is_ts_pkt = 0; if (tx_buf->is_push) { tx_buf->is_push = 0; goto next_tx_int; } - is_ts_pkt = tx_buf->is_ts_pkt; - tx_buf->is_ts_pkt = 0; dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), skb_headlen(skb), DMA_TO_DEVICE); @@ -846,7 +855,7 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, bnxt_tx_avail(bp, txr), bp->tx_wake_thresh, READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING); - return false; + return rc; } static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) @@ -2926,6 +2935,8 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, cpr->has_more_work = 1; break; } + } else if (cmp_type == CMP_TYPE_TX_L2_PKT_TS_CMP) { + bnxt_tx_ts_cmp(bp, bnapi, (struct tx_ts_cmp *)txcmp); } else if (cmp_type >= CMP_TYPE_RX_L2_CMP && cmp_type <= CMP_TYPE_RX_L2_TPA_START_V3_CMP) { if (likely(budget)) @@ -6804,6 +6815,7 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp, switch (ring_type) { case HWRM_RING_ALLOC_TX: { struct bnxt_tx_ring_info *txr; + u16 flags = 0; txr = container_of(ring, struct bnxt_tx_ring_info, tx_ring_struct); @@ -6817,6 +6829,9 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp, if (bp->flags & BNXT_FLAG_TX_COAL_CMPL) req->cmpl_coal_cnt = RING_ALLOC_REQ_CMPL_COAL_CNT_COAL_64; + if ((bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP) && bp->ptp_cfg) + flags |= RING_ALLOC_REQ_FLAGS_TX_PKT_TS_CMPL_ENABLE; + req->flags = cpu_to_le16(flags); break; } case HWRM_RING_ALLOC_RX: @@ -9111,6 +9126,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS; if (flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_UDP_GSO_SUPPORTED) bp->flags |= BNXT_FLAG_UDP_GSO_CAP; + if (flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_TX_PKT_TS_CMPL_SUPPORTED) + bp->fw_cap |= BNXT_FW_CAP_TX_TS_CMP; bp->tx_push_thresh = 0; if ((flags & FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED) && @@ -12152,7 +12169,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) /* VF-reps may need to be re-opened after the PF is re-opened */ if (BNXT_PF(bp)) bnxt_vf_reps_open(bp); - if (bp->ptp_cfg) + if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) atomic_set(&bp->ptp_cfg->tx_avail, BNXT_MAX_TX_TS); bnxt_ptp_init_rtc(bp, true); bnxt_ptp_cfg_tstamp_filters(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 00976e8a1e6a..12d6d17936a9 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2410,6 +2410,7 @@ struct bnxt { #define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2 BIT_ULL(16) #define BNXT_FW_CAP_PCIE_STATS_SUPPORTED BIT_ULL(17) #define BNXT_FW_CAP_EXT_STATS_SUPPORTED BIT_ULL(18) + #define BNXT_FW_CAP_TX_TS_CMP BIT_ULL(19) #define BNXT_FW_CAP_ERR_RECOVER_RELOAD BIT_ULL(20) #define BNXT_FW_CAP_HOT_RESET BIT_ULL(21) #define BNXT_FW_CAP_PTP_RTC BIT_ULL(22) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index a14d46b9bfdf..0ca7bc75616b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -768,6 +768,38 @@ int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts) return 0; } +void bnxt_tx_ts_cmp(struct bnxt *bp, struct bnxt_napi *bnapi, + struct tx_ts_cmp *tscmp) +{ + struct skb_shared_hwtstamps timestamp = {}; + struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; + u32 opaque = tscmp->tx_ts_cmp_opaque; + struct bnxt_tx_ring_info *txr; + struct bnxt_sw_tx_bd *tx_buf; + u64 ts, ns; + u16 cons; + + txr = bnapi->tx_ring[TX_OPAQUE_RING(opaque)]; + ts = BNXT_GET_TX_TS_48B_NS(tscmp); + cons = TX_OPAQUE_IDX(opaque); + tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; + if (tx_buf->is_ts_pkt) { + if (BNXT_TX_TS_ERR(tscmp)) { + netdev_err(bp->dev, + "timestamp completion error 0x%x 0x%x\n", + le32_to_cpu(tscmp->tx_ts_cmp_flags_type), + le32_to_cpu(tscmp->tx_ts_cmp_errors_v)); + } else { + spin_lock_bh(&ptp->ptp_lock); + ns = timecounter_cyc2time(&ptp->tc, ts); + spin_unlock_bh(&ptp->ptp_lock); + timestamp.hwtstamp = ns_to_ktime(ns); + skb_tstamp_tx(tx_buf->skb, ×tamp); + } + tx_buf->is_ts_pkt = 0; + } +} + static const struct ptp_clock_info bnxt_ptp_caps = { .owner = THIS_MODULE, .name = "bnxt clock", diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h index 8c30b428a428..d38c3500827f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h @@ -156,6 +156,8 @@ int bnxt_hwtstamp_set(struct net_device *dev, struct ifreq *ifr); int bnxt_hwtstamp_get(struct net_device *dev, struct ifreq *ifr); int bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb); int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts); +void bnxt_tx_ts_cmp(struct bnxt *bp, struct bnxt_napi *bnapi, + struct tx_ts_cmp *tscmp); void bnxt_ptp_rtc_timecounter_init(struct bnxt_ptp_cfg *ptp, u64 ns); int bnxt_ptp_init_rtc(struct bnxt *bp, bool phc_cfg); int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg); From patchwork Wed Jun 26 16:43:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713190 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B38D18FC6B for ; Wed, 26 Jun 2024 16:43:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420225; cv=none; b=eA6l6f1F5xt5yE9xpYK8DLojA70ybvrPGjbMK3apNGordGUgNe99VXFpTjzRW0tbPtJZpprALHUW3byr7jSrfECEXrh1Tf7s3wBJR831zgQ1gKs1SGrSxQWgNAJTMc1B8U2jaElymLQ68ixd/MHmlBnLiWQr8l7B+E+sZC7nt5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420225; c=relaxed/simple; bh=+bvu2TIzbRaPGNdEFauHV/5vdqZZxUadEXmEbizd4vE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XvT0J8j3+Q37RhxF+WPwyjxfpsZlZ7sKgfeTFSR/jY05Nx5rO11NYb1WVHgRn+e37DhIB04UX9aGK6luhsOdFvOJ2uo/SrPy4MSCWSf+ES5OhoMmh7ZDoX6C6ze/SPE0pcwplYyPZvSYNfL00l4YD0vmHVQ8b9mWAF6E0dk5rU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=LFz6eU7K; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="LFz6eU7K" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-79c2c05638cso94315285a.3 for ; Wed, 26 Jun 2024 09:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420223; x=1720025023; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=xEQAwPPZKAgg3hj+X5edaTN5tGC1XD/ScCUUTaK06vI=; b=LFz6eU7KbiOTVDIFBapL+68GVQN7nZ+V8u+82trVt2zFn+Uitin9BQ5psBHyaV79kB vb9w/692u0LXiPPOxLaQ3oH13dR/eaTAxPLaXFqghrUYUXgnVGB/CLzIYNuheil3urDr WT1evzpNjIk+lNM+Xh5KnCL1wbvd3UTi46XAI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420223; x=1720025023; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xEQAwPPZKAgg3hj+X5edaTN5tGC1XD/ScCUUTaK06vI=; b=NTKO1AI0b1+PGKG+kEXmZzwoGa3O69l3ysPFDYkMN8YHZJiak6BftH+VPhfy7DiAhL jkif7aCLi/TChuV6owCRBMDaBJ6vr/dcRYo3Ivb/4wFJXUYxiotZt65MR/xdgm6rP4eY 81zMi4WGiJunT2KyKsvvhRQF9eady5+ywy9aBskXgm4eotG4teqYqehCkwk6BA25PqU0 bPSQ1sKvltRCeoWFD7NB9dNFrBJd955e/pOQIJT4Sr43JNeHqKQqUwfrDADfecnCn5AO Dk8UITGvJP1++rwI38Nm2IOKcceyA5iGzNZgjpAw1K2cxlci2mJriHcXKXN0zHFmwX/V p8Pw== X-Gm-Message-State: AOJu0YzG/L86G/ONaLKkoeVjcZMwKmR711sXKzA+pjaE9NGV51b3FCXy aKu8+xM8IJZE0xIDI34muhMhT+7PyfowHq/Fi7craL6JgUpe9cfCI1TltkiwRg== X-Google-Smtp-Source: AGHT+IG3nhQTW/mGKYJLRLAl+CVCkqjnMfB0OVurwx3XPHKXx6US3XlQBji3k2zNzeZrKVpupCRROA== X-Received: by 2002:a05:620a:2949:b0:79b:ef62:4ecf with SMTP id af79cd13be357-79bef625027mr1139247885a.1.1719420219722; Wed, 26 Jun 2024 09:43:39 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:39 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 05/10] bnxt_en: Add BCM5760X specific PHC registers mapping Date: Wed, 26 Jun 2024 09:43:02 -0700 Message-ID: <20240626164307.219568-6-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Pavan Chebbi BCM5760X firmware will advertise direct 64-bit PHC registers access for the driver from BAR0. Make the necessary changes in handling HWRM_PORT_MAC_PTP_QCFG's response and PHC register mapping for 5760X chips. Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 ++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 8 ++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 10 +++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index e16f50d822c8..93858df547b2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9012,7 +9012,7 @@ static int __bnxt_hwrm_ptp_qcfg(struct bnxt *bp) u8 flags; int rc; - if (bp->hwrm_spec_code < 0x10801 || !BNXT_CHIP_P5(bp)) { + if (bp->hwrm_spec_code < 0x10801 || !BNXT_CHIP_P5_PLUS(bp)) { rc = -ENODEV; goto no_ptp; } @@ -9028,7 +9028,8 @@ static int __bnxt_hwrm_ptp_qcfg(struct bnxt *bp) goto exit; flags = resp->flags; - if (!(flags & PORT_MAC_PTP_QCFG_RESP_FLAGS_HWRM_ACCESS)) { + if (BNXT_CHIP_P5_AND_MINUS(bp) && + !(flags & PORT_MAC_PTP_QCFG_RESP_FLAGS_HWRM_ACCESS)) { rc = -ENODEV; goto exit; } @@ -9041,10 +9042,13 @@ static int __bnxt_hwrm_ptp_qcfg(struct bnxt *bp) ptp->bp = bp; bp->ptp_cfg = ptp; } - if (flags & PORT_MAC_PTP_QCFG_RESP_FLAGS_PARTIAL_DIRECT_ACCESS_REF_CLOCK) { + + if (flags & + (PORT_MAC_PTP_QCFG_RESP_FLAGS_PARTIAL_DIRECT_ACCESS_REF_CLOCK | + PORT_MAC_PTP_QCFG_RESP_FLAGS_64B_PHC_TIME)) { ptp->refclk_regs[0] = le32_to_cpu(resp->ts_ref_clock_reg_lower); ptp->refclk_regs[1] = le32_to_cpu(resp->ts_ref_clock_reg_upper); - } else if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { + } else if (BNXT_CHIP_P5(bp)) { ptp->refclk_regs[0] = BNXT_TS_REG_TIMESYNC_TS0_LOWER; ptp->refclk_regs[1] = BNXT_TS_REG_TIMESYNC_TS0_UPPER; } else { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 12d6d17936a9..82b05641953f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2263,9 +2263,17 @@ struct bnxt { (BNXT_CHIP_NUM_58700((bp)->chip_num) && \ !BNXT_CHIP_TYPE_NITRO_A0(bp))) +/* Chip class phase 3.x */ +#define BNXT_CHIP_P3(bp) \ + (BNXT_CHIP_NUM_57X0X((bp)->chip_num) || \ + BNXT_CHIP_TYPE_NITRO_A0(bp)) + #define BNXT_CHIP_P4_PLUS(bp) \ (BNXT_CHIP_P4(bp) || BNXT_CHIP_P5_PLUS(bp)) +#define BNXT_CHIP_P5_AND_MINUS(bp) \ + (BNXT_CHIP_P3(bp) || BNXT_CHIP_P4(bp) || BNXT_CHIP_P5(bp)) + struct bnxt_aux_priv *aux_priv; struct bnxt_en_dev *edev; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index 0ca7bc75616b..a3795ef8887d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -656,6 +656,14 @@ static int bnxt_map_ptp_regs(struct bnxt *bp) (ptp->refclk_regs[i] & BNXT_GRC_OFFSET_MASK); return 0; } + if (bp->flags & BNXT_FLAG_CHIP_P7) { + for (i = 0; i < 2; i++) { + if (reg_arr[i] & BNXT_GRC_BASE_MASK) + return -EINVAL; + ptp->refclk_mapped_regs[i] = reg_arr[i]; + } + return 0; + } return -ENODEV; } @@ -1018,7 +1026,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg) ptp->stats.ts_lost = 0; atomic64_set(&ptp->stats.ts_err, 0); - if (BNXT_CHIP_P5(bp)) { + if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { spin_lock_bh(&ptp->ptp_lock); bnxt_refclk_read(bp, NULL, &ptp->current_time); WRITE_ONCE(ptp->old_time, ptp->current_time); From patchwork Wed Jun 26 16:43:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713189 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C786618FC69 for ; Wed, 26 Jun 2024 16:43:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420224; cv=none; b=BPIRkmC89cULQSKB023sWBtXJuJuz6KHarq/2LA6Tbqtt8RpoMNk+jM0Vpn2FZR6G5Rht1WW10E3oclDSYxZ8/mxZNVpSoG67Dydlw29cEiTP9X0TwqKDRxCmwjx6WQF4gcADpuMtaySALZOZXB3oEYtDvdeq7g5w5KlxRSs/y4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420224; c=relaxed/simple; bh=q6SCppEVMh8RE03MOS4fkjSNotR5+rks9Odni/RIal0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Myr3daSj6Ht8BtuGKIWz2w4BWB/0CrfUNhbW5/xhfz2EJeampCu78mUktGq2mP7QRWq+LKjM79naI9g1rbizgFEf0Y35wFcIIXWG1RfMbw0A5YDMCa+TDjjWChvwRGcWLAAYP3CJNC2pJdVVTJ37nkE/W7xtxku95Rnib5vIqXo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=b08y2ARu; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="b08y2ARu" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-79c10f03a5dso109139485a.0 for ; Wed, 26 Jun 2024 09:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420222; x=1720025022; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=p/sZkjUgvkOCbJeVOYqKxVJtFR7npoa3CmT84myLW1c=; b=b08y2ARueigzXq2g2JhVKYLny0M1OQeASReHZVSKtjTmcSFpcNu/JxSHH0RtM0dE57 w8wWnVE8JCP2b2MC1CBkzu22uiyOxQRBhpuOBDJqjgvuUHFHwHv2d3Ulx28IyJWLOhL1 7F4Iyg5McUJNmt6ibf+1IZtWzI2o/tSLYYmhA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420222; x=1720025022; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p/sZkjUgvkOCbJeVOYqKxVJtFR7npoa3CmT84myLW1c=; b=VjrICNoEXIaIlO8CfRCy+ulynV4TtZpJa5IhPW9O73awhLEKcBw9aKZB4J6sIQoEXH BZ4w3v3RGfHxEZa4Brmv7qekXt7Wxzcr77pWaq6uUXNN/+aTih+tp2cm2FXjuKxUPMz2 BUNI9HycSHXRfaGsOqhmUmzTbem3dJz4Y9ZARS2kJpTslVRDA40byPXjM+LZPmFuoyY4 iyUrJhU31zBskmseU4K+D4VLjaWOHY0NMcKjy0q1bF3GB1G8iCifpavTxqkhKpOGGstO gpi3Blxwa5leTQVYLtg9hBEFzn8JL8vuxIQc3nGIZ+2ouea3IZarJhk/5/RJhKvm9bND pFQg== X-Gm-Message-State: AOJu0Yya/GvSQSmMTDi2k3irjQ7ypEe/XIMgzUqRTQVEb9zwbU4lKGHj SYEqKvDJ/h/mAq90NwsxAuLx8fUFZJAbFi0T4BMjjZu4OA2lX21crKNpeElXGA== X-Google-Smtp-Source: AGHT+IHT5N8ROGKuFkfImrdYyxJMRUXLctEoveXeIn/DKp+Q6ZsOSfBqTkaIbX7GpZOfROypbvdIzQ== X-Received: by 2002:a05:620a:394c:b0:795:5896:f847 with SMTP id af79cd13be357-79be6edcd6amr1129893985a.32.1719420221363; Wed, 26 Jun 2024 09:43:41 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:40 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 06/10] bnxt_en: Refactor all PTP TX timestamp fields into a struct Date: Wed, 26 Jun 2024 09:43:03 -0700 Message-ID: <20240626164307.219568-7-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Pavan Chebbi On the older 5750X (P5) chips, we currently support only 1 TX PTP packet in-flight waiting for the timestamp. Refactor the datastructures to prepare to support up to 4 TX PTP packets. Combine all fields required for PTP TX timestamp query into one structure. An array of this structure will be added in follow-on patches to support multiple outstanding TX timestamps. Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 +++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 43 ++++++++++--------- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 15 ++++--- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 93858df547b2..c284aa370c64 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -516,14 +516,18 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) lflags |= cpu_to_le32(TX_BD_FLAGS_STAMP); tx_buf->is_ts_pkt = 1; } else if (!skb_is_gso(skb)) { + u16 seq_id, hdr_off; + if (atomic_dec_if_positive(&ptp->tx_avail) < 0) { atomic64_inc(&ptp->stats.ts_err); goto tx_no_ts; } - if (!bnxt_ptp_parse(skb, &ptp->tx_seqid, - &ptp->tx_hdr_off)) { + + if (!bnxt_ptp_parse(skb, &seq_id, &hdr_off)) { if (vlan_tag_flags) - ptp->tx_hdr_off += VLAN_HLEN; + hdr_off += VLAN_HLEN; + ptp->txts_req.tx_seqid = seq_id; + ptp->txts_req.tx_hdr_off = hdr_off; lflags |= cpu_to_le32(TX_BD_FLAGS_STAMP); tx_buf->is_ts_pkt = 1; skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index a3795ef8887d..8431cd0ed9e9 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -123,11 +123,12 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts, req->flags = cpu_to_le32(flags); if ((flags & PORT_TS_QUERY_REQ_FLAGS_PATH) == PORT_TS_QUERY_REQ_FLAGS_PATH_TX) { + struct bnxt_ptp_tx_req *txts_req = &bp->ptp_cfg->txts_req; u32 tmo_us = txts_tmo * 1000; req->enables = cpu_to_le16(BNXT_PTP_QTS_TX_ENABLES); - req->ptp_seq_id = cpu_to_le32(bp->ptp_cfg->tx_seqid); - req->ptp_hdr_offset = cpu_to_le16(bp->ptp_cfg->tx_hdr_off); + req->ptp_seq_id = cpu_to_le32(txts_req->tx_seqid); + req->ptp_hdr_offset = cpu_to_le16(txts_req->tx_hdr_off); if (!tmo_us) tmo_us = BNXT_PTP_QTS_TIMEOUT; tmo_us = min(tmo_us, BNXT_PTP_QTS_MAX_TMO_US); @@ -686,15 +687,17 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; struct skb_shared_hwtstamps timestamp; + struct bnxt_ptp_tx_req *txts_req; unsigned long now = jiffies; u64 ts = 0, ns = 0; u32 tmo = 0; int rc; - if (!ptp->txts_pending) - ptp->abs_txts_tmo = now + msecs_to_jiffies(ptp->txts_tmo); - if (!time_after_eq(now, ptp->abs_txts_tmo)) - tmo = jiffies_to_msecs(ptp->abs_txts_tmo - now); + txts_req = &ptp->txts_req; + if (!txts_req->txts_pending) + txts_req->abs_txts_tmo = now + msecs_to_jiffies(ptp->txts_tmo); + if (!time_after_eq(now, txts_req->abs_txts_tmo)) + tmo = jiffies_to_msecs(txts_req->abs_txts_tmo - now); rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_PATH_TX, &ts, tmo); if (!rc) { @@ -703,11 +706,11 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) ns = timecounter_cyc2time(&ptp->tc, ts); spin_unlock_bh(&ptp->ptp_lock); timestamp.hwtstamp = ns_to_ktime(ns); - skb_tstamp_tx(ptp->tx_skb, ×tamp); + skb_tstamp_tx(txts_req->tx_skb, ×tamp); ptp->stats.ts_pkts++; } else { - if (!time_after_eq(jiffies, ptp->abs_txts_tmo)) { - ptp->txts_pending = true; + if (!time_after_eq(jiffies, txts_req->abs_txts_tmo)) { + txts_req->txts_pending = true; return; } ptp->stats.ts_lost++; @@ -715,10 +718,10 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) "TS query for TX timer failed rc = %x\n", rc); } - dev_kfree_skb_any(ptp->tx_skb); - ptp->tx_skb = NULL; + dev_kfree_skb_any(txts_req->tx_skb); + txts_req->tx_skb = NULL; atomic_inc(&ptp->tx_avail); - ptp->txts_pending = false; + txts_req->txts_pending = false; } static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) @@ -728,8 +731,8 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) unsigned long now = jiffies; struct bnxt *bp = ptp->bp; - if (ptp->tx_skb) - bnxt_stamp_tx_skb(bp, ptp->tx_skb); + if (ptp->txts_req.tx_skb) + bnxt_stamp_tx_skb(bp, ptp->txts_req.tx_skb); if (!time_after_eq(now, ptp->next_period)) return ptp->next_period - now; @@ -742,7 +745,7 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) spin_unlock_bh(&ptp->ptp_lock); ptp->next_overflow_check = now + BNXT_PHC_OVERFLOW_PERIOD; } - if (ptp->txts_pending) + if (ptp->txts_req.txts_pending) return 0; return HZ; } @@ -751,11 +754,11 @@ int bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; - if (ptp->tx_skb) { + if (ptp->txts_req.tx_skb) { netdev_err(bp->dev, "deferring skb:one SKB is still outstanding\n"); return -EBUSY; } - ptp->tx_skb = skb; + ptp->txts_req.tx_skb = skb; ptp_schedule_worker(ptp->ptp_clock, 0); return 0; } @@ -1056,9 +1059,9 @@ void bnxt_ptp_clear(struct bnxt *bp) kfree(ptp->ptp_info.pin_config); ptp->ptp_info.pin_config = NULL; - if (ptp->tx_skb) { - dev_kfree_skb_any(ptp->tx_skb); - ptp->tx_skb = NULL; + if (ptp->txts_req.tx_skb) { + dev_kfree_skb_any(ptp->txts_req.tx_skb); + ptp->txts_req.tx_skb = NULL; } bnxt_unmap_ptp_regs(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h index d38c3500827f..90f1418211e9 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h @@ -85,6 +85,14 @@ struct bnxt_ptp_stats { atomic64_t ts_err; }; +struct bnxt_ptp_tx_req { + struct sk_buff *tx_skb; + u16 tx_seqid; + u16 tx_hdr_off; + u8 txts_pending:1; + unsigned long abs_txts_tmo; +}; + struct bnxt_ptp_cfg { struct ptp_clock_info ptp_info; struct ptp_clock *ptp_clock; @@ -93,7 +101,6 @@ struct bnxt_ptp_cfg { struct bnxt_pps pps_info; /* serialize timecounter access */ spinlock_t ptp_lock; - struct sk_buff *tx_skb; u64 current_time; u64 old_time; unsigned long next_period; @@ -102,8 +109,8 @@ struct bnxt_ptp_cfg { /* a 23b shift cyclecounter will overflow in ~36 mins. Check overflow every 18 mins. */ #define BNXT_PHC_OVERFLOW_PERIOD (18 * 60 * HZ) - u16 tx_seqid; - u16 tx_hdr_off; + struct bnxt_ptp_tx_req txts_req; + struct bnxt *bp; atomic_t tx_avail; #define BNXT_MAX_TX_TS 1 @@ -123,14 +130,12 @@ struct bnxt_ptp_cfg { BNXT_PTP_MSG_PDELAY_REQ | \ BNXT_PTP_MSG_PDELAY_RESP) u8 tx_tstamp_en:1; - u8 txts_pending:1; int rx_filter; u32 tstamp_filters; u32 refclk_regs[2]; u32 refclk_mapped_regs[2]; u32 txts_tmo; - unsigned long abs_txts_tmo; struct bnxt_ptp_stats stats; }; From patchwork Wed Jun 26 16:43:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713191 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3DFE18FC75 for ; Wed, 26 Jun 2024 16:43:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420226; cv=none; b=SCsO8kKEFHtITXZ/BX+s92z+3op/WWchia6nTG67tfgESxd/1MibipBuiWq6o7o11JhoFghzKaPGO8UO/z0CovrFP0YpykPb+4xOu8rBaKNxFEmuiKRdHWyVr82i0eK3+swsvA0O99YXu5y9m+VzuENaCstf/+e1A27OrXe1izI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420226; c=relaxed/simple; bh=4HsPCyAqoH9VOB5PfyF2OhP0Tcfzn94IF6yU3n+PXWo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ItNB5gsG1oPQuEwIcYK2MHOBC3kU2MPQYBgdSovANz3XpzUtrLPi0kfMP18SWsXMix0tAfSbnF0xm8sJbL/MubfKpqK2IjaE7FFizxkRpZkzu3JaZoj4SX4XkxjyfgIHVUkxH4Dcoz+eXb/MK8TSvhwLB2ggxNHmtueOsDCKUNw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=XSesTc41; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="XSesTc41" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-79c2c05638cso94315885a.3 for ; Wed, 26 Jun 2024 09:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420224; x=1720025024; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=LSTKzvXtxh6OZ7aiqGVsq05A96dhIv59dL3ZvrKQY2c=; b=XSesTc41MrtQnV4zlp85krYSlVW4EYRIAh6r5UdpEeFhBC8/SOZl2wDQO1WZ/NLfsv VGAJkxJL4z504Ybx1+jUsohxU1wQZgnEmZlAFszUur5HChUabofr5nz07pUyyt6qaT5B aj0mEIB5xNLObNx4ublnvWUJox/UXKnirGbyk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420224; x=1720025024; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LSTKzvXtxh6OZ7aiqGVsq05A96dhIv59dL3ZvrKQY2c=; b=bsq/aCkFLSktWqjuURfbyGFQ3GAaL99VhN+M3mSk6rsCtzJzKa/oZZbevyx8Nkhb39 jh+SeSgsmMsw68YjnpYVN7hbG+sbMiPthPpR43iKj5dQP55e3wukFmMHf0nVnTfHEEZf WZFbvHJzZ6gBTclBfPU1071WcmtgDfxhE0TSAWhUIhkfLn6hC/sM1+BWeSYegD94PF9K niOVeDLXnbUPjVzS+kq3oLyuIam9EjIvSKz7gRReygF2H17cBbgQq4uYGWWym+5bUQdf /koil3z+GMlLWNC41A6x3WjuetaaYfbP3c3iEDeALfQLgg9RDHgWL9hPSgk52uTVR8jl 5Rlw== X-Gm-Message-State: AOJu0YzUlbdBCaheeooWcWzyNMLTpwpDD22gPzkFkDaYi863JGiK6XbC 1sFxBadebFK6nyLMEQNeVNpjYGcN7hk4JWrkKAyKrlx335WLeEnWH3sjLqWA7ZJhz5toSpIqO1M = X-Google-Smtp-Source: AGHT+IG82qydysI2F2KAktOWjiLDQ1tgOyP6B6eSsPDpsRr/p3pNJc1cL3JOzZVPqq4ISsBgNNAvwg== X-Received: by 2002:a05:620a:4549:b0:797:db7a:bc2 with SMTP id af79cd13be357-79be6f13d66mr1262072385a.57.1719420223206; Wed, 26 Jun 2024 09:43:43 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:42 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 07/10] bnxt_en: Remove an impossible condition check for PTP TX pending SKB Date: Wed, 26 Jun 2024 09:43:04 -0700 Message-ID: <20240626164307.219568-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Pavan Chebbi In the current 5750X PTP code paths, there is always at most one TX SKB requested for timestamp and we won't accept another one until we have retrieved the timestamp or it has timed out. Remove the unnecessary check in bnxt_get_tx_ts_p5() for a pending SKB and change the function to void. Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++------ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 7 +------ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c284aa370c64..ed2bbdf6b25f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -838,12 +838,8 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, if (unlikely(is_ts_pkt)) { if (BNXT_CHIP_P5(bp)) { /* PTP worker takes ownership of the skb */ - if (!bnxt_get_tx_ts_p5(bp, skb)) { - skb = NULL; - } else { - atomic64_inc(&bp->ptp_cfg->stats.ts_err); - atomic_inc(&bp->ptp_cfg->tx_avail); - } + bnxt_get_tx_ts_p5(bp, skb); + skb = NULL; } } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index 8431cd0ed9e9..baf191959b13 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -750,17 +750,12 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) return HZ; } -int bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb) +void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; - if (ptp->txts_req.tx_skb) { - netdev_err(bp->dev, "deferring skb:one SKB is still outstanding\n"); - return -EBUSY; - } ptp->txts_req.tx_skb = skb; ptp_schedule_worker(ptp->ptp_clock, 0); - return 0; } int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h index 90f1418211e9..ee1709cda47e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h @@ -159,7 +159,7 @@ int bnxt_ptp_cfg_tstamp_filters(struct bnxt *bp); void bnxt_ptp_reapply_pps(struct bnxt *bp); int bnxt_hwtstamp_set(struct net_device *dev, struct ifreq *ifr); int bnxt_hwtstamp_get(struct net_device *dev, struct ifreq *ifr); -int bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb); +void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb); int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts); void bnxt_tx_ts_cmp(struct bnxt *bp, struct bnxt_napi *bnapi, struct tx_ts_cmp *tscmp); From patchwork Wed Jun 26 16:43:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713192 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4619A18FDCF for ; Wed, 26 Jun 2024 16:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420227; cv=none; b=kSt5/8bSsYQy95Wy3/g0/yZnMoG1t6RJ8zW0w9f9yQ8nACuad4XxuTC22Ca5GsCtOiMeRTnEt30te6Ss2t1meYOXI2naayVi7icMI9bkoSyz/T0NmpCJh9DXxvAOuWMsF5Z/7ysWL1qUU3qe5Y0jsswAKimtnVEO4w4i9V5PVjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420227; c=relaxed/simple; bh=T+6CFfWRYFa8uJvryOyD05vwqYzv5B++kfE6kXjp58k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G/BxcKBM+JoKtuVBI2URBogHY30Dh6GzT/G3LnrFFwhi9+Tlo2suuKXkbR/mCjqSdoH9qmsOffW6ab70uGJBN379D61vsu+4yVaPeHXnw4ceNaLK+y3pJ487PHU/VT9YFSGfDLNpwci59vBITYu+m1FGD101AfJ2MDDp1ZOvBwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=gtfwDIKz; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="gtfwDIKz" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-79c05313ec8so137393985a.3 for ; Wed, 26 Jun 2024 09:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420225; x=1720025025; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=+Onr20j6DLjsl7PydSZyHaOF9uCE8J6kvDxx3ihAZjM=; b=gtfwDIKzDhetyHWGyAzaY9RPzwOA1+LNOHp9jTU+cyb8i654ol7yANagl9Bsi3M6Oc fwqWq3IOXpbETB6V+3tYpmR6zFDix6pVEdh5wTOLer7KMfmoxFLJD/LnKFnQUk8l8v6A +a86S2TBSiFpW8Z5FrYADch8Vq+nqxYCAaKrI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420225; x=1720025025; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+Onr20j6DLjsl7PydSZyHaOF9uCE8J6kvDxx3ihAZjM=; b=Zefd6Kx72u+KFCF00OKZBiLydWcB0Sk1MU7gk+EHqQWf56omeO3CXcJ0O1l1MxsZ1q RyRSJmB67TT5w64/JIiCIwKk8EHc1Vn4Prk1LTLO7zJeJEftF6euh9mt6Ju7WZO2kurS FdjhASzYSKTPU67G5MZcAvfoGf4NNWpvscw2CiOwxgn31G0Df2c6fQ/yOyYG07KQLNAK oEAsoF2CQe9NUFNlssNKf03ijg44lwrgOReQXGl0vkTo11EG1gaRuJwDx6TzaAv5McQ5 HtYQP0mNiTc+h9UpJJTAGFiZg+Dc6LftXURLrJaSs2b6vXV+0/cogG9MoYuBc5fZvAAD 4XbA== X-Gm-Message-State: AOJu0YyK73yf9+z0CRZoR2HfAn+Ui2Wl7zx56CHITkK/CBh+1njHdPk8 H2gjhyxdjoeRB0hrLiZGXhYAkRWhW7tVdSqZKpHRf0VGWlvrGQVEUvsu5dvI/X/sMFGazrDPK7I = X-Google-Smtp-Source: AGHT+IFTa5APjcViZnk55jjLe/Zt9Ne6itwXSib0m1UbgitndDXB1u/4+RLN7sMdxBnKSWJHJnjVBg== X-Received: by 2002:a05:620a:240f:b0:795:5115:5ae3 with SMTP id af79cd13be357-79be47b7035mr1245339685a.50.1719420224734; Wed, 26 Jun 2024 09:43:44 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:44 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 08/10] bnxt_en: Let bnxt_stamp_tx_skb() return error code Date: Wed, 26 Jun 2024 09:43:05 -0700 Message-ID: <20240626164307.219568-9-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Pavan Chebbi Change the function bnxt_stamp_tx_skb() to return 0 for suceess or -EAGAIN if the timestamp is still pending in firmware. The calling PTP aux worker will reschedule based on the return code. Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index baf191959b13..bd1e270307ec 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -683,7 +683,7 @@ static u64 bnxt_cc_read(const struct cyclecounter *cc) return ns; } -static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) +static int bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; struct skb_shared_hwtstamps timestamp; @@ -711,7 +711,7 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) } else { if (!time_after_eq(jiffies, txts_req->abs_txts_tmo)) { txts_req->txts_pending = true; - return; + return -EAGAIN; } ptp->stats.ts_lost++; netdev_warn_once(bp->dev, @@ -722,6 +722,8 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) txts_req->tx_skb = NULL; atomic_inc(&ptp->tx_avail); txts_req->txts_pending = false; + + return 0; } static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) @@ -730,12 +732,16 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) ptp_info); unsigned long now = jiffies; struct bnxt *bp = ptp->bp; + int rc = 0; if (ptp->txts_req.tx_skb) - bnxt_stamp_tx_skb(bp, ptp->txts_req.tx_skb); + rc = bnxt_stamp_tx_skb(bp, ptp->txts_req.tx_skb); - if (!time_after_eq(now, ptp->next_period)) + if (!time_after_eq(now, ptp->next_period)) { + if (rc == -EAGAIN) + return 0; return ptp->next_period - now; + } bnxt_ptp_get_current_time(bp); ptp->next_period = now + HZ; @@ -745,7 +751,7 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) spin_unlock_bh(&ptp->ptp_lock); ptp->next_overflow_check = now + BNXT_PHC_OVERFLOW_PERIOD; } - if (ptp->txts_req.txts_pending) + if (rc == -EAGAIN) return 0; return HZ; } From patchwork Wed Jun 26 16:43:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713193 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BE44190048 for ; Wed, 26 Jun 2024 16:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420229; cv=none; b=c/uqYKS7bjd+SkE3i2KmzbrImBZYQELPCNAl/Nn5h+PvUgVSys/woYC2LgzMQZA4r9Q+iUdKxt2TEi0TbGtmPp2byfPG/beXIq53ZYFJce9OYCTrpGY54hlmkMC33SPV0wCixNvJSkY+/jYrIIcHI1Xij5HZz/pHYQSxiyerMaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420229; c=relaxed/simple; bh=sJStlnB9fWAEGYpCSoEKaJayVhNaFjOGHDwgVAWaBNw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qirwYHnZcffemug41pVhjSzAr6QNNq9bMoRXx5VBK6G/4bAyNAmGeIlbLpF9iiiNfzfNkiICAF5164r9rF1MbRqXU0EbTOmrnDY/vinEyDh5I0FxQVyKn9lduoN+P6SAdZqFV6zWvqOs6CKQ37FR6qluc8gNjKg9k2xkKtrx2eA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=IOdMvZa/; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="IOdMvZa/" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-79c0c19ff02so170674885a.1 for ; Wed, 26 Jun 2024 09:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420227; x=1720025027; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=1hEYwL9Fupc00iZDfi/Asu3b+s07hnOP4btyY4Rsc18=; b=IOdMvZa/qyy225COwVlVJevzXTkp23fHosqDanjJusYjTdh6K3KyE58gh5cwQ4I9eQ fI2rsSxxMDOpsKwAZ5qMp21PzWl0SbuKJKYpTdzK1+dZPofWnl0lQFRk9Vt0v4Mvbslx ai8OJr70JtLtP1OvB4OQH+EeeFXPO0b1bvjt4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420227; x=1720025027; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1hEYwL9Fupc00iZDfi/Asu3b+s07hnOP4btyY4Rsc18=; b=R1sS31vbjmRj7rb6XlE1Pa4+TfkiPnPKlk797QdwW+cBg/tbFFOXX/REdqF930Iibg 3hpdGQDrU48tztFsTj0X2O2OLbGIVnp4R09cIpkEvq/A9FqYxLu0i1MRPV6zRXI3bCAJ cA6a7nGfDHwuoJ8wcyGV6i9eQBFSC7IktVMVxUNTGKloGV5LERq7xFaCLWIcHCi5Di0g WMbRKma1/5EXWA7nRpzC8lkqaNcz3G/VvN621/4PxMD8YJ0tufkSUelIF82eFbULUm9q YjM8KczGAEPfEWbhmGqf05jqmPAsRd3y8+1aFfLrA/RJ2ObCNySQcsWSCi04sIoUC4Xj MCIw== X-Gm-Message-State: AOJu0YyYsLox7y+yCVMCdC3Q7KDkU3KEgVjZ9MKsbJu/j/XApzijCpOI XDhIoOD9Y/q91yO2yQzlJsdLSwHBiyhIRpc1sATtSQyYtjQ1zZEWnU5G771L+Q== X-Google-Smtp-Source: AGHT+IE0+SSXYEZT7cNEnooLGTr36Q/WJj60azfBzlTY4qF/arh2Bmf8fCdm+j1mOZ58ng9Z+nBmxA== X-Received: by 2002:a05:620a:400a:b0:795:f319:e4a5 with SMTP id af79cd13be357-79be6f23dd1mr1310009985a.66.1719420226301; Wed, 26 Jun 2024 09:43:46 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:45 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 09/10] bnxt_en: Increase the max total outstanding PTP TX packets to 4 Date: Wed, 26 Jun 2024 09:43:06 -0700 Message-ID: <20240626164307.219568-10-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Pavan Chebbi Start accepting up to 4 TX TS requests on BCM5750X (P5) chips. These PTP TX packets will be queued in the ptp->txts_req[] array waiting for the TX timestamp to complete. The entries in the array will be managed by a producer and consumer index. The producer index is updated under spinlock since multiple TX rings can try to send PTP packets at the same time. Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 +++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 60 ++++++++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 13 ++-- 4 files changed, 68 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index ed2bbdf6b25f..0867861c14bd 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -457,8 +457,8 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) unsigned int length, pad = 0; u32 len, free_size, vlan_tag_flags, cfa_action, flags; struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; - u16 prod, last_frag; struct pci_dev *pdev = bp->pdev; + u16 prod, last_frag, txts_prod; struct bnxt_tx_ring_info *txr; struct bnxt_sw_tx_bd *tx_buf; __le32 lflags = 0; @@ -526,11 +526,19 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) if (!bnxt_ptp_parse(skb, &seq_id, &hdr_off)) { if (vlan_tag_flags) hdr_off += VLAN_HLEN; - ptp->txts_req.tx_seqid = seq_id; - ptp->txts_req.tx_hdr_off = hdr_off; lflags |= cpu_to_le32(TX_BD_FLAGS_STAMP); tx_buf->is_ts_pkt = 1; skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; + + spin_lock_bh(&ptp->ptp_tx_lock); + txts_prod = ptp->txts_prod; + ptp->txts_prod = NEXT_TXTS(txts_prod); + spin_unlock_bh(&ptp->ptp_tx_lock); + + ptp->txts_req[txts_prod].tx_seqid = seq_id; + ptp->txts_req[txts_prod].tx_hdr_off = hdr_off; + tx_buf->txts_prod = txts_prod; + } else { atomic_inc(&bp->ptp_cfg->tx_avail); } @@ -770,7 +778,9 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) tx_kick_pending: if (BNXT_TX_PTP_IS_SET(lflags)) { atomic64_inc(&bp->ptp_cfg->stats.ts_err); - atomic_inc(&bp->ptp_cfg->tx_avail); + if (!(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) + /* set SKB to err so PTP worker will clean up */ + ptp->txts_req[txts_prod].tx_skb = ERR_PTR(-EIO); } if (txr->kick_pending) bnxt_txr_db_kick(bp, txr, txr->tx_prod); @@ -838,7 +848,7 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, if (unlikely(is_ts_pkt)) { if (BNXT_CHIP_P5(bp)) { /* PTP worker takes ownership of the skb */ - bnxt_get_tx_ts_p5(bp, skb); + bnxt_get_tx_ts_p5(bp, skb, tx_buf->txts_prod); skb = NULL; } } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 82b05641953f..e46bd11e52b0 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -878,7 +878,10 @@ struct bnxt_sw_tx_bd { u8 is_push; u8 action; unsigned short nr_frags; - u16 rx_prod; + union { + u16 rx_prod; + u16 txts_prod; + }; }; struct bnxt_sw_rx_bd { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index bd1e270307ec..9e93dc8b2b57 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -110,7 +110,7 @@ static void bnxt_ptp_get_current_time(struct bnxt *bp) } static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts, - u32 txts_tmo) + u32 txts_tmo, int slot) { struct hwrm_port_ts_query_output *resp; struct hwrm_port_ts_query_input *req; @@ -123,7 +123,7 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts, req->flags = cpu_to_le32(flags); if ((flags & PORT_TS_QUERY_REQ_FLAGS_PATH) == PORT_TS_QUERY_REQ_FLAGS_PATH_TX) { - struct bnxt_ptp_tx_req *txts_req = &bp->ptp_cfg->txts_req; + struct bnxt_ptp_tx_req *txts_req = &bp->ptp_cfg->txts_req[slot]; u32 tmo_us = txts_tmo * 1000; req->enables = cpu_to_le16(BNXT_PTP_QTS_TX_ENABLES); @@ -683,7 +683,7 @@ static u64 bnxt_cc_read(const struct cyclecounter *cc) return ns; } -static int bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) +static int bnxt_stamp_tx_skb(struct bnxt *bp, int slot) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; struct skb_shared_hwtstamps timestamp; @@ -693,13 +693,13 @@ static int bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) u32 tmo = 0; int rc; - txts_req = &ptp->txts_req; - if (!txts_req->txts_pending) - txts_req->abs_txts_tmo = now + msecs_to_jiffies(ptp->txts_tmo); + txts_req = &ptp->txts_req[slot]; + /* make sure bnxt_get_tx_ts_p5() has updated abs_txts_tmo */ + smp_rmb(); if (!time_after_eq(now, txts_req->abs_txts_tmo)) tmo = jiffies_to_msecs(txts_req->abs_txts_tmo - now); rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_PATH_TX, &ts, - tmo); + tmo, slot); if (!rc) { memset(×tamp, 0, sizeof(timestamp)); spin_lock_bh(&ptp->ptp_lock); @@ -709,10 +709,9 @@ static int bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) skb_tstamp_tx(txts_req->tx_skb, ×tamp); ptp->stats.ts_pkts++; } else { - if (!time_after_eq(jiffies, txts_req->abs_txts_tmo)) { - txts_req->txts_pending = true; + if (!time_after_eq(jiffies, txts_req->abs_txts_tmo)) return -EAGAIN; - } + ptp->stats.ts_lost++; netdev_warn_once(bp->dev, "TS query for TX timer failed rc = %x\n", rc); @@ -720,8 +719,6 @@ static int bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) dev_kfree_skb_any(txts_req->tx_skb); txts_req->tx_skb = NULL; - atomic_inc(&ptp->tx_avail); - txts_req->txts_pending = false; return 0; } @@ -732,10 +729,24 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) ptp_info); unsigned long now = jiffies; struct bnxt *bp = ptp->bp; + u16 cons = ptp->txts_cons; + u8 num_requests; int rc = 0; - if (ptp->txts_req.tx_skb) - rc = bnxt_stamp_tx_skb(bp, ptp->txts_req.tx_skb); + num_requests = BNXT_MAX_TX_TS - atomic_read(&ptp->tx_avail); + while (num_requests--) { + if (IS_ERR(ptp->txts_req[cons].tx_skb)) + goto next_slot; + if (!ptp->txts_req[cons].tx_skb) + break; + rc = bnxt_stamp_tx_skb(bp, cons); + if (rc == -EAGAIN) + break; +next_slot: + atomic_inc(&ptp->tx_avail); + cons = NEXT_TXTS(cons); + } + ptp->txts_cons = cons; if (!time_after_eq(now, ptp->next_period)) { if (rc == -EAGAIN) @@ -756,11 +767,16 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) return HZ; } -void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb) +void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb, u16 prod) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; + struct bnxt_ptp_tx_req *txts_req; - ptp->txts_req.tx_skb = skb; + txts_req = &ptp->txts_req[prod]; + txts_req->abs_txts_tmo = jiffies + msecs_to_jiffies(ptp->txts_tmo); + /* make sure abs_txts_tmo is written first */ + smp_wmb(); + txts_req->tx_skb = skb; ptp_schedule_worker(ptp->ptp_clock, 0); } @@ -958,7 +974,7 @@ int bnxt_ptp_init_rtc(struct bnxt *bp, bool phc_cfg) return rc; } else { rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME, - &ns, 0); + &ns, 0, 0); if (rc) return rc; } @@ -1000,6 +1016,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg) atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS); spin_lock_init(&ptp->ptp_lock); + spin_lock_init(&ptp->ptp_tx_lock); if (BNXT_PTP_USE_RTC(bp)) { bnxt_ptp_timecounter_init(bp, false); @@ -1049,6 +1066,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg) void bnxt_ptp_clear(struct bnxt *bp) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; + int i; if (!ptp) return; @@ -1060,9 +1078,11 @@ void bnxt_ptp_clear(struct bnxt *bp) kfree(ptp->ptp_info.pin_config); ptp->ptp_info.pin_config = NULL; - if (ptp->txts_req.tx_skb) { - dev_kfree_skb_any(ptp->txts_req.tx_skb); - ptp->txts_req.tx_skb = NULL; + for (i = 0; i < BNXT_MAX_TX_TS; i++) { + if (ptp->txts_req[i].tx_skb) { + dev_kfree_skb_any(ptp->txts_req[i].tx_skb); + ptp->txts_req[i].tx_skb = NULL; + } } bnxt_unmap_ptp_regs(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h index ee1709cda47e..a1910ce86cbb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h @@ -85,11 +85,13 @@ struct bnxt_ptp_stats { atomic64_t ts_err; }; +#define BNXT_MAX_TX_TS 4 +#define NEXT_TXTS(idx) (((idx) + 1) & (BNXT_MAX_TX_TS - 1)) + struct bnxt_ptp_tx_req { struct sk_buff *tx_skb; u16 tx_seqid; u16 tx_hdr_off; - u8 txts_pending:1; unsigned long abs_txts_tmo; }; @@ -101,6 +103,8 @@ struct bnxt_ptp_cfg { struct bnxt_pps pps_info; /* serialize timecounter access */ spinlock_t ptp_lock; + /* serialize ts tx request queuing */ + spinlock_t ptp_tx_lock; u64 current_time; u64 old_time; unsigned long next_period; @@ -109,11 +113,10 @@ struct bnxt_ptp_cfg { /* a 23b shift cyclecounter will overflow in ~36 mins. Check overflow every 18 mins. */ #define BNXT_PHC_OVERFLOW_PERIOD (18 * 60 * HZ) - struct bnxt_ptp_tx_req txts_req; + struct bnxt_ptp_tx_req txts_req[BNXT_MAX_TX_TS]; struct bnxt *bp; atomic_t tx_avail; -#define BNXT_MAX_TX_TS 1 u16 rxctl; #define BNXT_PTP_MSG_SYNC (1 << 0) #define BNXT_PTP_MSG_DELAY_REQ (1 << 1) @@ -136,6 +139,8 @@ struct bnxt_ptp_cfg { u32 refclk_regs[2]; u32 refclk_mapped_regs[2]; u32 txts_tmo; + u16 txts_prod; + u16 txts_cons; struct bnxt_ptp_stats stats; }; @@ -159,7 +164,7 @@ int bnxt_ptp_cfg_tstamp_filters(struct bnxt *bp); void bnxt_ptp_reapply_pps(struct bnxt *bp); int bnxt_hwtstamp_set(struct net_device *dev, struct ifreq *ifr); int bnxt_hwtstamp_get(struct net_device *dev, struct ifreq *ifr); -void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb); +void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb, u16 prod); int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts); void bnxt_tx_ts_cmp(struct bnxt *bp, struct bnxt_napi *bnapi, struct tx_ts_cmp *tscmp); From patchwork Wed Jun 26 16:43:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713194 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01C3119005C for ; Wed, 26 Jun 2024 16:43:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420231; cv=none; b=MLbr9wDW1ZUjLaH5VGz0YywHWktjIr05xEu20tGFZ4DhdtvKGIfDbutsFyMCHpNdrUvl254gHHHc0MoVT6/phVeCyzYF4RCXFmRuR1vj4PfI70aU8mIGx8l6RX7Uj6d4bJQD7fpegwJcyPhUkq6qVEfnoSlLyY3Egrs411NQ+fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420231; c=relaxed/simple; bh=TYZihhcJLI9Jc2q8IoZj+IrpCL17UkK/hF5iG/wr9iE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pzvyu5qAbR/Ibq+tqMeuOczlR1F0BZfw95I282wkvAmR9QyFJtmES9v4BAAm50T4SKctkkncs6uExNWm6GtZsdnd/bvBBMUkLokQ+cvmdVjtC1XoDnjHBy6vbdbdO/p13FM8rWNd7jPF01C6It0kk/SfV/KQjkUGKNtKm01Sbj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Kr7hBLq5; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Kr7hBLq5" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-79c03dbddb8so213240485a.1 for ; Wed, 26 Jun 2024 09:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420229; x=1720025029; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=lJTGUEIo8u1qOej4wyadsnCa5VyT8DqBoHdj7C7oF7k=; b=Kr7hBLq5+Pqd0tYiRZXhX5foM/yxbFTOZHcFktZBhXJykwAhm7BvMTn04AR2wxOtBc eAtsd7jJOihyx57rjHu4/9lvNX+wDEMTWAbpcuJbQSgOzK11oar0iWnC5rSHyzGgDkMk Re0/1UM2dUEfeKAINFkMuUGno3LaLFWK7nGvc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420229; x=1720025029; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lJTGUEIo8u1qOej4wyadsnCa5VyT8DqBoHdj7C7oF7k=; b=HaCuU2KmHfsPabXG22fBr1dkg5EQySWjYQcahRgeber2z1hZ2PYV2gHIwd50gxCfxQ 3UFru/maT2Ox8zEbOoJbxHaXsyKvQxFhnP/9INR83DWElKDUnYGz1DiedTO1pe8r/Jq6 FJ6eZ9YGvq0QAIw0Gkj3a56Wmq8i88vfoVNFlG89PcKtGHKEZhJ+y4hfAGDL8zrF4ceA v1/W5rbNCP2LwZuH7CH3FzHTFvPIohfyzo8EqeACR6Em6U21aMEt+SqwIGU8S4AEYY3/ rb2HWGOe/2we3pmR9PO4eNmCM1w8zgg6DKBH9fW4jRxl0GaI40gL8DFw6Kv2OPV6mMBb 3RQQ== X-Gm-Message-State: AOJu0YzGf7xfYrS85SNks8Hk4wqAKgWWpn2griZLNwGQ4ErzcXNMLTy0 B7lldtTQPTfgi8w5jLhFOC59ajubt124A7PBSvXgd2PU8nOr1GUkSeth+qnu2A== X-Google-Smtp-Source: AGHT+IEd6IAO41h/+sp57VuozyNBm8RrPqtxSFFSmOrj63uAC5pMB9pmrrey7JKDqvlpJQ1DUQ3FOw== X-Received: by 2002:a05:620a:2951:b0:79d:5a77:aea8 with SMTP id af79cd13be357-79d5a77b290mr3419785a.1.1719420228554; Wed, 26 Jun 2024 09:43:48 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:47 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 10/10] bnxt_en: Remove atomic operations on ptp->tx_avail Date: Wed, 26 Jun 2024 09:43:07 -0700 Message-ID: <20240626164307.219568-11-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Pavan Chebbi Now that we require the spinlock to protect ptp->txts_prod, change ptp->tx_avail to non-atomic and protect it under the same spinlock. Add a new helper function bnxt_ptp_get_txts_prod() to decrement ptp->tx_avail under spinlock and return the producer. Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 +++------------- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 23 +++++++++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 10 +++++++- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0867861c14bd..33ba1964168b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -518,34 +518,20 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) } else if (!skb_is_gso(skb)) { u16 seq_id, hdr_off; - if (atomic_dec_if_positive(&ptp->tx_avail) < 0) { - atomic64_inc(&ptp->stats.ts_err); - goto tx_no_ts; - } - - if (!bnxt_ptp_parse(skb, &seq_id, &hdr_off)) { + if (!bnxt_ptp_parse(skb, &seq_id, &hdr_off) && + !bnxt_ptp_get_txts_prod(ptp, &txts_prod)) { if (vlan_tag_flags) hdr_off += VLAN_HLEN; lflags |= cpu_to_le32(TX_BD_FLAGS_STAMP); tx_buf->is_ts_pkt = 1; skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; - spin_lock_bh(&ptp->ptp_tx_lock); - txts_prod = ptp->txts_prod; - ptp->txts_prod = NEXT_TXTS(txts_prod); - spin_unlock_bh(&ptp->ptp_tx_lock); - ptp->txts_req[txts_prod].tx_seqid = seq_id; ptp->txts_req[txts_prod].tx_hdr_off = hdr_off; tx_buf->txts_prod = txts_prod; - - } else { - atomic_inc(&bp->ptp_cfg->tx_avail); } } } - -tx_no_ts: if (unlikely(skb->no_fcs)) lflags |= cpu_to_le32(TX_BD_FLAGS_NO_CRC); @@ -12184,7 +12170,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) if (BNXT_PF(bp)) bnxt_vf_reps_open(bp); if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) - atomic_set(&bp->ptp_cfg->tx_avail, BNXT_MAX_TX_TS); + WRITE_ONCE(bp->ptp_cfg->tx_avail, BNXT_MAX_TX_TS); bnxt_ptp_init_rtc(bp, true); bnxt_ptp_cfg_tstamp_filters(bp); if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp)) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index 9e93dc8b2b57..37d42423459c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -730,10 +730,10 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) unsigned long now = jiffies; struct bnxt *bp = ptp->bp; u16 cons = ptp->txts_cons; - u8 num_requests; + u32 num_requests; int rc = 0; - num_requests = BNXT_MAX_TX_TS - atomic_read(&ptp->tx_avail); + num_requests = BNXT_MAX_TX_TS - READ_ONCE(ptp->tx_avail); while (num_requests--) { if (IS_ERR(ptp->txts_req[cons].tx_skb)) goto next_slot; @@ -743,7 +743,7 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) if (rc == -EAGAIN) break; next_slot: - atomic_inc(&ptp->tx_avail); + BNXT_PTP_INC_TX_AVAIL(ptp); cons = NEXT_TXTS(cons); } ptp->txts_cons = cons; @@ -767,6 +767,21 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info) return HZ; } +int bnxt_ptp_get_txts_prod(struct bnxt_ptp_cfg *ptp, u16 *prod) +{ + spin_lock_bh(&ptp->ptp_tx_lock); + if (ptp->tx_avail) { + *prod = ptp->txts_prod; + ptp->txts_prod = NEXT_TXTS(*prod); + ptp->tx_avail--; + spin_unlock_bh(&ptp->ptp_tx_lock); + return 0; + } + spin_unlock_bh(&ptp->ptp_tx_lock); + atomic64_inc(&ptp->stats.ts_err); + return -ENOSPC; +} + void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb, u16 prod) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; @@ -1014,7 +1029,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg) bnxt_ptp_free(bp); - atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS); + WRITE_ONCE(ptp->tx_avail, BNXT_MAX_TX_TS); spin_lock_init(&ptp->ptp_lock); spin_lock_init(&ptp->ptp_tx_lock); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h index a1910ce86cbb..a9a2f9a18c9c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h @@ -116,7 +116,7 @@ struct bnxt_ptp_cfg { struct bnxt_ptp_tx_req txts_req[BNXT_MAX_TX_TS]; struct bnxt *bp; - atomic_t tx_avail; + u32 tx_avail; u16 rxctl; #define BNXT_PTP_MSG_SYNC (1 << 0) #define BNXT_PTP_MSG_DELAY_REQ (1 << 1) @@ -157,6 +157,13 @@ do { \ ((dst) = READ_ONCE(src)) #endif +#define BNXT_PTP_INC_TX_AVAIL(ptp) \ +do { \ + spin_lock_bh(&(ptp)->ptp_tx_lock); \ + (ptp)->tx_avail++; \ + spin_unlock_bh(&(ptp)->ptp_tx_lock); \ +} while (0) + int bnxt_ptp_parse(struct sk_buff *skb, u16 *seq_id, u16 *hdr_off); void bnxt_ptp_update_current_time(struct bnxt *bp); void bnxt_ptp_pps_event(struct bnxt *bp, u32 data1, u32 data2); @@ -164,6 +171,7 @@ int bnxt_ptp_cfg_tstamp_filters(struct bnxt *bp); void bnxt_ptp_reapply_pps(struct bnxt *bp); int bnxt_hwtstamp_set(struct net_device *dev, struct ifreq *ifr); int bnxt_hwtstamp_get(struct net_device *dev, struct ifreq *ifr); +int bnxt_ptp_get_txts_prod(struct bnxt_ptp_cfg *ptp, u16 *prod); void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb, u16 prod); int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts); void bnxt_tx_ts_cmp(struct bnxt *bp, struct bnxt_napi *bnapi,