[PATCH net-next v1 2/4] dpll: pass capabilities on device register

Arkadiusz Kubalewski posted 4 patches 10 months ago
There is a newer version of this series
[PATCH net-next v1 2/4] dpll: pass capabilities on device register
Posted by Arkadiusz Kubalewski 10 months ago
Add new argument on dpll device register, a capabilities bitmask of
features supported by the dpll device.
Provide capability value on dpll device dump.

Reviewed-by: Milena Olech <milena.olech@intel.com>
Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
---
 drivers/dpll/dpll_core.c                       | 5 ++++-
 drivers/dpll/dpll_core.h                       | 2 ++
 drivers/dpll/dpll_netlink.c                    | 2 ++
 drivers/net/ethernet/intel/ice/ice_dpll.c      | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/dpll.c | 2 +-
 drivers/ptp/ptp_ocp.c                          | 2 +-
 include/linux/dpll.h                           | 3 ++-
 7 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 20bdc52f63a5..563ac37c83ad 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -342,6 +342,7 @@ dpll_device_registration_find(struct dpll_device *dpll,
  * dpll_device_register - register the dpll device in the subsystem
  * @dpll: pointer to a dpll
  * @type: type of a dpll
+ * @capabilities: mask of available features supported by dpll
  * @ops: ops for a dpll device
  * @priv: pointer to private information of owner
  *
@@ -353,7 +354,8 @@ dpll_device_registration_find(struct dpll_device *dpll,
  * * negative - error value
  */
 int dpll_device_register(struct dpll_device *dpll, enum dpll_type type,
-			 const struct dpll_device_ops *ops, void *priv)
+			 u32 capabilities, const struct dpll_device_ops *ops,
+			 void *priv)
 {
 	struct dpll_device_registration *reg;
 	bool first_registration = false;
@@ -382,6 +384,7 @@ int dpll_device_register(struct dpll_device *dpll, enum dpll_type type,
 	reg->ops = ops;
 	reg->priv = priv;
 	dpll->type = type;
+	dpll->capabilities = capabilities;
 	first_registration = list_empty(&dpll->registration_list);
 	list_add_tail(&reg->list, &dpll->registration_list);
 	if (!first_registration) {
diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
index 2b6d8ef1cdf3..70bbafb9b635 100644
--- a/drivers/dpll/dpll_core.h
+++ b/drivers/dpll/dpll_core.h
@@ -21,6 +21,7 @@
  * @clock_id:		unique identifier (clock_id) of a dpll
  * @module:		module of creator
  * @type:		type of a dpll
+ * @capabilities:	capabilities of a dpll
  * @pin_refs:		stores pins registered within a dpll
  * @refcount:		refcount
  * @registration_list:	list of registered ops and priv data of dpll owners
@@ -31,6 +32,7 @@ struct dpll_device {
 	u64 clock_id;
 	struct module *module;
 	enum dpll_type type;
+	u32 capabilities;
 	struct xarray pin_refs;
 	refcount_t refcount;
 	struct list_head registration_list;
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index c130f87147fa..41aed0d29be2 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -591,6 +591,8 @@ dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,
 		return ret;
 	if (nla_put_u32(msg, DPLL_A_TYPE, dpll->type))
 		return -EMSGSIZE;
+	if (nla_put_u32(msg, DPLL_A_CAPABILITIES, dpll->capabilities))
+		return -EMSGSIZE;
 
 	return 0;
 }
diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
index bce3ad6ca2a6..614a813c7772 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.c
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
@@ -2012,7 +2012,7 @@ ice_dpll_init_dpll(struct ice_pf *pf, struct ice_dpll *d, bool cgu,
 	d->pf = pf;
 	if (cgu) {
 		ice_dpll_update_state(pf, d, true);
-		ret = dpll_device_register(d->dpll, type, &ice_dpll_ops, d);
+		ret = dpll_device_register(d->dpll, type, 0, &ice_dpll_ops, d);
 		if (ret) {
 			dpll_device_put(d->dpll);
 			return ret;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dpll.c b/drivers/net/ethernet/mellanox/mlx5/core/dpll.c
index 1e5522a19483..0e430f93b047 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/dpll.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/dpll.c
@@ -444,7 +444,7 @@ static int mlx5_dpll_probe(struct auxiliary_device *adev,
 		goto err_free_mdpll;
 	}
 
-	err = dpll_device_register(mdpll->dpll, DPLL_TYPE_EEC,
+	err = dpll_device_register(mdpll->dpll, DPLL_TYPE_EEC, 0,
 				   &mlx5_dpll_device_ops, mdpll);
 	if (err)
 		goto err_put_dpll_device;
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index b25635c5c745..87b9890d8ef2 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -4745,7 +4745,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto out;
 	}
 
-	err = dpll_device_register(bp->dpll, DPLL_TYPE_PPS, &dpll_ops, bp);
+	err = dpll_device_register(bp->dpll, DPLL_TYPE_PPS, 0, &dpll_ops, bp);
 	if (err)
 		goto out;
 
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index 5e4f9ab1cf75..dde8dee83dc6 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -171,7 +171,8 @@ dpll_device_get(u64 clock_id, u32 dev_driver_id, struct module *module);
 void dpll_device_put(struct dpll_device *dpll);
 
 int dpll_device_register(struct dpll_device *dpll, enum dpll_type type,
-			 const struct dpll_device_ops *ops, void *priv);
+			 u32 capabilities, const struct dpll_device_ops *ops,
+			 void *priv);
 
 void dpll_device_unregister(struct dpll_device *dpll,
 			    const struct dpll_device_ops *ops, void *priv);
-- 
2.38.1
RE: [PATCH net-next v1 2/4] dpll: pass capabilities on device register
Posted by Loktionov, Aleksandr 10 months ago

> -----Original Message-----
> From: Kubalewski, Arkadiusz <arkadiusz.kubalewski@intel.com>
> Sent: Wednesday, April 9, 2025 5:26 PM
> To: donald.hunter@gmail.com; kuba@kernel.org; davem@davemloft.net;
> Dumazet, Eric <edumazet@google.com>; pabeni@redhat.com;
> horms@kernel.org; vadim.fedorenko@linux.dev; jiri@resnulli.us; Nguyen,
> Anthony L <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; andrew+netdev@lunn.ch;
> saeedm@nvidia.com; leon@kernel.org; tariqt@nvidia.com;
> jonathan.lemon@gmail.com; richardcochran@gmail.com; Loktionov,
> Aleksandr <aleksandr.loktionov@intel.com>; Olech, Milena
> <milena.olech@intel.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; intel-wired-
> lan@lists.osuosl.org; linux-rdma@vger.kernel.org; Kubalewski, Arkadiusz
> <arkadiusz.kubalewski@intel.com>
> Subject: [PATCH net-next v1 2/4] dpll: pass capabilities on device register
> 
> Add new argument on dpll device register, a capabilities bitmask of features
> supported by the dpll device.
> Provide capability value on dpll device dump.
> 
> Reviewed-by: Milena Olech <milena.olech@intel.com>
> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
>  drivers/dpll/dpll_core.c                       | 5 ++++-
>  drivers/dpll/dpll_core.h                       | 2 ++
>  drivers/dpll/dpll_netlink.c                    | 2 ++
>  drivers/net/ethernet/intel/ice/ice_dpll.c      | 2 +-
>  drivers/net/ethernet/mellanox/mlx5/core/dpll.c | 2 +-
>  drivers/ptp/ptp_ocp.c                          | 2 +-
>  include/linux/dpll.h                           | 3 ++-
>  7 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c index
> 20bdc52f63a5..563ac37c83ad 100644
> --- a/drivers/dpll/dpll_core.c
> +++ b/drivers/dpll/dpll_core.c
> @@ -342,6 +342,7 @@ dpll_device_registration_find(struct dpll_device *dpll,
>   * dpll_device_register - register the dpll device in the subsystem
>   * @dpll: pointer to a dpll
>   * @type: type of a dpll
> + * @capabilities: mask of available features supported by dpll
>   * @ops: ops for a dpll device
>   * @priv: pointer to private information of owner
>   *
> @@ -353,7 +354,8 @@ dpll_device_registration_find(struct dpll_device *dpll,
>   * * negative - error value
>   */
>  int dpll_device_register(struct dpll_device *dpll, enum dpll_type type,
> -			 const struct dpll_device_ops *ops, void *priv)
> +			 u32 capabilities, const struct dpll_device_ops *ops,
> +			 void *priv)
>  {
>  	struct dpll_device_registration *reg;
>  	bool first_registration = false;
> @@ -382,6 +384,7 @@ int dpll_device_register(struct dpll_device *dpll, enum
> dpll_type type,
>  	reg->ops = ops;
>  	reg->priv = priv;
>  	dpll->type = type;
> +	dpll->capabilities = capabilities;
>  	first_registration = list_empty(&dpll->registration_list);
>  	list_add_tail(&reg->list, &dpll->registration_list);
>  	if (!first_registration) {
> diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h index
> 2b6d8ef1cdf3..70bbafb9b635 100644
> --- a/drivers/dpll/dpll_core.h
> +++ b/drivers/dpll/dpll_core.h
> @@ -21,6 +21,7 @@
>   * @clock_id:		unique identifier (clock_id) of a dpll
>   * @module:		module of creator
>   * @type:		type of a dpll
> + * @capabilities:	capabilities of a dpll
>   * @pin_refs:		stores pins registered within a dpll
>   * @refcount:		refcount
>   * @registration_list:	list of registered ops and priv data of dpll owners
> @@ -31,6 +32,7 @@ struct dpll_device {
>  	u64 clock_id;
>  	struct module *module;
>  	enum dpll_type type;
> +	u32 capabilities;
>  	struct xarray pin_refs;
>  	refcount_t refcount;
>  	struct list_head registration_list;
> diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c index
> c130f87147fa..41aed0d29be2 100644
> --- a/drivers/dpll/dpll_netlink.c
> +++ b/drivers/dpll/dpll_netlink.c
> @@ -591,6 +591,8 @@ dpll_device_get_one(struct dpll_device *dpll, struct
> sk_buff *msg,
>  		return ret;
>  	if (nla_put_u32(msg, DPLL_A_TYPE, dpll->type))
>  		return -EMSGSIZE;
> +	if (nla_put_u32(msg, DPLL_A_CAPABILITIES, dpll->capabilities))
> +		return -EMSGSIZE;
> 
>  	return 0;
>  }
> diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c
> b/drivers/net/ethernet/intel/ice/ice_dpll.c
> index bce3ad6ca2a6..614a813c7772 100644
> --- a/drivers/net/ethernet/intel/ice/ice_dpll.c
> +++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
> @@ -2012,7 +2012,7 @@ ice_dpll_init_dpll(struct ice_pf *pf, struct ice_dpll
> *d, bool cgu,
>  	d->pf = pf;
>  	if (cgu) {
>  		ice_dpll_update_state(pf, d, true);
> -		ret = dpll_device_register(d->dpll, type, &ice_dpll_ops, d);
> +		ret = dpll_device_register(d->dpll, type, 0, &ice_dpll_ops, d);
>  		if (ret) {
>  			dpll_device_put(d->dpll);
>  			return ret;
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dpll.c
> b/drivers/net/ethernet/mellanox/mlx5/core/dpll.c
> index 1e5522a19483..0e430f93b047 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/dpll.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/dpll.c
> @@ -444,7 +444,7 @@ static int mlx5_dpll_probe(struct auxiliary_device
> *adev,
>  		goto err_free_mdpll;
>  	}
> 
> -	err = dpll_device_register(mdpll->dpll, DPLL_TYPE_EEC,
> +	err = dpll_device_register(mdpll->dpll, DPLL_TYPE_EEC, 0,
>  				   &mlx5_dpll_device_ops, mdpll);
>  	if (err)
>  		goto err_put_dpll_device;
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index
> b25635c5c745..87b9890d8ef2 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -4745,7 +4745,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct
> pci_device_id *id)
>  		goto out;
>  	}
> 
> -	err = dpll_device_register(bp->dpll, DPLL_TYPE_PPS, &dpll_ops, bp);
> +	err = dpll_device_register(bp->dpll, DPLL_TYPE_PPS, 0, &dpll_ops, bp);
>  	if (err)
>  		goto out;
> 
> diff --git a/include/linux/dpll.h b/include/linux/dpll.h index
> 5e4f9ab1cf75..dde8dee83dc6 100644
> --- a/include/linux/dpll.h
> +++ b/include/linux/dpll.h
> @@ -171,7 +171,8 @@ dpll_device_get(u64 clock_id, u32 dev_driver_id,
> struct module *module);  void dpll_device_put(struct dpll_device *dpll);
> 
>  int dpll_device_register(struct dpll_device *dpll, enum dpll_type type,
> -			 const struct dpll_device_ops *ops, void *priv);
> +			 u32 capabilities, const struct dpll_device_ops *ops,
> +			 void *priv);
> 
>  void dpll_device_unregister(struct dpll_device *dpll,
>  			    const struct dpll_device_ops *ops, void *priv);
> --
> 2.38.1