Skip to content

Commit 7f9ab54

Browse files
jacob-kelleranguy11
authored andcommitted
ice: add support for set/get of driver-stored firmware parameters
Depending on the device configuration, the ice hardware may share the PTP hardware clock timer between multiple PFs. Each PF is informed by firmware during initialization of the PTP timer association. When bringing up PTP, only the PFs which own the timer shall allocate a PTP hardware clock. Other PFs associated with that timer must report the correct PTP clock index in order to allow userspace software the ability to know which ports are connected to the same clock. To support this, the firmware has driver shared parameters. These parameters enable one PF to write the clock index into firmware, and have other PFs read the associated value out. This enables the driver to have only a single PF allocate and control the device timer registers, while other PFs associated with that timer can report the correct clock in the ETHTOOL_GET_TS_INFO report. Add support for the necessary admin queue commands to enable reading and writing of the driver shared parameters. This will be used in a future change to enable sharing the PTP clock index between PF drivers. Signed-off-by: Jacob Keller <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 9733cc9 commit 7f9ab54

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,30 @@ struct ice_aqc_get_pkg_info_resp {
18531853
struct ice_aqc_get_pkg_info pkg_info[];
18541854
};
18551855

1856+
/* Driver Shared Parameters (direct, 0x0C90) */
1857+
struct ice_aqc_driver_shared_params {
1858+
u8 set_or_get_op;
1859+
#define ICE_AQC_DRIVER_PARAM_OP_MASK BIT(0)
1860+
#define ICE_AQC_DRIVER_PARAM_SET 0
1861+
#define ICE_AQC_DRIVER_PARAM_GET 1
1862+
u8 param_indx;
1863+
#define ICE_AQC_DRIVER_PARAM_MAX_IDX 15
1864+
u8 rsvd[2];
1865+
__le32 param_val;
1866+
__le32 addr_high;
1867+
__le32 addr_low;
1868+
};
1869+
1870+
enum ice_aqc_driver_params {
1871+
/* OS clock index for PTP timer Domain 0 */
1872+
ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0 = 0,
1873+
/* OS clock index for PTP timer Domain 1 */
1874+
ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR1,
1875+
1876+
/* Add new parameters above */
1877+
ICE_AQC_DRIVER_PARAM_MAX = 16,
1878+
};
1879+
18561880
/* Lan Queue Overflow Event (direct, 0x1001) */
18571881
struct ice_aqc_event_lan_overflow {
18581882
__le32 prtdcb_ruptq;
@@ -1930,6 +1954,7 @@ struct ice_aq_desc {
19301954
struct ice_aqc_fw_logging fw_logging;
19311955
struct ice_aqc_get_clear_fw_log get_clear_fw_log;
19321956
struct ice_aqc_download_pkg download_pkg;
1957+
struct ice_aqc_driver_shared_params drv_shared_params;
19331958
struct ice_aqc_set_mac_lb set_mac_lb;
19341959
struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
19351960
struct ice_aqc_set_mac_cfg set_mac_cfg;
@@ -2083,6 +2108,8 @@ enum ice_adminq_opc {
20832108
ice_aqc_opc_update_pkg = 0x0C42,
20842109
ice_aqc_opc_get_pkg_info_list = 0x0C43,
20852110

2111+
ice_aqc_opc_driver_shared_params = 0x0C90,
2112+
20862113
/* Standalone Commands/Events */
20872114
ice_aqc_opc_event_lan_overflow = 0x1001,
20882115

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4680,6 +4680,81 @@ ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
46804680
return status;
46814681
}
46824682

4683+
/**
4684+
* ice_aq_set_driver_param - Set driver parameter to share via firmware
4685+
* @hw: pointer to the HW struct
4686+
* @idx: parameter index to set
4687+
* @value: the value to set the parameter to
4688+
* @cd: pointer to command details structure or NULL
4689+
*
4690+
* Set the value of one of the software defined parameters. All PFs connected
4691+
* to this device can read the value using ice_aq_get_driver_param.
4692+
*
4693+
* Note that firmware provides no synchronization or locking, and will not
4694+
* save the parameter value during a device reset. It is expected that
4695+
* a single PF will write the parameter value, while all other PFs will only
4696+
* read it.
4697+
*/
4698+
int
4699+
ice_aq_set_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
4700+
u32 value, struct ice_sq_cd *cd)
4701+
{
4702+
struct ice_aqc_driver_shared_params *cmd;
4703+
struct ice_aq_desc desc;
4704+
4705+
if (idx >= ICE_AQC_DRIVER_PARAM_MAX)
4706+
return -EIO;
4707+
4708+
cmd = &desc.params.drv_shared_params;
4709+
4710+
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_driver_shared_params);
4711+
4712+
cmd->set_or_get_op = ICE_AQC_DRIVER_PARAM_SET;
4713+
cmd->param_indx = idx;
4714+
cmd->param_val = cpu_to_le32(value);
4715+
4716+
return ice_status_to_errno(ice_aq_send_cmd(hw, &desc, NULL, 0, cd));
4717+
}
4718+
4719+
/**
4720+
* ice_aq_get_driver_param - Get driver parameter shared via firmware
4721+
* @hw: pointer to the HW struct
4722+
* @idx: parameter index to set
4723+
* @value: storage to return the shared parameter
4724+
* @cd: pointer to command details structure or NULL
4725+
*
4726+
* Get the value of one of the software defined parameters.
4727+
*
4728+
* Note that firmware provides no synchronization or locking. It is expected
4729+
* that only a single PF will write a given parameter.
4730+
*/
4731+
int
4732+
ice_aq_get_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
4733+
u32 *value, struct ice_sq_cd *cd)
4734+
{
4735+
struct ice_aqc_driver_shared_params *cmd;
4736+
struct ice_aq_desc desc;
4737+
enum ice_status status;
4738+
4739+
if (idx >= ICE_AQC_DRIVER_PARAM_MAX)
4740+
return -EIO;
4741+
4742+
cmd = &desc.params.drv_shared_params;
4743+
4744+
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_driver_shared_params);
4745+
4746+
cmd->set_or_get_op = ICE_AQC_DRIVER_PARAM_GET;
4747+
cmd->param_indx = idx;
4748+
4749+
status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
4750+
if (status)
4751+
return ice_status_to_errno(status);
4752+
4753+
*value = le32_to_cpu(cmd->param_val);
4754+
4755+
return 0;
4756+
}
4757+
46834758
/**
46844759
* ice_fw_supports_link_override
46854760
* @hw: pointer to the hardware structure

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
185185
enum ice_status
186186
ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
187187
struct ice_aqc_txsched_elem_data *buf);
188+
int
189+
ice_aq_set_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
190+
u32 value, struct ice_sq_cd *cd);
191+
int
192+
ice_aq_get_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
193+
u32 *value, struct ice_sq_cd *cd);
188194
enum ice_status
189195
ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size,
190196
struct ice_sq_cd *cd);

0 commit comments

Comments
 (0)