Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2024 18:39:21 GMT
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: cd2ae696295f - stable/14 - cxgbe/iw_cxgbe: Replace the fatal error flag with a stopped flag.
Message-ID:  <202410211839.49LIdLXn036672@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by np:

URL: https://cgit.FreeBSD.org/src/commit/?id=cd2ae696295f22db7ee72f528cea646c9c6cdcfb

commit cd2ae696295f22db7ee72f528cea646c9c6cdcfb
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-08-28 18:41:10 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2024-10-21 17:07:49 +0000

    cxgbe/iw_cxgbe: Replace the fatal error flag with a stopped flag.
    
    Now that suspend/resume is supported by the base driver, a fatal error
    isn't the only reason that the RNIC can stop abruptly.  Also, this state
    is no longer permanent as it's possible to resume operations after a
    stop.  Rename the flag and associated routines to match the new state of
    affairs.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 8254a276ad893ae2a1b35fcbbad255f06e29b8c6)
---
 sys/dev/cxgbe/iw_cxgbe/cm.c       | 10 +++++-----
 sys/dev/cxgbe/iw_cxgbe/device.c   | 11 ++++++++---
 sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h | 10 +++++-----
 sys/dev/cxgbe/iw_cxgbe/mem.c      |  2 +-
 4 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c
index 77158eb855df..2ca2fcb8041f 100644
--- a/sys/dev/cxgbe/iw_cxgbe/cm.c
+++ b/sys/dev/cxgbe/iw_cxgbe/cm.c
@@ -1089,7 +1089,7 @@ c4iw_so_upcall(struct socket *so, void *arg, int waitflag)
 	 * Wake up any threads waiting in rdma_init()/rdma_fini(),
 	 * with locks held.
 	 */
-	if (so->so_error || (ep->com.dev->rdev.flags & T4_FATAL_ERROR))
+	if (so->so_error || c4iw_stopped(&ep->com.dev->rdev))
 		c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET);
 	add_ep_to_req_list(ep, C4IW_EVENT_SOCKET);
 
@@ -2717,8 +2717,8 @@ c4iw_create_listen(struct iw_cm_id *cm_id, int backlog)
 
 	CTR3(KTR_IW_CXGBE, "%s: cm_id %p, backlog %s", __func__, cm_id,
 			backlog);
-	if (c4iw_fatal_error(&dev->rdev)) {
-		CTR2(KTR_IW_CXGBE, "%s: cm_id %p, fatal error", __func__,
+	if (c4iw_stopped(&dev->rdev)) {
+		CTR2(KTR_IW_CXGBE, "%s: cm_id %p, stopped", __func__,
 			       cm_id);
 		return -EIO;
 	}
@@ -2830,8 +2830,8 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
 
 	rdev = &ep->com.dev->rdev;
 
-	if (c4iw_fatal_error(rdev)) {
-		CTR3(KTR_IW_CXGBE, "%s:ced1 fatal error %p %s", __func__, ep,
+	if (c4iw_stopped(rdev)) {
+		CTR3(KTR_IW_CXGBE, "%s:ced1 stopped %p %s", __func__, ep,
 					states[ep->com.state]);
 		if (ep->com.state != DEAD) {
 			send_abort(ep);
diff --git a/sys/dev/cxgbe/iw_cxgbe/device.c b/sys/dev/cxgbe/iw_cxgbe/device.c
index 209d12767a1c..3c4d269f6c69 100644
--- a/sys/dev/cxgbe/iw_cxgbe/device.c
+++ b/sys/dev/cxgbe/iw_cxgbe/device.c
@@ -335,9 +335,8 @@ c4iw_stop(struct adapter *sc)
 	if (iwsc) {
 		struct ib_event event = {0};
 
-		device_printf(sc->dev,
-			      "iWARP driver received FATAL ERROR event.\n");
-		iwsc->rdev.flags |= T4_FATAL_ERROR;
+		device_printf(sc->dev, "iWARP driver stopped.\n");
+		iwsc->rdev.flags |= T4_IW_STOPPED;
 		event.event  = IB_EVENT_DEVICE_FATAL;
 		event.device = &iwsc->ibdev;
 		ib_dispatch_event(&event);
@@ -349,6 +348,12 @@ c4iw_stop(struct adapter *sc)
 static int
 c4iw_restart(struct adapter *sc)
 {
+	struct c4iw_dev *iwsc = sc->iwarp_softc;
+
+	if (iwsc) {
+		device_printf(sc->dev, "iWARP driver restarted.\n");
+		iwsc->rdev.flags &= ~T4_IW_STOPPED;
+	}
 	return (0);
 }
 
diff --git a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
index 5715b7e53863..ca2595b65b02 100644
--- a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
+++ b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
@@ -116,7 +116,7 @@ struct c4iw_dev_ucontext {
 };
 
 enum c4iw_rdev_flags {
-	T4_FATAL_ERROR = (1<<0),
+	T4_IW_STOPPED = (1<<0),
 	T4_STATUS_PAGE_DISABLED = (1<<1),
 };
 
@@ -167,9 +167,9 @@ struct c4iw_rdev {
 	struct workqueue_struct *free_workq;
 };
 
-static inline int c4iw_fatal_error(struct c4iw_rdev *rdev)
+static inline int c4iw_stopped(struct c4iw_rdev *rdev)
 {
-	return rdev->flags & T4_FATAL_ERROR;
+	return rdev->flags & T4_IW_STOPPED;
 }
 
 static inline int c4iw_num_stags(struct c4iw_rdev *rdev)
@@ -214,7 +214,7 @@ c4iw_wait_for_reply(struct c4iw_rdev *rdev, struct c4iw_wr_wait *wr_waitp,
 	int timedout = 0;
 	struct timeval t1, t2;
 
-	if (c4iw_fatal_error(rdev)) {
+	if (c4iw_stopped(rdev)) {
 		wr_waitp->ret = -EIO;
 		goto out;
 	}
@@ -240,7 +240,7 @@ c4iw_wait_for_reply(struct c4iw_rdev *rdev, struct c4iw_wr_wait *wr_waitp,
 			    "seconds - tid %u qpid %u\n", func,
 			    device_get_nameunit(sc->dev), t2.tv_sec, t2.tv_usec,
 			    hwtid, qpid);
-			if (c4iw_fatal_error(rdev)) {
+			if (c4iw_stopped(rdev)) {
 				wr_waitp->ret = -EIO;
 				break;
 			}
diff --git a/sys/dev/cxgbe/iw_cxgbe/mem.c b/sys/dev/cxgbe/iw_cxgbe/mem.c
index 5b8c7391514f..348cd3985e87 100644
--- a/sys/dev/cxgbe/iw_cxgbe/mem.c
+++ b/sys/dev/cxgbe/iw_cxgbe/mem.c
@@ -256,7 +256,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
 	u32 stag_idx;
 	static atomic_t key;
 
-	if (c4iw_fatal_error(rdev))
+	if (c4iw_stopped(rdev))
 		return -EIO;
 
 	stag_state = stag_state > 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410211839.49LIdLXn036672>