[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9cb7c957-8746-4a94-b8a3-cf3da927511c@intel.com>
Date: Mon, 15 Jul 2024 08:33:43 -0600
From: Ahmed Zaki <ahmed.zaki@...el.com>
To: Paul Menzel <pmenzel@...gen.mpg.de>, Junfeng Guo <junfeng.guo@...el.com>
CC: <intel-wired-lan@...ts.osuosl.org>, <netdev@...r.kernel.org>, "Marcin
Szycik" <marcin.szycik@...ux.intel.com>, <anthony.l.nguyen@...el.com>,
<horms@...nel.org>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v3 11/13] ice: enable FDIR
filters from raw binary patterns for VFs
On 2024-07-10 11:42 p.m., Paul Menzel wrote:
> Dear Ahmed, dear Junfeng,
>
>
> Thank you for the patch.
>
> Am 10.07.24 um 22:40 schrieb Ahmed Zaki:
>> From: Junfeng Guo <junfeng.guo@...el.com>
>>
>> Enable VFs to create FDIR filters from raw binary patterns.
>> The corresponding processes for raw flow are added in the
>> Parse / Create / Destroy stages.
>>
>> Reviewed-by: Marcin Szycik <marcin.szycik@...ux.intel.com>
>> Signed-off-by: Junfeng Guo <junfeng.guo@...el.com>
>> Co-developed-by: Ahmed Zaki <ahmed.zaki@...el.com>
>> Signed-off-by: Ahmed Zaki <ahmed.zaki@...el.com>
>> ---
>> .../net/ethernet/intel/ice/ice_flex_pipe.c | 48 +++
>> .../net/ethernet/intel/ice/ice_flex_pipe.h | 3 +
>> drivers/net/ethernet/intel/ice/ice_flow.c | 106 +++++
>> drivers/net/ethernet/intel/ice/ice_flow.h | 5 +
>> drivers/net/ethernet/intel/ice/ice_vf_lib.h | 8 +
>> .../ethernet/intel/ice/ice_virtchnl_fdir.c | 404 +++++++++++++++++-
>> 6 files changed, 566 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
>> b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
>> index a750d7e1edd8..51aa6525565c 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
>> @@ -4146,6 +4146,54 @@ ice_add_prof_id_flow(struct ice_hw *hw, enum
>> ice_block blk, u16 vsi, u64 hdl)
>> return status;
>> }
>> +/**
>> + * ice_flow_assoc_fdir_prof - add a FDIR profile for main/ctrl VSI
>
> a*n* FDIR?
>
>> + * @hw: pointer to the HW struct
>> + * @blk: HW block
>> + * @dest_vsi: dest VSI
>> + * @fdir_vsi: fdir programming VSI
>> + * @hdl: profile handle
>> + *
>> + * Update the hardware tables to enable the FDIR profile indicated by
>> @hdl for
>> + * the VSI specified by @dest_vsi. On success, the flow will be enabled.
>> + *
>> + * Return: 0 on success or negative errno on failure.
>> + */
>> +int
>> +ice_flow_assoc_fdir_prof(struct ice_hw *hw, enum ice_block blk,
>> + u16 dest_vsi, u16 fdir_vsi, u64 hdl)
>> +{
>> + int status = 0;
>> + u16 vsi_num;
>> +
>> + if (blk != ICE_BLK_FD)
>> + return -EINVAL;
>> +
>> + vsi_num = ice_get_hw_vsi_num(hw, dest_vsi);
>> + status = ice_add_prof_id_flow(hw, blk, vsi_num, hdl);
>> + if (status) {
>> + ice_debug(hw, ICE_DBG_FLOW, "HW profile add failed for main
>> VSI flow entry: %d\n",
>
> Maybe: Adding HW profile failed …? (Also below.)
>
>> + status);
>> + return status;
>> + }
>> +
>> + vsi_num = ice_get_hw_vsi_num(hw, fdir_vsi);
>> + status = ice_add_prof_id_flow(hw, blk, vsi_num, hdl);
>> + if (status) {
>> + ice_debug(hw, ICE_DBG_FLOW, "HW profile add failed for ctrl
>> VSI flow entry: %d\n",
>> + status);
>> + goto err;
>> + }
>> +
>> + return 0;
>> +
>> +err:
>> + vsi_num = ice_get_hw_vsi_num(hw, dest_vsi);
>> + ice_rem_prof_id_flow(hw, blk, vsi_num, hdl);
>> +
>> + return status;
>> +}
>> +
>> /**
>> * ice_rem_prof_from_list - remove a profile from list
>> * @hw: pointer to the HW struct
>> diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h
>> b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h
>> index 7c66652dadd6..90b9b0993122 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h
>> +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h
>> @@ -51,6 +51,9 @@ int
>> ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi,
>> u64 hdl);
>> int
>> ice_rem_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi,
>> u64 hdl);
>> +int
>> +ice_flow_assoc_fdir_prof(struct ice_hw *hw, enum ice_block blk,
>> + u16 dest_vsi, u16 fdir_vsi, u64 hdl);
>> enum ice_ddp_state ice_init_pkg(struct ice_hw *hw, u8 *buff, u32 len);
>> enum ice_ddp_state
>> ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
>> diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c
>> b/drivers/net/ethernet/intel/ice/ice_flow.c
>> index 79106503194b..99d584f46c23 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_flow.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_flow.c
>> @@ -409,6 +409,29 @@ static const u32 ice_ptypes_gtpc_tid[] = {
>> };
>> /* Packet types for GTPU */
>> +static const struct ice_ptype_attributes ice_attr_gtpu_session[] = {
>> + { ICE_MAC_IPV4_GTPU_IPV4_FRAG, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV4_PAY, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV4_UDP_PAY, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV4_TCP, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV4_ICMP, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV4_FRAG, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV4_PAY, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV4_UDP_PAY, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV4_TCP, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV4_ICMP, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV6_FRAG, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV6_PAY, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV6_UDP_PAY, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV6_TCP, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV4_GTPU_IPV6_ICMPV6, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV6_FRAG, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV6_PAY, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV6_UDP_PAY, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV6_TCP, ICE_PTYPE_ATTR_GTP_SESSION },
>> + { ICE_MAC_IPV6_GTPU_IPV6_ICMPV6, ICE_PTYPE_ATTR_GTP_SESSION },
>> +};
>> +
>> static const struct ice_ptype_attributes ice_attr_gtpu_eh[] = {
>> { ICE_MAC_IPV4_GTPU_IPV4_FRAG, ICE_PTYPE_ATTR_GTP_PDU_EH },
>> { ICE_MAC_IPV4_GTPU_IPV4_PAY, ICE_PTYPE_ATTR_GTP_PDU_EH },
>> @@ -1523,6 +1546,89 @@ ice_flow_disassoc_prof(struct ice_hw *hw, enum
>> ice_block blk,
>> return status;
>> }
>> +#define FLAG_GTP_EH_PDU_LINK BIT_ULL(13)
>> +#define FLAG_GTP_EH_PDU BIT_ULL(14)
>> +
>> +#define HI_BYTE_IN_WORD GENMASK(15, 8)
>> +#define LO_BYTE_IN_WORD GENMASK(7, 0)
>> +
>> +#define FLAG_GTPU_MSK \
>> + (FLAG_GTP_EH_PDU | FLAG_GTP_EH_PDU_LINK)
>> +#define FLAG_GTPU_UP \
>> + (FLAG_GTP_EH_PDU | FLAG_GTP_EH_PDU_LINK)
>> +#define FLAG_GTPU_DW FLAG_GTP_EH_PDU
>> +/**
>> + * ice_flow_set_parser_prof - Set flow profile based on the parsed
>> profile info
>> + * @hw: pointer to the HW struct
>> + * @dest_vsi: dest VSI
>> + * @fdir_vsi: fdir programming VSI
>> + * @prof: stores parsed profile info from raw flow
>> + * @blk: classification blk
>> + *
>> + * Return: 0 on success or negative errno on failure.
>> + */
>> +int
>> +ice_flow_set_parser_prof(struct ice_hw *hw, u16 dest_vsi, u16 fdir_vsi,
>> + struct ice_parser_profile *prof, enum ice_block blk)
>> +{
>> + u64 id = find_first_bit(prof->ptypes, ICE_FLOW_PTYPE_MAX);
>> + struct ice_flow_prof_params *params __free(kfree);
>> + u8 fv_words = hw->blk[blk].es.fvw;
>> + int status;
>> + int i, idx;
>
> Use size_t as it’s used in arrays?
>
>> +
>> + params = kzalloc(sizeof(*params), GFP_KERNEL);
>> + if (!params)
>> + return -ENOMEM;
>> +
>> + for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
>> + params->es[i].prot_id = ICE_PROT_INVALID;
>> + params->es[i].off = ICE_FV_OFFSET_INVAL;
>> + }
>> +
>> + for (i = 0; i < prof->fv_num; i++) {
>> + if (hw->blk[blk].es.reverse)
>> + idx = fv_words - i - 1;
>> + else
>> + idx = i;
>
> Use ternery operator?
(hw->blk[blk].es.reverse) ? idx = fv_words - i - 1 : idx = i;
better readability with if/else IMO.
>> + params->es[idx].prot_id = prof->fv[i].proto_id;
>> + params->es[idx].off = prof->fv[i].offset;
>> + params->mask[idx] = (((prof->fv[i].msk) << BITS_PER_BYTE) &
>> + HI_BYTE_IN_WORD) |
>> + (((prof->fv[i].msk) >> BITS_PER_BYTE) &
>> + LO_BYTE_IN_WORD);
>> + }
>> +
>> + switch (prof->flags) {
>> + case FLAG_GTPU_DW:
>> + params->attr = ice_attr_gtpu_down;
>> + params->attr_cnt = ARRAY_SIZE(ice_attr_gtpu_down);
>> + break;
>> + case FLAG_GTPU_UP:
>> + params->attr = ice_attr_gtpu_up;
>> + params->attr_cnt = ARRAY_SIZE(ice_attr_gtpu_up);
<..>
>> + vsi_num = ice_get_hw_vsi_num(hw, ctrl_vsi->idx);
>> + ice_rem_prof_id_flow(hw, blk, vsi_num, id);
>> +
>> + vsi_num = ice_get_hw_vsi_num(hw, vf_vsi->idx);
>> + ice_rem_prof_id_flow(hw, blk, vsi_num, id);
>> + }
>> + }
>> +
>> + conf->parser_ena = false;
>> + return 0;
>> +}
>
>
> Kind regards,
>
> Paul
>
All other comments will be fixed in the next version.
Thanks for reviewing the code.
Ahmed
Powered by blists - more mailing lists