]> git.droids-corp.org - dpdk.git/commitdiff
net/ice/base: add get/set functions for shared parameters
authorQi Zhang <qi.z.zhang@intel.com>
Thu, 16 Sep 2021 09:53:02 +0000 (17:53 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Tue, 21 Sep 2021 12:33:42 +0000 (14:33 +0200)
Add functions used by the driver for setting and getting the shared
driver parameters. These will be used by the driver in order to share
the PTP clock index identifier between PF drivers.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
drivers/net/ice/base/ice_adminq_cmd.h
drivers/net/ice/base/ice_common.c
drivers/net/ice/base/ice_common.h

index e9d6fcc3ad05fb0540a8298dec91096ec54abc31..253b971dfd314add47622cb6a6e890550946d3aa 100644 (file)
@@ -2713,6 +2713,16 @@ struct ice_aqc_driver_shared_params {
        __le32 addr_low;
 };
 
+enum ice_aqc_driver_params {
+       /* OS clock index for PTP timer Domain 0 */
+       ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0 = 0,
+       /* OS clock index for PTP timer Domain 1 */
+       ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR1,
+
+       /* Add new parameters above */
+       ICE_AQC_DRIVER_PARAM_MAX = 16,
+};
+
 /* Lan Queue Overflow Event (direct, 0x1001) */
 struct ice_aqc_event_lan_overflow {
        __le32 prtdcb_ruptq;
index 46b0dd11b8c7766c4848e44f091108d9103575b2..ae55bebaa22318d597f6e45c28eec540436f8ad1 100644 (file)
@@ -5494,6 +5494,81 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
        return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
 }
 
+/**
+ * ice_aq_set_driver_param - Set driver parameter to share via firmware
+ * @hw: pointer to the HW struct
+ * @idx: parameter index to set
+ * @value: the value to set the parameter to
+ * @cd: pointer to command details structure or NULL
+ *
+ * Set the value of one of the software defined parameters. All PFs connected
+ * to this device can read the value using ice_aq_get_driver_param.
+ *
+ * Note that firmware provides no synchronization or locking, and will not
+ * save the parameter value during a device reset. It is expected that
+ * a single PF will write the parameter value, while all other PFs will only
+ * read it.
+ */
+enum ice_status
+ice_aq_set_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
+                       u32 value, struct ice_sq_cd *cd)
+{
+       struct ice_aqc_driver_shared_params *cmd;
+       struct ice_aq_desc desc;
+
+       if (idx >= ICE_AQC_DRIVER_PARAM_MAX)
+               return ICE_ERR_OUT_OF_RANGE;
+
+       cmd = &desc.params.drv_shared_params;
+
+       ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_driver_shared_params);
+
+       cmd->set_or_get_op = ICE_AQC_DRIVER_PARAM_SET;
+       cmd->param_indx = idx;
+       cmd->param_val = CPU_TO_LE32(value);
+
+       return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
+}
+
+/**
+ * ice_aq_get_driver_param - Get driver parameter shared via firmware
+ * @hw: pointer to the HW struct
+ * @idx: parameter index to set
+ * @value: storage to return the shared parameter
+ * @cd: pointer to command details structure or NULL
+ *
+ * Get the value of one of the software defined parameters.
+ *
+ * Note that firmware provides no synchronization or locking. It is expected
+ * that only a single PF will write a given parameter.
+ */
+enum ice_status
+ice_aq_get_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
+                       u32 *value, struct ice_sq_cd *cd)
+{
+       struct ice_aqc_driver_shared_params *cmd;
+       struct ice_aq_desc desc;
+       enum ice_status status;
+
+       if (idx >= ICE_AQC_DRIVER_PARAM_MAX)
+               return ICE_ERR_OUT_OF_RANGE;
+
+       cmd = &desc.params.drv_shared_params;
+
+       ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_driver_shared_params);
+
+       cmd->set_or_get_op = ICE_AQC_DRIVER_PARAM_GET;
+       cmd->param_indx = idx;
+
+       status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
+       if (status)
+               return status;
+
+       *value = LE32_TO_CPU(cmd->param_val);
+
+       return ICE_SUCCESS;
+}
+
 /**
  * ice_aq_set_gpio
  * @hw: pointer to the hw struct
index a5bfdc072e1c79306eba2c483a30eb64b17e7744..1d8882c279d61851a7ed6faa1179d23fcf3d1ca0 100644 (file)
@@ -251,6 +251,12 @@ enum ice_status
 ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
                     struct ice_aqc_txsched_elem_data *buf);
 enum ice_status
+ice_aq_set_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
+                       u32 value, struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_get_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
+                       u32 *value, struct ice_sq_cd *cd);
+enum ice_status
 ice_aq_set_gpio(struct ice_hw *hw, u16 gpio_ctrl_handle, u8 pin_idx, bool value,
                struct ice_sq_cd *cd);
 enum ice_status