aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2016-04-01 19:17:35 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2016-04-21 02:07:31 -0400
commit4e160f2a59cec8f705583edfaa11ce5f3b3ef4a6 (patch)
treed189810c62fc41d6fdf752fe46af4f2664ba0451
parent3417415c3a86d6bae8bfee495ce634f4d24e16b8 (diff)
fm10k: fix documentation of fm10k_tlv_parse_attr
fm10k_tlv_parse_attr is supposed to return FM10K_NOT_IMPLEMENTED for any TLV who's attribute id lies outside the range of results. It does not do this today. In addition, the documentation does not indicate that other attributes which are not implemented for a given TLV will be silently ignored. Fix this. Clean up the logic so that we don't rely on the fact that FM10K_NOT_IMPLEMENTED is greater than zero, as this can easily cause confusion. A future extension could look into some way of reporting unknown TLVs in order to make issues more easily discoverable. We can't just return FM10K_NOT_IMPLEMENTED here because we don't want to drop the entire message if it has an unknown TLV. While here, update the copyright year. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_tlv.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c b/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c
index b999897e50d8..6b500a6378e0 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c
@@ -1,5 +1,5 @@
1/* Intel Ethernet Switch Host Interface Driver 1/* Intel Ethernet Switch Host Interface Driver
2 * Copyright(c) 2013 - 2015 Intel Corporation. 2 * Copyright(c) 2013 - 2016 Intel Corporation.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License, 5 * under the terms and conditions of the GNU General Public License,
@@ -481,7 +481,8 @@ static s32 fm10k_tlv_attr_validate(u32 *attr,
481 * up into an array of pointers stored in results. The function will 481 * up into an array of pointers stored in results. The function will
482 * return FM10K_ERR_PARAM on any input or message error, 482 * return FM10K_ERR_PARAM on any input or message error,
483 * FM10K_NOT_IMPLEMENTED for any attribute that is outside of the array 483 * FM10K_NOT_IMPLEMENTED for any attribute that is outside of the array
484 * and 0 on success. 484 * and 0 on success. Any attributes not found in tlv_attr will be silently
485 * ignored.
485 **/ 486 **/
486static s32 fm10k_tlv_attr_parse(u32 *attr, u32 **results, 487static s32 fm10k_tlv_attr_parse(u32 *attr, u32 **results,
487 const struct fm10k_tlv_attr *tlv_attr) 488 const struct fm10k_tlv_attr *tlv_attr)
@@ -518,14 +519,15 @@ static s32 fm10k_tlv_attr_parse(u32 *attr, u32 **results,
518 while (offset < len) { 519 while (offset < len) {
519 attr_id = *attr & FM10K_TLV_ID_MASK; 520 attr_id = *attr & FM10K_TLV_ID_MASK;
520 521
521 if (attr_id < FM10K_TLV_RESULTS_MAX) 522 if (attr_id >= FM10K_TLV_RESULTS_MAX)
522 err = fm10k_tlv_attr_validate(attr, tlv_attr); 523 return FM10K_NOT_IMPLEMENTED;
523 else
524 err = FM10K_NOT_IMPLEMENTED;
525 524
526 if (err < 0) 525 err = fm10k_tlv_attr_validate(attr, tlv_attr);
526 if (err == FM10K_NOT_IMPLEMENTED)
527 ; /* silently ignore non-implemented attributes */
528 else if (err)
527 return err; 529 return err;
528 if (!err) 530 else
529 results[attr_id] = attr; 531 results[attr_id] = attr;
530 532
531 /* update offset */ 533 /* update offset */