// SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2019-2021, Intel Corporation. */ #include "ice.h" #include "ice_tc_lib.h" #include "ice_fltr.h" #include "ice_lib.h" #include "ice_protocol_type.h" #define ICE_TC_METADATA_LKUP_IDX … /** * ice_tc_count_lkups - determine lookup count for switch filter * @flags: TC-flower flags * @headers: Pointer to TC flower filter header structure * @fltr: Pointer to outer TC filter structure * * Determine lookup count based on TC flower input for switch filter. */ static int ice_tc_count_lkups(u32 flags, struct ice_tc_flower_lyr_2_4_hdrs *headers, struct ice_tc_flower_fltr *fltr) { … } static enum ice_protocol_type ice_proto_type_from_mac(bool inner) { … } static enum ice_protocol_type ice_proto_type_from_etype(bool inner) { … } static enum ice_protocol_type ice_proto_type_from_ipv4(bool inner) { … } static enum ice_protocol_type ice_proto_type_from_ipv6(bool inner) { … } static enum ice_protocol_type ice_proto_type_from_l4_port(u16 ip_proto) { … } static enum ice_protocol_type ice_proto_type_from_tunnel(enum ice_tunnel_type type) { … } static enum ice_sw_tunnel_type ice_sw_type_from_tunnel(enum ice_tunnel_type type) { … } static u16 ice_check_supported_vlan_tpid(u16 vlan_tpid) { … } static int ice_tc_fill_tunnel_outer(u32 flags, struct ice_tc_flower_fltr *fltr, struct ice_adv_lkup_elem *list, int i) { … } /** * ice_tc_fill_rules - fill filter rules based on TC fltr * @hw: pointer to HW structure * @flags: tc flower field flags * @tc_fltr: pointer to TC flower filter * @list: list of advance rule elements * @rule_info: pointer to information about rule * @l4_proto: pointer to information such as L4 proto type * * Fill ice_adv_lkup_elem list based on TC flower flags and * TC flower headers. This list should be used to add * advance filter in hardware. */ static int ice_tc_fill_rules(struct ice_hw *hw, u32 flags, struct ice_tc_flower_fltr *tc_fltr, struct ice_adv_lkup_elem *list, struct ice_adv_rule_info *rule_info, u16 *l4_proto) { … } /** * ice_tc_tun_get_type - get the tunnel type * @tunnel_dev: ptr to tunnel device * * This function detects appropriate tunnel_type if specified device is * tunnel device such as VXLAN/Geneve */ static int ice_tc_tun_get_type(struct net_device *tunnel_dev) { … } bool ice_is_tunnel_supported(struct net_device *dev) { … } static bool ice_tc_is_dev_uplink(struct net_device *dev) { … } static int ice_tc_setup_action(struct net_device *filter_dev, struct ice_tc_flower_fltr *fltr, struct net_device *target_dev, enum ice_sw_fwd_act_type action) { … } static int ice_tc_setup_drop_action(struct net_device *filter_dev, struct ice_tc_flower_fltr *fltr) { … } static int ice_eswitch_tc_parse_action(struct net_device *filter_dev, struct ice_tc_flower_fltr *fltr, struct flow_action_entry *act) { … } static int ice_eswitch_add_tc_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr) { … } /** * ice_locate_vsi_using_queue - locate VSI using queue (forward to queue action) * @vsi: Pointer to VSI * @queue: Queue index * * Locate the VSI using specified "queue". When ADQ is not enabled, * always return input VSI, otherwise locate corresponding * VSI based on per channel "offset" and "qcount" */ struct ice_vsi * ice_locate_vsi_using_queue(struct ice_vsi *vsi, int queue) { … } static struct ice_rx_ring * ice_locate_rx_ring_using_queue(struct ice_vsi *vsi, struct ice_tc_flower_fltr *tc_fltr) { … } /** * ice_tc_forward_action - Determine destination VSI and queue for the action * @vsi: Pointer to VSI * @tc_fltr: Pointer to TC flower filter structure * * Validates the tc forward action and determines the destination VSI and queue * for the forward action. */ static struct ice_vsi * ice_tc_forward_action(struct ice_vsi *vsi, struct ice_tc_flower_fltr *tc_fltr) { … } /** * ice_add_tc_flower_adv_fltr - add appropriate filter rules * @vsi: Pointer to VSI * @tc_fltr: Pointer to TC flower filter structure * * based on filter parameters using Advance recipes supported * by OS package. */ static int ice_add_tc_flower_adv_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *tc_fltr) { … } /** * ice_tc_set_pppoe - Parse PPPoE fields from TC flower filter * @match: Pointer to flow match structure * @fltr: Pointer to filter structure * @headers: Pointer to outer header fields * @returns PPP protocol used in filter (ppp_ses or ppp_disc) */ static u16 ice_tc_set_pppoe(struct flow_match_pppoe *match, struct ice_tc_flower_fltr *fltr, struct ice_tc_flower_lyr_2_4_hdrs *headers) { … } /** * ice_tc_set_ipv4 - Parse IPv4 addresses from TC flower filter * @match: Pointer to flow match structure * @fltr: Pointer to filter structure * @headers: inner or outer header fields * @is_encap: set true for tunnel IPv4 address */ static int ice_tc_set_ipv4(struct flow_match_ipv4_addrs *match, struct ice_tc_flower_fltr *fltr, struct ice_tc_flower_lyr_2_4_hdrs *headers, bool is_encap) { … } /** * ice_tc_set_ipv6 - Parse IPv6 addresses from TC flower filter * @match: Pointer to flow match structure * @fltr: Pointer to filter structure * @headers: inner or outer header fields * @is_encap: set true for tunnel IPv6 address */ static int ice_tc_set_ipv6(struct flow_match_ipv6_addrs *match, struct ice_tc_flower_fltr *fltr, struct ice_tc_flower_lyr_2_4_hdrs *headers, bool is_encap) { … } /** * ice_tc_set_tos_ttl - Parse IP ToS/TTL from TC flower filter * @match: Pointer to flow match structure * @fltr: Pointer to filter structure * @headers: inner or outer header fields * @is_encap: set true for tunnel */ static void ice_tc_set_tos_ttl(struct flow_match_ip *match, struct ice_tc_flower_fltr *fltr, struct ice_tc_flower_lyr_2_4_hdrs *headers, bool is_encap) { … } /** * ice_tc_set_port - Parse ports from TC flower filter * @match: Flow match structure * @fltr: Pointer to filter structure * @headers: inner or outer header fields * @is_encap: set true for tunnel port */ static int ice_tc_set_port(struct flow_match_ports match, struct ice_tc_flower_fltr *fltr, struct ice_tc_flower_lyr_2_4_hdrs *headers, bool is_encap) { … } static struct net_device * ice_get_tunnel_device(struct net_device *dev, struct flow_rule *rule) { … } /** * ice_parse_gtp_type - Sets GTP tunnel type to GTP-U or GTP-C * @match: Flow match structure * @fltr: Pointer to filter structure * * GTP-C/GTP-U is selected based on destination port number (enc_dst_port). * Before calling this funtcion, fltr->tunnel_type should be set to TNL_GTPU, * therefore making GTP-U the default choice (when destination port number is * not specified). */ static int ice_parse_gtp_type(struct flow_match_ports match, struct ice_tc_flower_fltr *fltr) { … } static int ice_parse_tunnel_attr(struct net_device *dev, struct flow_rule *rule, struct ice_tc_flower_fltr *fltr) { … } /** * ice_parse_cls_flower - Parse TC flower filters provided by kernel * @vsi: Pointer to the VSI * @filter_dev: Pointer to device on which filter is being added * @f: Pointer to struct flow_cls_offload * @fltr: Pointer to filter structure */ static int ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi, struct flow_cls_offload *f, struct ice_tc_flower_fltr *fltr) { … } /** * ice_add_switch_fltr - Add TC flower filters * @vsi: Pointer to VSI * @fltr: Pointer to struct ice_tc_flower_fltr * * Add filter in HW switch block */ static int ice_add_switch_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr) { … } /** * ice_prep_adq_filter - Prepare ADQ filter with the required additional headers * @vsi: Pointer to VSI * @fltr: Pointer to TC flower filter structure * * Prepare ADQ filter with the required additional header fields */ static int ice_prep_adq_filter(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr) { … } /** * ice_handle_tclass_action - Support directing to a traffic class * @vsi: Pointer to VSI * @cls_flower: Pointer to TC flower offload structure * @fltr: Pointer to TC flower filter structure * * Support directing traffic to a traffic class/queue-set */ static int ice_handle_tclass_action(struct ice_vsi *vsi, struct flow_cls_offload *cls_flower, struct ice_tc_flower_fltr *fltr) { … } static int ice_tc_forward_to_queue(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr, struct flow_action_entry *act) { … } static int ice_tc_parse_action(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr, struct flow_action_entry *act) { … } /** * ice_parse_tc_flower_actions - Parse the actions for a TC filter * @filter_dev: Pointer to device on which filter is being added * @vsi: Pointer to VSI * @cls_flower: Pointer to TC flower offload structure * @fltr: Pointer to TC flower filter structure * * Parse the actions for a TC filter */ static int ice_parse_tc_flower_actions(struct net_device *filter_dev, struct ice_vsi *vsi, struct flow_cls_offload *cls_flower, struct ice_tc_flower_fltr *fltr) { … } /** * ice_del_tc_fltr - deletes a filter from HW table * @vsi: Pointer to VSI * @fltr: Pointer to struct ice_tc_flower_fltr * * This function deletes a filter from HW table and manages book-keeping */ static int ice_del_tc_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr) { … } /** * ice_add_tc_fltr - adds a TC flower filter * @netdev: Pointer to netdev * @vsi: Pointer to VSI * @f: Pointer to flower offload structure * @__fltr: Pointer to struct ice_tc_flower_fltr * * This function parses TC-flower input fields, parses action, * and adds a filter. */ static int ice_add_tc_fltr(struct net_device *netdev, struct ice_vsi *vsi, struct flow_cls_offload *f, struct ice_tc_flower_fltr **__fltr) { … } /** * ice_find_tc_flower_fltr - Find the TC flower filter in the list * @pf: Pointer to PF * @cookie: filter specific cookie */ static struct ice_tc_flower_fltr * ice_find_tc_flower_fltr(struct ice_pf *pf, unsigned long cookie) { … } /** * ice_add_cls_flower - add TC flower filters * @netdev: Pointer to filter device * @vsi: Pointer to VSI * @cls_flower: Pointer to flower offload structure */ int ice_add_cls_flower(struct net_device *netdev, struct ice_vsi *vsi, struct flow_cls_offload *cls_flower) { … } /** * ice_del_cls_flower - delete TC flower filters * @vsi: Pointer to VSI * @cls_flower: Pointer to struct flow_cls_offload */ int ice_del_cls_flower(struct ice_vsi *vsi, struct flow_cls_offload *cls_flower) { … } /** * ice_replay_tc_fltrs - replay TC filters * @pf: pointer to PF struct */ void ice_replay_tc_fltrs(struct ice_pf *pf) { … }