Commit f699a4bf authored by Ivan Vecera's avatar Ivan Vecera Committed by Jakub Kicinski
Browse files

i40e: Move inline helpers to i40e_prototype.h

Move version check helper functions from i40e_type.h to
i40e_prototype.h as per discussion [1].

[1] https://lore.kernel.org/all/cdcd6b97-1138-4cd7-854f-b3faa1f475f8@intel.com/#t



Cc: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
Link: https://lore.kernel.org/r/20231113231047.548659-15-anthony.l.nguyen@intel.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d8c6bee0
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
@@ -501,4 +501,74 @@ i40e_add_pinfo_to_list(struct i40e_hw *hw,
/* i40e_ddp */
int i40e_ddp_flash(struct net_device *netdev, struct ethtool_flash *flash);

/* Firmware and AdminQ version check helpers */

/**
 * i40e_is_aq_api_ver_ge
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current HW API version is greater/equal than provided.
 **/
static inline bool i40e_is_aq_api_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
{
	return (hw->aq.api_maj_ver > maj ||
		(hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
}

/**
 * i40e_is_aq_api_ver_lt
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current HW API version is less than provided.
 **/
static inline bool i40e_is_aq_api_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
{
	return !i40e_is_aq_api_ver_ge(hw, maj, min);
}

/**
 * i40e_is_fw_ver_ge
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current firmware version is greater/equal than provided.
 **/
static inline bool i40e_is_fw_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
{
	return (hw->aq.fw_maj_ver > maj ||
		(hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver >= min));
}

/**
 * i40e_is_fw_ver_lt
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current firmware version is less than provided.
 **/
static inline bool i40e_is_fw_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
{
	return !i40e_is_fw_ver_ge(hw, maj, min);
}

/**
 * i40e_is_fw_ver_eq
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current firmware version is equal to provided.
 **/
static inline bool i40e_is_fw_ver_eq(struct i40e_hw *hw, u16 maj, u16 min)
{
	return (hw->aq.fw_maj_ver > maj ||
		(hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver == min));
}

#endif /* _I40E_PROTOTYPE_H_ */
+0 −68
Original line number Diff line number Diff line
@@ -586,74 +586,6 @@ struct i40e_hw {
	char err_str[16];
};

/**
 * i40e_is_aq_api_ver_ge
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current HW API version is greater/equal than provided.
 **/
static inline bool i40e_is_aq_api_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
{
	return (hw->aq.api_maj_ver > maj ||
		(hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
}

/**
 * i40e_is_aq_api_ver_lt
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current HW API version is less than provided.
 **/
static inline bool i40e_is_aq_api_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
{
	return !i40e_is_aq_api_ver_ge(hw, maj, min);
}

/**
 * i40e_is_fw_ver_ge
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current firmware version is greater/equal than provided.
 **/
static inline bool i40e_is_fw_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
{
	return (hw->aq.fw_maj_ver > maj ||
		(hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver >= min));
}

/**
 * i40e_is_fw_ver_lt
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current firmware version is less than provided.
 **/
static inline bool i40e_is_fw_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
{
	return !i40e_is_fw_ver_ge(hw, maj, min);
}

/**
 * i40e_is_fw_ver_eq
 * @hw: pointer to i40e_hw structure
 * @maj: API major value to compare
 * @min: API minor value to compare
 *
 * Assert whether current firmware version is equal to provided.
 **/
static inline bool i40e_is_fw_ver_eq(struct i40e_hw *hw, u16 maj, u16 min)
{
	return (hw->aq.fw_maj_ver > maj ||
		(hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver == min));
}

struct i40e_driver_version {
	u8 major_version;
	u8 minor_version;