netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
To: patrick@stwcx.xyz
Cc: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>,
	Samuel Mendoza-Jonas <sam@mendozajonas.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1] NCSI: Add propety : no-channel-monitor and start-redo-probe
Date: Thu, 18 Jan 2024 13:22:20 +0800	[thread overview]
Message-ID: <20240118052220.1906721-1-Delphine_CC_Chiu@wiwynn.com> (raw)

Add property start-redo-probe to redo probe, because Mellanox cx7 nic card
cannot't get mac address after nic card hot-plug.
Setup start-redo-probe property so that nic card can get MAC address again.
Also setup no-channel-monitor property so that the log won't keep
popping up when nic card host-plug.

Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
---
 net/ncsi/internal.h    |  6 ++++++
 net/ncsi/ncsi-manage.c | 25 +++++++++++++++++++++++--
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index 03757e76bb6b..a605271e04b4 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -199,6 +199,11 @@ struct ncsi_channel_stats {
 	u32 pt_rx_os_err;	/* Rx oversize errors         */
 };
 
+enum {
+	NCSI_CTRL_FLAG_NO_CHANNEL_MONITOR	= 0x0001,
+	NCSI_CTRL_FLAG_START_REDO_PROBE		= 0x0002,
+};
+
 struct ncsi_dev_priv;
 struct ncsi_package;
 
@@ -340,6 +345,7 @@ struct ncsi_dev_priv {
 	bool                multi_package;   /* Enable multiple packages   */
 	bool                mlx_multi_host;  /* Enable multi host Mellanox */
 	u32                 package_whitelist; /* Packages to configure    */
+	unsigned int        ctrl_flags;      /* NCSI control flags */
 };
 
 struct ncsi_cmd_arg {
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index d9da942ad53d..21a4b4db3cdc 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -1211,7 +1211,8 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
 		ndp->hot_channel = hot_nc;
 		spin_unlock_irqrestore(&ndp->lock, flags);
 
-		ncsi_start_channel_monitor(nc);
+		if (!(ndp->ctrl_flags & NCSI_CTRL_FLAG_NO_CHANNEL_MONITOR))
+			ncsi_start_channel_monitor(nc);
 		ncsi_process_next_channel(ndp);
 		break;
 	default:
@@ -1779,6 +1780,7 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
 	INIT_LIST_HEAD(&ndp->vlan_vids);
 	INIT_WORK(&ndp->work, ncsi_dev_work);
 	ndp->package_whitelist = UINT_MAX;
+	ndp->ctrl_flags = 0;
 
 	/* Initialize private NCSI device */
 	spin_lock_init(&ndp->lock);
@@ -1804,8 +1806,14 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
 	if (pdev) {
 		np = pdev->dev.of_node;
 		if (np && (of_property_read_bool(np, "mellanox,multi-host") ||
-			   of_property_read_bool(np, "mlx,multi-host")))
+			of_property_read_bool(np, "mlx,multi-host")))
 			ndp->mlx_multi_host = true;
+
+		if (np && of_get_property(np, "ncsi-ctrl,no-channel-monitor", NULL))
+			ndp->ctrl_flags |= NCSI_CTRL_FLAG_NO_CHANNEL_MONITOR;
+
+		if (np && of_get_property(np, "ncsi-ctrl,start-redo-probe", NULL))
+			ndp->ctrl_flags |= NCSI_CTRL_FLAG_START_REDO_PROBE;
 	}
 
 	return nd;
@@ -1815,11 +1823,24 @@ EXPORT_SYMBOL_GPL(ncsi_register_dev);
 int ncsi_start_dev(struct ncsi_dev *nd)
 {
 	struct ncsi_dev_priv *ndp = TO_NCSI_DEV_PRIV(nd);
+	struct ncsi_package *np, *tmp;
+	unsigned long flags;
 
 	if (nd->state != ncsi_dev_state_registered &&
 	    nd->state != ncsi_dev_state_functional)
 		return -ENOTTY;
 
+	if (ndp->ctrl_flags & NCSI_CTRL_FLAG_START_REDO_PROBE) {
+		nd->state = ncsi_dev_state_probe;
+		spin_lock_irqsave(&ndp->lock, flags);
+		ndp->flags &= ~NCSI_DEV_PROBED;
+		ndp->gma_flag = 0;
+		spin_unlock_irqrestore(&ndp->lock, flags);
+
+		list_for_each_entry_safe(np, tmp, &ndp->packages, node)
+			ncsi_remove_package(np);
+	}
+
 	if (!(ndp->flags & NCSI_DEV_PROBED)) {
 		ndp->package_probe_id = 0;
 		nd->state = ncsi_dev_state_probe;
-- 
2.25.1


             reply	other threads:[~2024-01-18  5:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18  5:22 Delphine CC Chiu [this message]
2024-01-20  5:36 ` [PATCH v1] NCSI: Add propety : no-channel-monitor and start-redo-probe Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240118052220.1906721-1-Delphine_CC_Chiu@wiwynn.com \
    --to=delphine_cc_chiu@wiwynn.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=patrick@stwcx.xyz \
    --cc=sam@mendozajonas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).