linux/drivers/net/ethernet/intel/ice/ice_arfs.c

// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 2018-2020, Intel Corporation. */

#include "ice.h"
#include <net/rps.h>

/**
 * ice_is_arfs_active - helper to check is aRFS is active
 * @vsi: VSI to check
 */
static bool ice_is_arfs_active(struct ice_vsi *vsi)
{}

/**
 * ice_is_arfs_using_perfect_flow - check if aRFS has active perfect filters
 * @hw: pointer to the HW structure
 * @flow_type: flow type as Flow Director understands it
 *
 * Flow Director will query this function to see if aRFS is currently using
 * the specified flow_type for perfect (4-tuple) filters.
 */
bool
ice_is_arfs_using_perfect_flow(struct ice_hw *hw, enum ice_fltr_ptype flow_type)
{}

/**
 * ice_arfs_update_active_fltr_cntrs - update active filter counters for aRFS
 * @vsi: VSI that aRFS is active on
 * @entry: aRFS entry used to change counters
 * @add: true to increment counter, false to decrement
 */
static void
ice_arfs_update_active_fltr_cntrs(struct ice_vsi *vsi,
				  struct ice_arfs_entry *entry, bool add)
{}

/**
 * ice_arfs_del_flow_rules - delete the rules passed in from HW
 * @vsi: VSI for the flow rules that need to be deleted
 * @del_list_head: head of the list of ice_arfs_entry(s) for rule deletion
 *
 * Loop through the delete list passed in and remove the rules from HW. After
 * each rule is deleted, disconnect and free the ice_arfs_entry because it is no
 * longer being referenced by the aRFS hash table.
 */
static void
ice_arfs_del_flow_rules(struct ice_vsi *vsi, struct hlist_head *del_list_head)
{}

/**
 * ice_arfs_add_flow_rules - add the rules passed in from HW
 * @vsi: VSI for the flow rules that need to be added
 * @add_list_head: head of the list of ice_arfs_entry_ptr(s) for rule addition
 *
 * Loop through the add list passed in and remove the rules from HW. After each
 * rule is added, disconnect and free the ice_arfs_entry_ptr node. Don't free
 * the ice_arfs_entry(s) because they are still being referenced in the aRFS
 * hash table.
 */
static void
ice_arfs_add_flow_rules(struct ice_vsi *vsi, struct hlist_head *add_list_head)
{}

/**
 * ice_arfs_is_flow_expired - check if the aRFS entry has expired
 * @vsi: VSI containing the aRFS entry
 * @arfs_entry: aRFS entry that's being checked for expiration
 *
 * Return true if the flow has expired, else false. This function should be used
 * to determine whether or not an aRFS entry should be removed from the hardware
 * and software structures.
 */
static bool
ice_arfs_is_flow_expired(struct ice_vsi *vsi, struct ice_arfs_entry *arfs_entry)
{}

/**
 * ice_arfs_update_flow_rules - add/delete aRFS rules in HW
 * @vsi: the VSI to be forwarded to
 * @idx: index into the table of aRFS filter lists. Obtained from skb->hash
 * @add_list: list to populate with filters to be added to Flow Director
 * @del_list: list to populate with filters to be deleted from Flow Director
 *
 * Iterate over the hlist at the index given in the aRFS hash table and
 * determine if there are any aRFS entries that need to be either added or
 * deleted in the HW. If the aRFS entry is marked as ICE_ARFS_INACTIVE the
 * filter needs to be added to HW, else if it's marked as ICE_ARFS_ACTIVE and
 * the flow has expired delete the filter from HW. The caller of this function
 * is expected to add/delete rules on the add_list/del_list respectively.
 */
static void
ice_arfs_update_flow_rules(struct ice_vsi *vsi, u16 idx,
			   struct hlist_head *add_list,
			   struct hlist_head *del_list)
{}

/**
 * ice_sync_arfs_fltrs - update all aRFS filters
 * @pf: board private structure
 */
void ice_sync_arfs_fltrs(struct ice_pf *pf)
{}

/**
 * ice_arfs_build_entry - builds an aRFS entry based on input
 * @vsi: destination VSI for this flow
 * @fk: flow dissector keys for creating the tuple
 * @rxq_idx: Rx queue to steer this flow to
 * @flow_id: passed down from the stack and saved for flow expiration
 *
 * returns an aRFS entry on success and NULL on failure
 */
static struct ice_arfs_entry *
ice_arfs_build_entry(struct ice_vsi *vsi, const struct flow_keys *fk,
		     u16 rxq_idx, u32 flow_id)
{}

/**
 * ice_arfs_is_perfect_flow_set - Check to see if perfect flow is set
 * @hw: pointer to HW structure
 * @l3_proto: ETH_P_IP or ETH_P_IPV6 in network order
 * @l4_proto: IPPROTO_UDP or IPPROTO_TCP
 *
 * We only support perfect (4-tuple) filters for aRFS. This function allows aRFS
 * to check if perfect (4-tuple) flow rules are currently in place by Flow
 * Director.
 */
static bool
ice_arfs_is_perfect_flow_set(struct ice_hw *hw, __be16 l3_proto, u8 l4_proto)
{}

/**
 * ice_rx_flow_steer - steer the Rx flow to where application is being run
 * @netdev: ptr to the netdev being adjusted
 * @skb: buffer with required header information
 * @rxq_idx: queue to which the flow needs to move
 * @flow_id: flow identifier provided by the netdev
 *
 * Based on the skb, rxq_idx, and flow_id passed in add/update an entry in the
 * aRFS hash table. Iterate over one of the hlists in the aRFS hash table and
 * if the flow_id already exists in the hash table but the rxq_idx has changed
 * mark the entry as ICE_ARFS_INACTIVE so it can get updated in HW, else
 * if the entry is marked as ICE_ARFS_TODEL delete it from the aRFS hash table.
 * If neither of the previous conditions are true then add a new entry in the
 * aRFS hash table, which gets set to ICE_ARFS_INACTIVE by default so it can be
 * added to HW.
 */
int
ice_rx_flow_steer(struct net_device *netdev, const struct sk_buff *skb,
		  u16 rxq_idx, u32 flow_id)
{}

/**
 * ice_init_arfs_cntrs - initialize aRFS counter values
 * @vsi: VSI that aRFS counters need to be initialized on
 */
static int ice_init_arfs_cntrs(struct ice_vsi *vsi)
{}

/**
 * ice_init_arfs - initialize aRFS resources
 * @vsi: the VSI to be forwarded to
 */
void ice_init_arfs(struct ice_vsi *vsi)
{}

/**
 * ice_clear_arfs - clear the aRFS hash table and any memory used for aRFS
 * @vsi: the VSI to be forwarded to
 */
void ice_clear_arfs(struct ice_vsi *vsi)
{}

/**
 * ice_free_cpu_rx_rmap - free setup CPU reverse map
 * @vsi: the VSI to be forwarded to
 */
void ice_free_cpu_rx_rmap(struct ice_vsi *vsi)
{}

/**
 * ice_set_cpu_rx_rmap - setup CPU reverse map for each queue
 * @vsi: the VSI to be forwarded to
 */
int ice_set_cpu_rx_rmap(struct ice_vsi *vsi)
{}

/**
 * ice_remove_arfs - remove/clear all aRFS resources
 * @pf: device private structure
 */
void ice_remove_arfs(struct ice_pf *pf)
{}

/**
 * ice_rebuild_arfs - remove/clear all aRFS resources and rebuild after reset
 * @pf: device private structure
 */
void ice_rebuild_arfs(struct ice_pf *pf)
{}