Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iavf: change the flex-byte support number to macro definition

The maximum number (2) of flex-byte support is derived from ethtool
use-def data size (8 byte).

Change the magic number 2 to macro definition, and add the comment to
track the design thinking, so the code is clear and easily maintained.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>

authored by

Haiyue Wang and committed by
Tony Nguyen
f995f95a 1a0e880b

+8 -3
+1 -1
drivers/net/ethernet/intel/iavf/iavf_ethtool.c
··· 939 939 if (!(fsp->flow_type & FLOW_EXT)) 940 940 return 0; 941 941 942 - for (i = 0; i < 2; i++) { 942 + for (i = 0; i < IAVF_FLEX_WORD_NUM; i++) { 943 943 #define IAVF_USERDEF_FLEX_WORD_M GENMASK(15, 0) 944 944 #define IAVF_USERDEF_FLEX_OFFS_S 16 945 945 #define IAVF_USERDEF_FLEX_OFFS_M GENMASK(31, IAVF_USERDEF_FLEX_OFFS_S)
+7 -2
drivers/net/ethernet/intel/iavf/iavf_fdir.h
··· 35 35 IAVF_FDIR_FLOW_PTYPE_MAX, 36 36 }; 37 37 38 + /* Must not exceed the array element number of '__be32 data[2]' in the ethtool 39 + * 'struct ethtool_rx_flow_spec.m_ext.data[2]' to express the flex-byte (word). 40 + */ 41 + #define IAVF_FLEX_WORD_NUM 2 42 + 38 43 struct iavf_flex_word { 39 44 u16 offset; 40 45 u16 word; ··· 76 71 }; 77 72 78 73 struct iavf_fdir_extra { 79 - u32 usr_def[2]; 74 + u32 usr_def[IAVF_FLEX_WORD_NUM]; 80 75 }; 81 76 82 77 /* bookkeeping of Flow Director filters */ ··· 100 95 /* flex byte filter data */ 101 96 u8 ip_ver; /* used to adjust the flex offset, 4 : IPv4, 6 : IPv6 */ 102 97 u8 flex_cnt; 103 - struct iavf_flex_word flex_words[2]; 98 + struct iavf_flex_word flex_words[IAVF_FLEX_WORD_NUM]; 104 99 105 100 u32 flow_id; 106 101