DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rasesh Mody <rasesh.mody@cavium.com>
To: dev@dpdk.org, ferruh.yigit@intel.com
Cc: Rasesh Mody <rasesh.mody@cavium.com>, Dept-EngDPDKDev@cavium.com
Subject: [dpdk-dev] [PATCH 34/53] net/qede/base: use function pointers for spq async callback
Date: Mon, 18 Sep 2017 18:51:24 -0700	[thread overview]
Message-ID: <1505785903-1741-5-git-send-email-rasesh.mody@cavium.com> (raw)
In-Reply-To: <1505785903-1741-1-git-send-email-rasesh.mody@cavium.com>

Change spq async callback to use function pointers instead of switch case
on protocolid.

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
---
 drivers/net/qede/base/ecore_spq.c   |   38 +++++++++++++++++++++++++++++------
 drivers/net/qede/base/ecore_spq.h   |   17 ++++++++++++++++
 drivers/net/qede/base/ecore_sriov.c |   20 ++++++++++++++----
 drivers/net/qede/base/ecore_sriov.h |   13 ------------
 4 files changed, 65 insertions(+), 23 deletions(-)

diff --git a/drivers/net/qede/base/ecore_spq.c b/drivers/net/qede/base/ecore_spq.c
index ee0f06c..a346166 100644
--- a/drivers/net/qede/base/ecore_spq.c
+++ b/drivers/net/qede/base/ecore_spq.c
@@ -271,12 +271,16 @@ static enum _ecore_status_t ecore_spq_hw_post(struct ecore_hwfn *p_hwfn,
 ecore_async_event_completion(struct ecore_hwfn *p_hwfn,
 			     struct event_ring_entry *p_eqe)
 {
-	switch (p_eqe->protocol_id) {
-	case PROTOCOLID_COMMON:
-		return ecore_sriov_eqe_event(p_hwfn,
-					     p_eqe->opcode,
-					     p_eqe->echo, &p_eqe->data);
-	default:
+	ecore_spq_async_comp_cb cb;
+
+	if (!p_hwfn->p_spq || (p_eqe->protocol_id >= MAX_PROTOCOL_TYPE))
+		return ECORE_INVAL;
+
+	cb = p_hwfn->p_spq->async_comp_cb[p_eqe->protocol_id];
+	if (cb) {
+		return cb(p_hwfn, p_eqe->opcode, p_eqe->echo,
+			  &p_eqe->data, p_eqe->fw_return_code);
+	} else {
 		DP_NOTICE(p_hwfn,
 			  true, "Unknown Async completion for protocol: %d\n",
 			  p_eqe->protocol_id);
@@ -284,6 +288,28 @@ static enum _ecore_status_t ecore_spq_hw_post(struct ecore_hwfn *p_hwfn,
 	}
 }
 
+enum _ecore_status_t
+ecore_spq_register_async_cb(struct ecore_hwfn *p_hwfn,
+			    enum protocol_type protocol_id,
+			    ecore_spq_async_comp_cb cb)
+{
+	if (!p_hwfn->p_spq || (protocol_id >= MAX_PROTOCOL_TYPE))
+		return ECORE_INVAL;
+
+	p_hwfn->p_spq->async_comp_cb[protocol_id] = cb;
+	return ECORE_SUCCESS;
+}
+
+void
+ecore_spq_unregister_async_cb(struct ecore_hwfn *p_hwfn,
+			      enum protocol_type protocol_id)
+{
+	if (!p_hwfn->p_spq || (protocol_id >= MAX_PROTOCOL_TYPE))
+		return;
+
+	p_hwfn->p_spq->async_comp_cb[protocol_id] = OSAL_NULL;
+}
+
 /***************************************************************************
  * EQ API
  ***************************************************************************/
diff --git a/drivers/net/qede/base/ecore_spq.h b/drivers/net/qede/base/ecore_spq.h
index 31d8a3e..526cff0 100644
--- a/drivers/net/qede/base/ecore_spq.h
+++ b/drivers/net/qede/base/ecore_spq.h
@@ -86,6 +86,22 @@ struct ecore_consq {
 	struct ecore_chain	chain;
 };
 
+typedef enum _ecore_status_t
+(*ecore_spq_async_comp_cb)(struct ecore_hwfn *p_hwfn,
+			   u8 opcode,
+			   u16 echo,
+			   union event_ring_data *data,
+			   u8 fw_return_code);
+
+enum _ecore_status_t
+ecore_spq_register_async_cb(struct ecore_hwfn *p_hwfn,
+			    enum protocol_type protocol_id,
+			    ecore_spq_async_comp_cb cb);
+
+void
+ecore_spq_unregister_async_cb(struct ecore_hwfn *p_hwfn,
+			      enum protocol_type protocol_id);
+
 struct ecore_spq {
 	osal_spinlock_t			lock;
 
@@ -127,6 +143,7 @@ struct ecore_spq {
 
 	u32				db_addr_offset;
 	struct core_db_data		db_data;
+	ecore_spq_async_comp_cb		async_comp_cb[MAX_PROTOCOL_TYPE];
 };
 
 struct ecore_port;
diff --git a/drivers/net/qede/base/ecore_sriov.c b/drivers/net/qede/base/ecore_sriov.c
index 53d6b36..2b8e24c 100644
--- a/drivers/net/qede/base/ecore_sriov.c
+++ b/drivers/net/qede/base/ecore_sriov.c
@@ -27,6 +27,12 @@
 #include "ecore_init_fw_funcs.h"
 #include "ecore_sp_commands.h"
 
+static enum _ecore_status_t ecore_sriov_eqe_event(struct ecore_hwfn *p_hwfn,
+						  u8 opcode,
+						  __le16 echo,
+						  union event_ring_data *data,
+						  u8 fw_return_code);
+
 const char *ecore_channel_tlvs_string[] = {
 	"CHANNEL_TLV_NONE",	/* ends tlv sequence */
 	"CHANNEL_TLV_ACQUIRE",
@@ -591,6 +597,9 @@ enum _ecore_status_t ecore_iov_alloc(struct ecore_hwfn *p_hwfn)
 
 	p_hwfn->pf_iov_info = p_sriov;
 
+	ecore_spq_register_async_cb(p_hwfn, PROTOCOLID_COMMON,
+				    ecore_sriov_eqe_event);
+
 	return ecore_iov_allocate_vfdb(p_hwfn);
 }
 
@@ -604,6 +613,8 @@ void ecore_iov_setup(struct ecore_hwfn *p_hwfn)
 
 void ecore_iov_free(struct ecore_hwfn *p_hwfn)
 {
+	ecore_spq_unregister_async_cb(p_hwfn, PROTOCOLID_COMMON);
+
 	if (IS_PF_SRIOV_ALLOC(p_hwfn)) {
 		ecore_iov_free_vfdb(p_hwfn);
 		OSAL_FREE(p_hwfn->p_dev, p_hwfn->pf_iov_info);
@@ -4195,10 +4206,11 @@ static void ecore_sriov_vfpf_malicious(struct ecore_hwfn *p_hwfn,
 	OSAL_PF_VF_MALICIOUS(p_hwfn, p_vf->relative_vf_id);
 }
 
-enum _ecore_status_t ecore_sriov_eqe_event(struct ecore_hwfn *p_hwfn,
-					   u8 opcode,
-					   __le16 echo,
-					   union event_ring_data *data)
+static enum _ecore_status_t ecore_sriov_eqe_event(struct ecore_hwfn *p_hwfn,
+						  u8 opcode,
+						  __le16 echo,
+						  union event_ring_data *data,
+						  u8 OSAL_UNUSED fw_return_code)
 {
 	switch (opcode) {
 	case COMMON_EVENT_VF_PF_CHANNEL:
diff --git a/drivers/net/qede/base/ecore_sriov.h b/drivers/net/qede/base/ecore_sriov.h
index effeb69..31bdee1 100644
--- a/drivers/net/qede/base/ecore_sriov.h
+++ b/drivers/net/qede/base/ecore_sriov.h
@@ -254,19 +254,6 @@ void ecore_dp_tlv_list(struct ecore_hwfn *p_hwfn,
 void ecore_iov_free_hw_info(struct ecore_dev *p_dev);
 
 /**
- * @brief ecore_sriov_eqe_event - handle async sriov event arrived on eqe.
- *
- * @param p_hwfn
- * @param opcode
- * @param echo
- * @param data
- */
-enum _ecore_status_t ecore_sriov_eqe_event(struct ecore_hwfn	 *p_hwfn,
-					   u8			 opcode,
-					   __le16		 echo,
-					   union event_ring_data *data);
-
-/**
  * @brief Mark structs of vfs that have been FLR-ed.
  *
  * @param p_hwfn
-- 
1.7.10.3

  parent reply	other threads:[~2017-09-19  1:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19  1:51 [dpdk-dev] [PATCH 30/53] net/qede/base: read per queue coalescing from HW Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 31/53] net/qede/base: refactor device's number of ports logic Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 32/53] net/qede/base: use proper units for rate limiting Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 33/53] net/qede/base: use available macro Rasesh Mody
2017-09-19  1:51 ` Rasesh Mody [this message]
2017-09-19  1:51 ` [dpdk-dev] [PATCH 35/53] net/qede/base: fix API return types Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 36/53] net/qede/base: semantic changes Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 37/53] net/qede/base: handle the error condition properly Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 38/53] net/qede/base: add new macro for CMT mode Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 39/53] net/qede/base: change verbosity Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 40/53] net/qede/base: fix number of app table entries Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 41/53] net/qede/base: update firmware to 8.30.12.0 Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 42/53] net/qede/base: add UFP support Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 43/53] net/qede/base: add support for mapped doorbell Bars for VFs Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 44/53] net/qede/base: add support for driver attribute repository Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 45/53] net/qede/base: move define to header file Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 46/53] net/qede/base: dcbx dscp related extensions Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 47/53] net/qede/base: add feature support for per-PF virtual link Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 48/53] net/qede/base: catch an init command write failure Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 49/53] net/qede/base: retain dcbx config till actually applied Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 50/53] net/qede/base: disable aRFS for NPAR and 100G Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 51/53] net/qede/base: add support for WoL writes Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 52/53] net/qede/base: remove unused input parameter Rasesh Mody
2017-09-19  1:51 ` [dpdk-dev] [PATCH 53/53] net/qede/base: update PMD version to 2.6.0.1 Rasesh Mody

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=1505785903-1741-5-git-send-email-rasesh.mody@cavium.com \
    --to=rasesh.mody@cavium.com \
    --cc=Dept-EngDPDKDev@cavium.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@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).