// SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2015 - 2024 Beijing WangXun Technology Co., Ltd. */ #include <linux/string.h> #include <linux/types.h> #include <linux/pci.h> #include "../libwx/wx_type.h" #include "../libwx/wx_lib.h" #include "../libwx/wx_hw.h" #include "txgbe_type.h" #include "txgbe_fdir.h" /* These defines allow us to quickly generate all of the necessary instructions * in the function below by simply calling out TXGBE_COMPUTE_SIG_HASH_ITERATION * for values 0 through 15 */ #define TXGBE_ATR_COMMON_HASH_KEY … #define TXGBE_COMPUTE_SIG_HASH_ITERATION(_n) … /** * txgbe_atr_compute_sig_hash - Compute the signature hash * @input: input bitstream to compute the hash on * @common: compressed common input dword * @hash: pointer to the computed hash * * This function is almost identical to the function above but contains * several optimizations such as unwinding all of the loops, letting the * compiler work out all of the conditional ifs since the keys are static * defines, and computing two keys at once since the hashed dword stream * will be the same for both keys. **/ static void txgbe_atr_compute_sig_hash(union txgbe_atr_hash_dword input, union txgbe_atr_hash_dword common, u32 *hash) { … } #define TXGBE_COMPUTE_BKT_HASH_ITERATION(_n) … /** * txgbe_atr_compute_perfect_hash - Compute the perfect filter hash * @input: input bitstream to compute the hash on * @input_mask: mask for the input bitstream * * This function serves two main purposes. First it applies the input_mask * to the atr_input resulting in a cleaned up atr_input data stream. * Secondly it computes the hash and stores it in the bkt_hash field at * the end of the input byte stream. This way it will be available for * future use without needing to recompute the hash. **/ void txgbe_atr_compute_perfect_hash(union txgbe_atr_input *input, union txgbe_atr_input *input_mask) { … } static int txgbe_fdir_check_cmd_complete(struct wx *wx) { … } /** * txgbe_fdir_add_signature_filter - Adds a signature hash filter * @wx: pointer to hardware structure * @input: unique input dword * @common: compressed common input dword * @queue: queue index to direct traffic to * * @return: 0 on success and negative on failure **/ static int txgbe_fdir_add_signature_filter(struct wx *wx, union txgbe_atr_hash_dword input, union txgbe_atr_hash_dword common, u8 queue) { … } void txgbe_atr(struct wx_ring *ring, struct wx_tx_buffer *first, u8 ptype) { … } int txgbe_fdir_set_input_mask(struct wx *wx, union txgbe_atr_input *input_mask) { … } int txgbe_fdir_write_perfect_filter(struct wx *wx, union txgbe_atr_input *input, u16 soft_id, u8 queue) { … } int txgbe_fdir_erase_perfect_filter(struct wx *wx, union txgbe_atr_input *input, u16 soft_id) { … } /** * txgbe_fdir_enable - Initialize Flow Director control registers * @wx: pointer to hardware structure * @fdirctrl: value to write to flow director control register **/ static void txgbe_fdir_enable(struct wx *wx, u32 fdirctrl) { … } /** * txgbe_init_fdir_signature -Initialize Flow Director sig filters * @wx: pointer to hardware structure **/ static void txgbe_init_fdir_signature(struct wx *wx) { … } /** * txgbe_init_fdir_perfect - Initialize Flow Director perfect filters * @wx: pointer to hardware structure **/ static void txgbe_init_fdir_perfect(struct wx *wx) { … } static void txgbe_fdir_filter_restore(struct wx *wx) { … } void txgbe_configure_fdir(struct wx *wx) { … } void txgbe_fdir_filter_exit(struct wx *wx) { … }