[v2,1/2] net/ice: refactor FDIR set conf function
Checks
Commit Message
The original set conf function in FDIR was very long. Refactor to
increase readability to make it clearer and allow for more convenient
further changes.
No functional change here.
Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
---
drivers/net/ice/ice_fdir_filter.c | 54 ++++++++++++++++++-------------
1 file changed, 31 insertions(+), 23 deletions(-)
Comments
On 9/14/2020 4:05 AM, Zhirun Yan wrote:
> The original set conf function in FDIR was very long. Refactor to
> increase readability to make it clearer and allow for more convenient
> further changes.
>
> No functional change here.
>
> Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
> ---
> drivers/net/ice/ice_fdir_filter.c | 54 ++++++++++++++++++-------------
> 1 file changed, 31 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
> index 88c9bb03d..593dfd0e2 100644
> --- a/drivers/net/ice/ice_fdir_filter.c
> +++ b/drivers/net/ice/ice_fdir_filter.c
> @@ -964,30 +964,10 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
> }
> }
>
> -static int
> -ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
> - uint64_t input_set, enum ice_fdir_tunnel_type ttype)
> +static void
> +ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg,
> + enum ice_fdir_tunnel_type ttype)
> {
Hi Zhirun,
'ttype' variable is not used in this function at all, what do you think
removing it?
> -----Original Message-----
> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Monday, September 14, 2020 6:55 PM
> To: Yan, Zhirun <zhirun.yan@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> dev@dpdk.org
> Cc: Cao, Yahui <yahui.cao@intel.com>; Wang, Xiao W
> <xiao.w.wang@intel.com>; Su, Simei <simei.su@intel.com>; Guo, Junfeng
> <junfeng.guo@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2 1/2] net/ice: refactor FDIR set conf
> function
>
> On 9/14/2020 4:05 AM, Zhirun Yan wrote:
> > The original set conf function in FDIR was very long. Refactor to
> > increase readability to make it clearer and allow for more convenient
> > further changes.
> >
> > No functional change here.
> >
> > Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
> > ---
> > drivers/net/ice/ice_fdir_filter.c | 54
> > ++++++++++++++++++-------------
> > 1 file changed, 31 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/net/ice/ice_fdir_filter.c
> > b/drivers/net/ice/ice_fdir_filter.c
> > index 88c9bb03d..593dfd0e2 100644
> > --- a/drivers/net/ice/ice_fdir_filter.c
> > +++ b/drivers/net/ice/ice_fdir_filter.c
> > @@ -964,30 +964,10 @@ ice_fdir_input_set_parse(uint64_t inset, enum
> ice_flow_field *field)
> > }
> > }
> >
> > -static int
> > -ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
> > - uint64_t input_set, enum ice_fdir_tunnel_type ttype)
> > +static void
> > +ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct
> ice_flow_seg_info *seg,
> > + enum ice_fdir_tunnel_type ttype)
> > {
>
> Hi Zhirun,
>
> 'ttype' variable is not used in this function at all, what do you think removing
> it?
Hi Ferruh,
Yes. I will fix it in V3. Thanks.
@@ -964,30 +964,10 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
}
}
-static int
-ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
- uint64_t input_set, enum ice_fdir_tunnel_type ttype)
+static void
+ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg,
+ enum ice_fdir_tunnel_type ttype)
{
- struct ice_flow_seg_info *seg;
- struct ice_flow_seg_info *seg_tun = NULL;
- enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX];
- bool is_tunnel;
- int i, ret;
-
- if (!input_set)
- return -EINVAL;
-
- seg = (struct ice_flow_seg_info *)
- ice_malloc(hw, sizeof(*seg));
- if (!seg) {
- PMD_DRV_LOG(ERR, "No memory can be allocated");
- return -ENOMEM;
- }
-
- for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++)
- field[i] = ICE_FLOW_FIELD_IDX_MAX;
- ice_fdir_input_set_parse(input_set, field);
-
switch (flow) {
case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
@@ -1063,6 +1043,34 @@ ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
PMD_DRV_LOG(ERR, "not supported filter type.");
break;
}
+}
+
+static int
+ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
+ uint64_t input_set, enum ice_fdir_tunnel_type ttype)
+{
+ struct ice_flow_seg_info *seg;
+ struct ice_flow_seg_info *seg_tun = NULL;
+ enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX];
+ bool is_tunnel;
+ int i, ret;
+
+ if (!input_set)
+ return -EINVAL;
+
+ seg = (struct ice_flow_seg_info *)
+ ice_malloc(hw, sizeof(*seg));
+ if (!seg) {
+ PMD_DRV_LOG(ERR, "No memory can be allocated");
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++)
+ field[i] = ICE_FLOW_FIELD_IDX_MAX;
+
+ ice_fdir_input_set_parse(input_set, field);
+
+ ice_fdir_input_set_hdrs(flow, seg, ttype);
for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) {
ice_flow_set_fld(seg, field[i],