[PATCH 4.4 5/9] net/ncsi: Allow to extend NCSI request properties

Gavin Shan gwshan at linux.vnet.ibm.com
Fri Oct 21 11:47:42 AEDT 2016


There is only one NCSI request property for now: the response for
the sent command need drive the workqueue or not. So we had one
field (@driven) for the purpose. We lost the flexibility to extend
NCSI request properties.

This replaces @driven with @nr_flags and @nca_req_flags in NCSI
request and NCSI command argument struct. Each bit of the newly
introduced field can be used for one property. No functional
changes introduced.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
Reviewed-by: Joel Stanley <joel at jms.id.au>
---
 net/ncsi/internal.h    |  6 +++++-
 net/ncsi/ncsi-cmd.c    |  2 +-
 net/ncsi/ncsi-manage.c | 12 ++++++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index 212d77b..18a477b 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -41,6 +41,8 @@ struct ncsi_package {
 struct ncsi_req {
 	unsigned char		nr_id;
 	bool			nr_used;
+	unsigned int		nr_flags;
+#define NCSI_REQ_FLAG_EVENT_DRIVEN	1
 	struct ncsi_dev_priv	*nr_ndp;
 	struct sk_buff		*nr_cmd;
 	struct sk_buff		*nr_rsp;
@@ -103,6 +105,7 @@ struct ncsi_cmd_arg {
 	unsigned char		nca_channel;
 	unsigned short		nca_payload;
 	unsigned int		nca_portid;
+	unsigned int		nca_req_flags;
 	union {
 		unsigned char	nca_bytes[16];
 		unsigned short	nca_words[8];
@@ -140,7 +143,8 @@ void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
 				   unsigned char id,
 				   struct ncsi_package **np,
 				   struct ncsi_channel **nc);
-struct ncsi_req *ncsi_alloc_req(struct ncsi_dev_priv *ndp);
+struct ncsi_req *ncsi_alloc_req(struct ncsi_dev_priv *ndp,
+				unsigned int req_flags);
 void ncsi_free_req(struct ncsi_req *nr);
 struct ncsi_dev *ncsi_find_dev(struct net_device *dev);
 int ncsi_config_dev(struct ncsi_dev *nd);
diff --git a/net/ncsi/ncsi-cmd.c b/net/ncsi/ncsi-cmd.c
index feedb66..9b0ddb7 100644
--- a/net/ncsi/ncsi-cmd.c
+++ b/net/ncsi/ncsi-cmd.c
@@ -279,7 +279,7 @@ static struct ncsi_req *ncsi_alloc_cmd_req(struct ncsi_cmd_arg *nca)
 	struct sk_buff *skb;
 	struct ncsi_req *nr;
 
-	nr = ncsi_alloc_req(ndp);
+	nr = ncsi_alloc_req(ndp, nca->nca_req_flags);
 	if (!nr)
 		return NULL;
 
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 44a740f..e3fe191 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -297,7 +297,8 @@ void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
  * same. Otherwise, the bogus response might be replied. So the
  * available IDs are allocated in round-robin fasion.
  */
-struct ncsi_req *ncsi_alloc_req(struct ncsi_dev_priv *ndp)
+struct ncsi_req *ncsi_alloc_req(struct ncsi_dev_priv *ndp,
+				unsigned int req_flags)
 {
 	struct ncsi_req *nr = NULL;
 	int idx, limit = 256;
@@ -312,6 +313,7 @@ struct ncsi_req *ncsi_alloc_req(struct ncsi_dev_priv *ndp)
 
 		nr = &ndp->ndp_reqs[idx];
 		nr->nr_used = true;
+		nr->nr_flags = req_flags;
 		atomic_set(&ndp->ndp_last_req_idx, idx + 1);
 		goto found;
 	}
@@ -324,6 +326,7 @@ struct ncsi_req *ncsi_alloc_req(struct ncsi_dev_priv *ndp)
 
 		nr = &ndp->ndp_reqs[idx];
 		nr->nr_used = true;
+		nr->nr_flags = req_flags;
 		atomic_set(&ndp->ndp_last_req_idx, idx + 1);
 		goto found;
 	}
@@ -338,6 +341,7 @@ void ncsi_free_req(struct ncsi_req *nr)
 	struct ncsi_dev_priv *ndp = nr->nr_ndp;
 	struct sk_buff *cmd, *rsp;
 	unsigned long flags;
+	bool driven;
 
 	if (nr->nr_timer_enabled) {
 		nr->nr_timer_enabled = false;
@@ -350,9 +354,10 @@ void ncsi_free_req(struct ncsi_req *nr)
 	nr->nr_cmd = NULL;
 	nr->nr_rsp = NULL;
 	nr->nr_used = false;
+	driven = !!(nr->nr_flags & NCSI_REQ_FLAG_EVENT_DRIVEN);
 	spin_unlock_irqrestore(&ndp->ndp_req_lock, flags);
 
-	if (cmd && atomic_dec_return(&ndp->ndp_pending_reqs) == 0)
+	if (driven && cmd && atomic_dec_return(&ndp->ndp_pending_reqs) == 0)
 		schedule_work(&ndp->ndp_work);
 	/* Release command and response */
 	consume_skb(cmd);
@@ -382,6 +387,7 @@ static void ncsi_dev_config(struct ncsi_dev_priv *ndp)
 	int ret;
 
 	nca.nca_ndp = ndp;
+	nca.nca_req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN;
 
 	/* When we're reconfiguring the active channel, the active package
 	 * should be selected and the old setting on the active channel
@@ -523,6 +529,7 @@ static void ncsi_dev_probe(struct ncsi_dev_priv *ndp)
 	int ret;
 
 	nca.nca_ndp = ndp;
+	nca.nca_req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN;
 	switch (nd->nd_state) {
 	case ncsi_dev_state_probe:
 		nd->nd_state = ncsi_dev_state_probe_deselect;
@@ -694,6 +701,7 @@ static void ncsi_dev_suspend(struct ncsi_dev_priv *ndp)
 	int ret;
 
 	nca.nca_ndp = ndp;
+	nca.nca_req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN;
 	switch (nd->nd_state) {
 	case ncsi_dev_state_suspend:
 		/* If there're no active channel, we're done */
-- 
2.1.0



More information about the openbmc mailing list