summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaiyue Wang <haiyue.wang@intel.com>2021-03-31 05:08:35 +0300
committerTony Nguyen <anthony.l.nguyen@intel.com>2021-04-23 19:03:56 +0300
commitf995f95af626cb1867cbfc702d011a50c4ff9538 (patch)
treedb0a50bc3a8118660b3be1912d777f15e80045ab
parent1a0e880b028f97478dc689e2900b312741d0d772 (diff)
downloadlinux-f995f95af626cb1867cbfc702d011a50c4ff9538.tar.xz
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>
-rw-r--r--drivers/net/ethernet/intel/iavf/iavf_ethtool.c2
-rw-r--r--drivers/net/ethernet/intel/iavf/iavf_fdir.h9
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index 3d904bc6ee76..af43fbd8cb75 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -939,7 +939,7 @@ iavf_parse_rx_flow_user_data(struct ethtool_rx_flow_spec *fsp,
if (!(fsp->flow_type & FLOW_EXT))
return 0;
- for (i = 0; i < 2; i++) {
+ for (i = 0; i < IAVF_FLEX_WORD_NUM; i++) {
#define IAVF_USERDEF_FLEX_WORD_M GENMASK(15, 0)
#define IAVF_USERDEF_FLEX_OFFS_S 16
#define IAVF_USERDEF_FLEX_OFFS_M GENMASK(31, IAVF_USERDEF_FLEX_OFFS_S)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_fdir.h b/drivers/net/ethernet/intel/iavf/iavf_fdir.h
index 2439c970b657..33c55c366315 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_fdir.h
+++ b/drivers/net/ethernet/intel/iavf/iavf_fdir.h
@@ -35,6 +35,11 @@ enum iavf_fdir_flow_type {
IAVF_FDIR_FLOW_PTYPE_MAX,
};
+/* Must not exceed the array element number of '__be32 data[2]' in the ethtool
+ * 'struct ethtool_rx_flow_spec.m_ext.data[2]' to express the flex-byte (word).
+ */
+#define IAVF_FLEX_WORD_NUM 2
+
struct iavf_flex_word {
u16 offset;
u16 word;
@@ -71,7 +76,7 @@ struct iavf_fdir_ip {
};
struct iavf_fdir_extra {
- u32 usr_def[2];
+ u32 usr_def[IAVF_FLEX_WORD_NUM];
};
/* bookkeeping of Flow Director filters */
@@ -95,7 +100,7 @@ struct iavf_fdir_fltr {
/* flex byte filter data */
u8 ip_ver; /* used to adjust the flex offset, 4 : IPv4, 6 : IPv6 */
u8 flex_cnt;
- struct iavf_flex_word flex_words[2];
+ struct iavf_flex_word flex_words[IAVF_FLEX_WORD_NUM];
u32 flow_id;