// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2013 - 2018 Intel Corporation. */ #include <linux/firmware.h> #include "i40e.h" #define I40_DDP_FLASH_REGION … #define I40E_PROFILE_INFO_SIZE … #define I40E_MAX_PROFILE_NUM … #define I40E_PROFILE_LIST_SIZE … #define I40E_DDP_PROFILE_PATH … #define I40E_DDP_PROFILE_NAME_MAX … struct i40e_ddp_profile_list { … }; struct i40e_ddp_old_profile_list { … }; /** * i40e_ddp_profiles_eq - checks if DDP profiles are the equivalent * @a: new profile info * @b: old profile info * * checks if DDP profiles are the equivalent. * Returns true if profiles are the same. **/ static bool i40e_ddp_profiles_eq(struct i40e_profile_info *a, struct i40e_profile_info *b) { … } /** * i40e_ddp_does_profile_exist - checks if DDP profile loaded already * @hw: HW data structure * @pinfo: DDP profile information structure * * checks if DDP profile loaded already. * Returns >0 if the profile exists. * Returns 0 if the profile is absent. * Returns <0 if error. **/ static int i40e_ddp_does_profile_exist(struct i40e_hw *hw, struct i40e_profile_info *pinfo) { … } /** * i40e_ddp_profiles_overlap - checks if DDP profiles overlap. * @new: new profile info * @old: old profile info * * checks if DDP profiles overlap. * Returns true if profiles are overlap. **/ static bool i40e_ddp_profiles_overlap(struct i40e_profile_info *new, struct i40e_profile_info *old) { … } /** * i40e_ddp_does_profile_overlap - checks if DDP overlaps with existing one. * @hw: HW data structure * @pinfo: DDP profile information structure * * checks if DDP profile overlaps with existing one. * Returns >0 if the profile overlaps. * Returns 0 if the profile is ok. * Returns <0 if error. **/ static int i40e_ddp_does_profile_overlap(struct i40e_hw *hw, struct i40e_profile_info *pinfo) { … } /** * i40e_add_pinfo * @hw: pointer to the hardware structure * @profile: pointer to the profile segment of the package * @profile_info_sec: buffer for information section * @track_id: package tracking id * * Register a profile to the list of loaded profiles. */ static int i40e_add_pinfo(struct i40e_hw *hw, struct i40e_profile_segment *profile, u8 *profile_info_sec, u32 track_id) { … } /** * i40e_del_pinfo - delete DDP profile info from NIC * @hw: HW data structure * @profile: DDP profile segment to be deleted * @profile_info_sec: DDP profile section header * @track_id: track ID of the profile for deletion * * Removes DDP profile from the NIC. **/ static int i40e_del_pinfo(struct i40e_hw *hw, struct i40e_profile_segment *profile, u8 *profile_info_sec, u32 track_id) { … } /** * i40e_ddp_is_pkg_hdr_valid - performs basic pkg header integrity checks * @netdev: net device structure (for logging purposes) * @pkg_hdr: pointer to package header * @size_huge: size of the whole DDP profile package in size_t * * Checks correctness of pkg header: Version, size too big/small, and * all segment offsets alignment and boundaries. This function lets * reject non DDP profile file to be loaded by administrator mistake. **/ static bool i40e_ddp_is_pkg_hdr_valid(struct net_device *netdev, struct i40e_package_header *pkg_hdr, size_t size_huge) { … } /** * i40e_ddp_load - performs DDP loading * @netdev: net device structure * @data: buffer containing recipe file * @size: size of the buffer * @is_add: true when loading profile, false when rolling back the previous one * * Checks correctness and loads DDP profile to the NIC. The function is * also used for rolling back previously loaded profile. **/ static int i40e_ddp_load(struct net_device *netdev, const u8 *data, size_t size, bool is_add) { … } /** * i40e_ddp_restore - restore previously loaded profile and remove from list * @pf: PF data struct * * Restores previously loaded profile stored on the list in driver memory. * After rolling back removes entry from the list. **/ static int i40e_ddp_restore(struct i40e_pf *pf) { … } /** * i40e_ddp_flash - callback function for ethtool flash feature * @netdev: net device structure * @flash: kernel flash structure * * Ethtool callback function used for loading and unloading DDP profiles. **/ int i40e_ddp_flash(struct net_device *netdev, struct ethtool_flash *flash) { … }