[dpdk-dev] [PATCH v2 4/7] ethdev: fix of calculating the size of flow type mask array

Helin Zhang helin.zhang at intel.com
Wed Feb 4 08:16:30 CET 2015


It wrongly calculates the size of the flow type mask array. The fix
is to align the flow type maximum index ID with the number of
element bit width, and then divide the number of element bit width.

Signed-off-by: Helin Zhang <helin.zhang at intel.com>
---
 lib/librte_ether/rte_eth_ctrl.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index e936f3a..cbd36ea 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -398,6 +398,10 @@ enum rte_fdir_mode {
 	RTE_FDIR_MODE_PERFECT,       /**< Enable FDIR perfect filter mode. */
 };
 
+#define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
+#define RTE_FLOW_MASK_ARRAY_SIZE \
+(RTE_ALIGN(RTE_ETH_FLOW_TYPE_MAX, UINT32_BIT)/UINT32_BIT)
+
 /**
  * A structure used to get the information of flow director filter.
  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
@@ -412,7 +416,7 @@ struct rte_eth_fdir_info {
 	uint32_t guarant_spc; /**< Guaranteed spaces.*/
 	uint32_t best_spc; /**< Best effort spaces.*/
 	/** Bit mask for every supported flow type. */
-	uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
+	uint32_t flow_types_mask[RTE_FLOW_MASK_ARRAY_SIZE];
 	uint32_t max_flexpayload; /**< Total flex payload in bytes. */
 	/** Flexible payload unit in bytes. Size and alignments of all flex
 	    payload segments should be multiplies of this value. */
@@ -477,7 +481,6 @@ enum rte_eth_hash_function {
 	RTE_ETH_HASH_FUNCTION_MAX,
 };
 
-#define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
 #define RTE_SYM_HASH_MASK_ARRAY_SIZE \
 	(RTE_ALIGN(RTE_ETH_FLOW_TYPE_MAX, UINT32_BIT)/UINT32_BIT)
 /**
-- 
1.9.3



More information about the dev mailing list