All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qi Zhang <qi.z.zhang@intel.com>
To: jing.d.chen@intel.com
Cc: helin.zhang@intel.com, dev@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>
Subject: [PATCH v2 05/18] net/fm10k/base: clean up the logic
Date: Wed,  8 Mar 2017 01:18:53 -0500	[thread overview]
Message-ID: <20170308061906.950-6-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20170308061906.950-1-qi.z.zhang@intel.com>

Clean up the logic in fm10k_tlv_attr_parse, we
should not reply on that FM10K_NOT_IMPLEMENTED is
greater than zero, as this can easily cause confusion.
The patch also correct a minor document error.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/fm10k/base/fm10k_tlv.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/fm10k/base/fm10k_tlv.c b/drivers/net/fm10k/base/fm10k_tlv.c
index e6150c1..0328ede 100644
--- a/drivers/net/fm10k/base/fm10k_tlv.c
+++ b/drivers/net/fm10k/base/fm10k_tlv.c
@@ -520,7 +520,8 @@ STATIC s32 fm10k_tlv_attr_validate(u32 *attr,
  *  up into an array of pointers stored in results.  The function will
  *  return FM10K_ERR_PARAM on any input or message error,
  *  FM10K_NOT_IMPLEMENTED for any attribute that is outside of the array
- *  and 0 on success.
+ *  and 0 on success. Any attributes not found in tlv_attr will be silently
+ *  ignored.
  **/
 static s32 fm10k_tlv_attr_parse(u32 *attr, u32 **results,
 				const struct fm10k_tlv_attr *tlv_attr)
@@ -559,14 +560,15 @@ static s32 fm10k_tlv_attr_parse(u32 *attr, u32 **results,
 	while (offset < len) {
 		attr_id = *attr & FM10K_TLV_ID_MASK;
 
-		if (attr_id < FM10K_TLV_RESULTS_MAX)
-			err = fm10k_tlv_attr_validate(attr, tlv_attr);
-		else
-			err = FM10K_NOT_IMPLEMENTED;
+		if (attr_id >= FM10K_TLV_RESULTS_MAX)
+			return FM10K_NOT_IMPLEMENTED;
 
-		if (err < 0)
+		err = fm10k_tlv_attr_validate(attr, tlv_attr);
+		if (err == FM10K_NOT_IMPLEMENTED)
+			; /* silently ignore non-implemented attributes */
+		else if (err)
 			return err;
-		if (!err)
+		else
 			results[attr_id] = attr;
 
 		/* update offset */
-- 
2.9.3

  parent reply	other threads:[~2017-03-08  5:28 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03  3:17 [PATCH 00/17] net/fm10k: update base code Qi Zhang
2017-03-03  3:17 ` [PATCH 01/17] net/fm10k/base: add a flag to indicate VF trust mode Qi Zhang
2017-03-03  3:17 ` [PATCH 02/17] net/fm10k/base: reset multicaset mode when deleting lport Qi Zhang
2017-03-05 11:41   ` Ferruh Yigit
2017-03-03  3:17 ` [PATCH 03/17] net/fm10k/base: expose macros needed by DPDK Qi Zhang
2017-03-05 11:41   ` Ferruh Yigit
2017-03-03  3:17 ` [PATCH 04/17] net/fm10k/base: add error code Qi Zhang
2017-03-03  3:17 ` [PATCH 05/17] net/fm10k/base: clean up the logic Qi Zhang
2017-03-03  3:17 ` [PATCH 06/17] net/fm10k/base: add new item to lport msg attr Qi Zhang
2017-03-03  3:17 ` [PATCH 07/17] net/fm10k/base: use 8 bit notation instead of 10bit notation Qi Zhang
2017-03-05 11:42   ` Ferruh Yigit
2017-03-03  3:17 ` [PATCH 08/17] net/fm10k/base: use different name for override bit Qi Zhang
2017-03-03  3:17 ` [PATCH 09/17] net/fm10k/base: update comment regarding reserved bits check Qi Zhang
2017-03-03  3:17 ` [PATCH 10/17] net/fm10k/base: improve VF's multi-bit VLAN update requests Qi Zhang
2017-03-05 11:42   ` Ferruh Yigit
2017-03-03  3:17 ` [PATCH 11/17] net/fm10k/base: enable lport map request Qi Zhang
2017-03-03  3:17 ` [PATCH 12/17] net/fm10k/base: add macros for global interrupt Qi Zhang
2017-03-03  3:17 ` [PATCH 13/17] net/fm10k/base: don't stop reset Qi Zhang
2017-03-03  3:17 ` [PATCH 14/17] net/fm10k/base: add macro for geneve tunnel offload Qi Zhang
2017-03-03  3:17 ` [PATCH 15/17] net/fm10k/base: improve re-map queues handle Qi Zhang
2017-03-03  3:17 ` [PATCH 16/17] net/fm10k/base: replace macros Qi Zhang
2017-03-03  3:17 ` [PATCH 17/17] net/fm10k/base: equest reset when mbx->state changes Qi Zhang
2017-03-05 11:42   ` Ferruh Yigit
2017-03-05 11:41 ` [PATCH 00/17] net/fm10k: update base code Ferruh Yigit
2017-03-08  6:18 ` [PATCH v2 00/18] " Qi Zhang
2017-03-08  6:18   ` [PATCH v2 01/18] net/fm10k/base: add a flag to indicate VF trust mode Qi Zhang
2017-03-08  6:18   ` [PATCH v2 02/18] net/fm10k/base: reset multicast mode when deleting lport Qi Zhang
2017-03-08  6:18   ` [PATCH v2 03/18] net/fm10k/base: expose macros needed by DPDK Qi Zhang
2017-03-08  6:18   ` [PATCH v2 04/18] net/fm10k/base: add error code Qi Zhang
2017-03-08  6:18   ` Qi Zhang [this message]
2017-03-08  6:18   ` [PATCH v2 06/18] net/fm10k/base: add new item to lport msg attr Qi Zhang
2017-03-08  6:18   ` [PATCH v2 07/18] net/fm10k/base: update comment Qi Zhang
2017-03-08  6:18   ` [PATCH v2 08/18] net/fm10k/base: use different name for override bit Qi Zhang
2017-03-08  6:18   ` [PATCH v2 09/18] net/fm10k/base: update comment regarding reserved bits check Qi Zhang
2017-03-08  6:18   ` [PATCH v2 10/18] net/fm10k/base: improve VF's multi-bit VLAN update requests Qi Zhang
2017-03-08  6:18   ` [PATCH v2 11/18] net/fm10k/base: enable lport map request Qi Zhang
2017-03-08  6:19   ` [PATCH v2 12/18] net/fm10k/base: add macros for global interrupt Qi Zhang
2017-03-08  6:19   ` [PATCH v2 13/18] net/fm10k/base: don't stop reset Qi Zhang
2017-03-08  6:19   ` [PATCH v2 14/18] net/fm10k/base: add macro for geneve tunnel offload Qi Zhang
2017-03-08  6:19   ` [PATCH v2 15/18] net/fm10k/base: improve re-map queues handle Qi Zhang
2017-03-08  6:19   ` [PATCH v2 16/18] net/fm10k/base: replace macros Qi Zhang
2017-03-08  6:19   ` [PATCH v2 17/18] net/fm10k/base: request reset when mbx->state changes Qi Zhang
2017-03-08  6:19   ` [PATCH v2 18/18] net/fm10k/base: add base driver information Qi Zhang
2017-03-09 11:13   ` [PATCH v2 00/18] net/fm10k: update base code Ferruh Yigit
2017-03-10  3:11     ` Zhang, Qi Z

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=20170308061906.950-6-qi.z.zhang@intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=dev@dpdk.org \
    --cc=helin.zhang@intel.com \
    --cc=jing.d.chen@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.