All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dennis Dalessandro <dennis.dalessandro@intel.com>
To: jgg@ziepe.ca, dledford@redhat.com
Cc: linux-rdma@vger.kernel.org,
	Mike Marciniszyn <mike.marciniszyn@intel.com>,
	Kaike Wan <kaike.wan@intel.com>
Subject: [PATCH for-next v2 06/11] IB/hfi1: IB/hfi1: Add an API to handle special case drop
Date: Tue, 26 Nov 2019 09:12:45 -0500	[thread overview]
Message-ID: <20191126141245.58836.286.stgit@awfm-01.aw.intel.com> (raw)
In-Reply-To: <20191126141055.58836.79452.stgit@awfm-01.aw.intel.com>

From: Mike Marciniszyn <mike.marciniszyn@intel.com>

This patch pushes special case drop logic into an API to be shared by
all interrupt handlers.

Additionally, convert do_drop to a bool.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
---
 drivers/infiniband/hw/hfi1/driver.c |    6 +-----
 drivers/infiniband/hw/hfi1/hfi.h    |   21 ++++++++++++++++++++-
 drivers/infiniband/hw/hfi1/init.c   |    4 ++--
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c
index 3671191..bbc7458 100644
--- a/drivers/infiniband/hw/hfi1/driver.c
+++ b/drivers/infiniband/hw/hfi1/driver.c
@@ -1004,11 +1004,7 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, int thread)
 	prescan_rxq(rcd, &packet);
 
 	while (last == RCV_PKT_OK) {
-		if (unlikely(dd->do_drop &&
-			     atomic_xchg(&dd->drop_packet, DROP_PACKET_OFF) ==
-			     DROP_PACKET_ON)) {
-			dd->do_drop = 0;
-
+		if (hfi1_need_drop(dd)) {
 			/* On to the next packet */
 			packet.rhqoff += packet.rsize;
 			packet.rhf_addr = (__le32 *)rcd->rcvhdrq +
diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
index b819d7d..9480499 100644
--- a/drivers/infiniband/hw/hfi1/hfi.h
+++ b/drivers/infiniband/hw/hfi1/hfi.h
@@ -1316,7 +1316,7 @@ struct hfi1_devdata {
 	struct err_info_constraint err_info_xmit_constraint;
 
 	atomic_t drop_packet;
-	u8 do_drop;
+	bool do_drop;
 	u8 err_info_uncorrectable;
 	u8 err_info_fmconfig;
 
@@ -2462,6 +2462,25 @@ static inline bool is_integrated(struct hfi1_devdata *dd)
 	return dd->pcidev->device == PCI_DEVICE_ID_INTEL1;
 }
 
+/**
+ * hfi1_need_drop - detect need for drop
+ * @dd: - the device
+ *
+ * In some cases, the first packet needs to be dropped.
+ *
+ * Return true is the current packet needs to be dropped and false otherwise.
+ */
+static inline bool hfi1_need_drop(struct hfi1_devdata *dd)
+{
+	if (unlikely(dd->do_drop &&
+		     atomic_xchg(&dd->drop_packet, DROP_PACKET_OFF) ==
+		     DROP_PACKET_ON)) {
+		dd->do_drop = false;
+		return true;
+	}
+	return false;
+}
+
 int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp);
 
 #define DD_DEV_ENTRY(dd)       __string(dev, dev_name(&(dd)->pcidev->dev))
diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
index 55adc97..2e6938c 100644
--- a/drivers/infiniband/hw/hfi1/init.c
+++ b/drivers/infiniband/hw/hfi1/init.c
@@ -876,10 +876,10 @@ int hfi1_init(struct hfi1_devdata *dd, int reinit)
 
 	if (is_ax(dd)) {
 		atomic_set(&dd->drop_packet, DROP_PACKET_ON);
-		dd->do_drop = 1;
+		dd->do_drop = true;
 	} else {
 		atomic_set(&dd->drop_packet, DROP_PACKET_OFF);
-		dd->do_drop = 0;
+		dd->do_drop = false;
 	}
 
 	/* make sure the link is not "up" */


  parent reply	other threads:[~2019-11-26 14:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 14:12 [PATCH for-next v2 00/11] rdmavt/hfi1 updates for next Dennis Dalessandro
2019-11-26 14:12 ` [PATCH for-next v2 01/11] IB/hfi1: Add accessor API routines to access context members Dennis Dalessandro
2019-11-26 14:12 ` [PATCH for-next v2 02/11] IB/hfi1: List all receive contexts from debugfs Dennis Dalessandro
2019-12-02 13:30   ` Ruhl, Michael J
2019-12-05 13:49   ` [PATCH for-next v3] " Dennis Dalessandro
2020-01-03 19:48     ` Jason Gunthorpe
2019-11-26 14:12 ` [PATCH for-next v2 03/11] IB/hfi1: Move chip specific functions to chip.c Dennis Dalessandro
2019-11-26 14:12 ` [PATCH for-next v2 04/11] IB/hfi1: Add fast and slow handlers for receive context Dennis Dalessandro
2019-11-26 14:12 ` [PATCH for-next v2 05/11] IB/hfi1: Move common receive IRQ code to function Dennis Dalessandro
2019-11-26 14:12 ` Dennis Dalessandro [this message]
2019-11-26 14:12 ` [PATCH for-next v2 07/11] IB/hfi1: Create API for auto activate Dennis Dalessandro
2019-11-26 14:12 ` [PATCH for-next v2 08/11] IB/hfi1: Decouple IRQ name from type Dennis Dalessandro
2019-11-26 14:13 ` [PATCH for-next v2 09/11] IB/hfi1: Return void in packet receiving functions Dennis Dalessandro
2019-11-26 14:13 ` [PATCH for-next v2 10/11] IB/rdmavt: Correct comments in rdmavt_qp.h header Dennis Dalessandro
2019-11-26 14:13 ` [PATCH for-next v2 11/11] IB/hfi1: Don't cancel unused work item Dennis Dalessandro
2019-11-26 15:31 ` [PATCH for-next v2 00/11] rdmavt/hfi1 updates for next Jason Gunthorpe
2019-12-11 13:34 ` Dennis Dalessandro
2019-12-11 16:21   ` Jason Gunthorpe
2019-12-11 16:33     ` Dennis Dalessandro

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=20191126141245.58836.286.stgit@awfm-01.aw.intel.com \
    --to=dennis.dalessandro@intel.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=kaike.wan@intel.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mike.marciniszyn@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.