DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wenjing Qiao <wenjing.qiao@intel.com>
To: jingjing.wu@intel.com, beilei.xing@intel.com, qi.z.zhang@intel.com
Cc: dev@dpdk.org, Wenjing Qiao <wenjing.qiao@intel.com>,
	NorbertX Ciosek <norbertx.ciosek@intel.com>
Subject: [PATCH 16/18] common/idpf: add func to clean all DESCs on controlq
Date: Thu, 13 Apr 2023 05:45:00 -0400	[thread overview]
Message-ID: <20230413094502.1714755-17-wenjing.qiao@intel.com> (raw)
In-Reply-To: <20230413094502.1714755-1-wenjing.qiao@intel.com>

Add 'idpf_ctlq_clean_sq_force' which will clean all descriptors on
given control queue. It is needed in case control plane is not
running and we need to do proper driver cleanup.

Signed-off-by: NorbertX Ciosek <norbertx.ciosek@intel.com>
Signed-off-by: Wenjing Qiao <wenjing.qiao@intel.com>
---
 drivers/common/idpf/base/idpf_controlq.c     | 56 ++++++++++++++++++--
 drivers/common/idpf/base/idpf_controlq_api.h |  4 ++
 2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/drivers/common/idpf/base/idpf_controlq.c b/drivers/common/idpf/base/idpf_controlq.c
index 8381e4000f..9374fce71e 100644
--- a/drivers/common/idpf/base/idpf_controlq.c
+++ b/drivers/common/idpf/base/idpf_controlq.c
@@ -386,13 +386,15 @@ int idpf_ctlq_send(struct idpf_hw *hw, struct idpf_ctlq_info *cq,
 }
 
 /**
- * idpf_ctlq_clean_sq - reclaim send descriptors on HW write back for the
- * requested queue
+ * __idpf_ctlq_clean_sq - helper function to reclaim descriptors on HW write
+ * back for the requested queue
  * @cq: pointer to the specific Control queue
  * @clean_count: (input|output) number of descriptors to clean as input, and
  * number of descriptors actually cleaned as output
  * @msg_status: (output) pointer to msg pointer array to be populated; needs
  * to be allocated by caller
+ * @force: (input) clean descriptors which were not done yet. Use with caution
+ * in kernel mode only
  *
  * Returns an array of message pointers associated with the cleaned
  * descriptors. The pointers are to the original ctlq_msgs sent on the cleaned
@@ -400,8 +402,8 @@ int idpf_ctlq_send(struct idpf_hw *hw, struct idpf_ctlq_info *cq,
  * to send will have a non-zero status. The caller is expected to free original
  * ctlq_msgs and free or reuse the DMA buffers.
  */
-int idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count,
-		       struct idpf_ctlq_msg *msg_status[])
+static int __idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count,
+				struct idpf_ctlq_msg *msg_status[], bool force)
 {
 	struct idpf_ctlq_desc *desc;
 	u16 i = 0, num_to_clean;
@@ -425,7 +427,7 @@ int idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count,
 	for (i = 0; i < num_to_clean; i++) {
 		/* Fetch next descriptor and check if marked as done */
 		desc = IDPF_CTLQ_DESC(cq, ntc);
-		if (!(LE16_TO_CPU(desc->flags) & IDPF_CTLQ_FLAG_DD))
+		if (!force && !(LE16_TO_CPU(desc->flags) & IDPF_CTLQ_FLAG_DD))
 			break;
 
 		desc_err = LE16_TO_CPU(desc->ret_val);
@@ -435,6 +437,8 @@ int idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count,
 		}
 
 		msg_status[i] = cq->bi.tx_msg[ntc];
+		if (!msg_status[i])
+			break;
 		msg_status[i]->status = desc_err;
 
 		cq->bi.tx_msg[ntc] = NULL;
@@ -457,6 +461,48 @@ int idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count,
 	return ret;
 }
 
+/**
+ * idpf_ctlq_clean_sq_force - reclaim all descriptors on HW write back for the
+ * requested queue. Use only in kernel mode.
+ * @cq: pointer to the specific Control queue
+ * @clean_count: (input|output) number of descriptors to clean as input, and
+ * number of descriptors actually cleaned as output
+ * @msg_status: (output) pointer to msg pointer array to be populated; needs
+ * to be allocated by caller
+ *
+ * Returns an array of message pointers associated with the cleaned
+ * descriptors. The pointers are to the original ctlq_msgs sent on the cleaned
+ * descriptors.  The status will be returned for each; any messages that failed
+ * to send will have a non-zero status. The caller is expected to free original
+ * ctlq_msgs and free or reuse the DMA buffers.
+ */
+int idpf_ctlq_clean_sq_force(struct idpf_ctlq_info *cq, u16 *clean_count,
+			     struct idpf_ctlq_msg *msg_status[])
+{
+	return __idpf_ctlq_clean_sq(cq, clean_count, msg_status, true);
+}
+
+/**
+ * idpf_ctlq_clean_sq - reclaim send descriptors on HW write back for the
+ * requested queue
+ * @cq: pointer to the specific Control queue
+ * @clean_count: (input|output) number of descriptors to clean as input, and
+ * number of descriptors actually cleaned as output
+ * @msg_status: (output) pointer to msg pointer array to be populated; needs
+ * to be allocated by caller
+ *
+ * Returns an array of message pointers associated with the cleaned
+ * descriptors. The pointers are to the original ctlq_msgs sent on the cleaned
+ * descriptors.  The status will be returned for each; any messages that failed
+ * to send will have a non-zero status. The caller is expected to free original
+ * ctlq_msgs and free or reuse the DMA buffers.
+ */
+int idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count,
+		       struct idpf_ctlq_msg *msg_status[])
+{
+	return __idpf_ctlq_clean_sq(cq, clean_count, msg_status, false);
+}
+
 /**
  * idpf_ctlq_post_rx_buffs - post buffers to descriptor ring
  * @hw: pointer to hw struct
diff --git a/drivers/common/idpf/base/idpf_controlq_api.h b/drivers/common/idpf/base/idpf_controlq_api.h
index 80be282b42..a00faac05f 100644
--- a/drivers/common/idpf/base/idpf_controlq_api.h
+++ b/drivers/common/idpf/base/idpf_controlq_api.h
@@ -191,6 +191,10 @@ int idpf_ctlq_send(struct idpf_hw *hw,
 int idpf_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg,
 		   struct idpf_ctlq_msg *q_msg);
 
+/* Reclaims all descriptors on HW write back */
+int idpf_ctlq_clean_sq_force(struct idpf_ctlq_info *cq, u16 *clean_count,
+			     struct idpf_ctlq_msg *msg_status[]);
+
 /* Reclaims send descriptors on HW write back */
 int idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count,
 		       struct idpf_ctlq_msg *msg_status[]);
-- 
2.25.1


  parent reply	other threads:[~2023-04-13  9:52 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13  9:44 [PATCH 00/18] update idpf shared code Wenjing Qiao
2023-04-13  9:44 ` [PATCH 01/18] common/idpf: support flow subscription Wenjing Qiao
2023-04-21  8:40   ` [PATCH v2 00/15] update idpf shared code Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 01/15] common/idpf: remove virtchnl related " Wenjing Qiao
2023-04-24 11:52       ` Zhang, Qi Z
2023-04-26 10:22       ` [PATCH v3 00/15] update idpf base code Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 01/15] common/idpf/base: remove virtchnl related " Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 02/15] common/idpf/base: fix ctlq message send and receive Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 03/15] common/idpf/base: fix ITR register definitions for AVF Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 04/15] common/idpf/base: remove qregion struct variables Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 05/15] common/idpf/base: move OEM capability to the last bit Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 06/15] common/idpf/base: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 07/15] common/idpf/base: add virtchnl2 error codes Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 08/15] common/idpf/base: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 09/15] common/idpf/base: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 10/15] common/idpf/base: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 11/15] common/idpf/base: allocate static buffer at initialization Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 12/15] common/idpf/base: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 13/15] common/idpf/base: add/delete queue groups commands Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 14/15] common/idpf/base: add func to clean all DESCs on controlq Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 15/15] common/idpf/base: update license and README Wenjing Qiao
2023-04-26 11:56           ` Zhang, Qi Z
2023-06-12 10:18           ` Thomas Monjalon
2023-04-26 12:40         ` [PATCH v3 00/15] update idpf base code Zhang, Qi Z
2023-04-21  8:40     ` [PATCH v2 02/15] common/idpf: fix ctlq message send and receive Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 03/15] common/idpf: fix ITR register definitions for AVF Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 04/15] common/idpf: remove qregion struct variables Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 05/15] common/idpf: move OEM capability to the last bit Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 06/15] common/idpf: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 07/15] common/idpf: add virtchnl2 error codes Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 08/15] common/idpf: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 09/15] common/idpf: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 10/15] common/idpf: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 11/15] common/idpf: allocate static buffer at initialization Wenjing Qiao
2023-04-24 12:15       ` Zhang, Qi Z
2023-04-21  8:40     ` [PATCH v2 12/15] common/idpf: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 13/15] common/idpf: add/delete queue groups commands Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 14/15] common/idpf: add func to clean all DESCs on controlq Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 15/15] common/idpf: update license and README Wenjing Qiao
2023-04-13  9:44 ` [PATCH 02/18] common/idpf: fix ctlq message send and receive Wenjing Qiao
2023-04-13  9:44 ` [PATCH 03/18] common/idpf: fix ITR register definitions for AVF Wenjing Qiao
2023-04-13  9:44 ` [PATCH 04/18] common/idpf: remove qregion struct variables Wenjing Qiao
2023-04-13  9:44 ` [PATCH 05/18] common/idpf: move OEM capability to the last bit Wenjing Qiao
2023-04-13  9:44 ` [PATCH 06/18] common/idpf: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-13  9:44 ` [PATCH 07/18] common/idpf: add virtchnl2 error codes Wenjing Qiao
2023-04-13  9:44 ` [PATCH 08/18] common/idpf: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-13  9:44 ` [PATCH 09/18] common/idpf: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-13  9:44 ` [PATCH 10/18] common/idpf: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-13  9:44 ` [PATCH 11/18] common/idpf: allocate static buffer at initialization Wenjing Qiao
2023-04-13  9:44 ` [PATCH 12/18] common/idpf: add SyncE support over VF Wenjing Qiao
2023-04-13  9:44 ` [PATCH 13/18] common/idpf: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-13  9:44 ` [PATCH 14/18] common/idpf: add GNSS support over VF Wenjing Qiao
2023-04-13  9:44 ` [PATCH 15/18] common/idpf: add/delete queue groups commands Wenjing Qiao
2023-04-13  9:45 ` Wenjing Qiao [this message]
2023-04-13  9:45 ` [PATCH 17/18] common/idpf: fix cannot understand warnings Wenjing Qiao
2023-04-13  9:45 ` [PATCH 18/18] common/idpf: update license and README Wenjing Qiao

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=20230413094502.1714755-17-wenjing.qiao@intel.com \
    --to=wenjing.qiao@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=norbertx.ciosek@intel.com \
    --cc=qi.z.zhang@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 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).