Create common DPLL configuration API
Subsystems (11)
Vadim Fedorenko
maintainercover Create common DPLL configuration API
Implement common API for clock/DPLL configuration and status reporting. The API utilises netlink interface as transport for commands and event notifications. This API aim to extend current pin configuration and make it flexible and easy to cover special configurations.
Netlink interface is based on ynl spec, it allows use of in-kernel tools/net/ynl/cli.py application to control the interface with properly formated command and json attribute strings. Here are few command examples of how it works with ice driver on supported NIC:
- dump dpll devices
$# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \
--dump device-get
[{'clock-id': 282574471561216,
'id': 0,
'lock-status': 'unlocked',
'mode': 'automatic',
'module-name': 'ice',
'type': 'eec'},
{'clock-id': 282574471561216,
'id': 1,
'lock-status': 'unlocked',
'mode': 'automatic',
'module-name': 'ice',
'type': 'pps'}]
- get single pin info:
$# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \
--do pin-get --json '{"pin-id":2}'
{'clock-id': 282574471561216,
'module-name': 'ice',
'pin-board-label': 'C827_0-RCLKA',
'pin-dpll-caps': 6,
'pin-frequency': 1953125,
'pin-id': 2,
'pin-parenti-device': [{'id': 0,
'pin-direction': 'input',
'pin-prio': 11,
'pin-state': 'selectable'},
{'id': 1,
'pin-direction': 'input',
'pin-prio': 9,
'pin-state': 'selectable'}],'pin-type': 'mux'}
- set pin's state on dpll:
$# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \
--do pin-set --json '{"pin-id":2, "pin-parent-device":{"id":1, "pin-state":2}}'
- set pin's prio on dpll:
$# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \
--do pin-set --json '{"pin-id":2, "pin-parent-device":{"id":1, "pin-prio":4}}'
- set pin's state on parent pin:
$# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \
--do pin-set --json '{"pin-id":13, \
"pin-parent-pin":{"pin-id":2, "pin-state":1}}'v8 RFC -> v0:
- Merge header patch into the patches where the actual functions are implemented
- Address comments from previous reviews
- Per patch change log contains more details
v8 -> v9:
[00/10] Create common DPLL configuration API
- update examples to reflect new pin-parent nest split
[01/10] dpll: documentation on DPLL subsystem interface
- fix docs build warnings
- separate netlink command/attribute list
- replace enum description with uapi header
- add brief explanation what is a DPLL
- fix EOPNOTSUPP typo
- fix typo .state_get -> .state_on_dpll_get
[02/10] dpll: spec: Add Netlink spec in YAML
- regenerate policy max values
- add missing enum descriptions
- split pin-parent nest:
- pin-parent-device - for configuration of pin-device tuple
- pin-parent-pin - for configuration od pin-pin tuple
- fix typos:
- s/working-modes/working modes/
- s/differentiate/differentiates/
- s/valid input, auto selected by dpll/input pin auto selected by dpll/
- remove FREERUN and HOLDOVER modes
[03/10] dpll: core: Add DPLL framework base functions
- fix description in spdx header.
- remove refcount check if refcount was already set
- do not validate dpll ptr in dpll_device_put(..)
- fix return -ENOMEM on failed memory alloc
- do not validate pin ptr in dpll_pin_put(..)
- return -EINVAL in case of module/clock_id mismatch
- do not {} around one-line xa_for_each() macro
- move dpll_<x>_registration structs to dpll_core.c
- rephrase doc comment on device and pin id struct members
- remove ref in case of memory allocation fail
- check for required ops on pin/device registration
- mark pin with DPLL_REGISTERED once pin is registered with dpll
[04/10] dpll: netlink: Add DPLL framework base functions
- fix pin-id-get/device-id-get behavior
- reshuffle order of functions
- avoid forward declarations
- functions for adding pin/device handle next to each other
- pass ops callback return values to the user
- remove dpll_cmd_pin_fill_details(..) function, merge the code into __dpll_cmd_pin_dump_one(..)
- rename __dpll_cmd_pin_dump_one() to dpll_cmd_pin_get_one()
- use WARN_ON macro when dpll ref is missing
- remove redundant pin's dpll list not empty check
- remove double spaces inside if statement
- add extack message when set command is not possible
- do not return error when callback is not required
- WARN_ON missing ops moved to dpll_core.c
- use DPLL_REGISTERED if pin was registered with dpll
- fix pin-id-get return and add extack errors
- fix device-id-get return and add extack errors
- drop pointless init of variables
- add macro for iterating over marked pins/devices
- move dpll_set_from_nlattr() for consistent order
- use GENL_REQ_ATTR_CHECK() for checking attibute presence
- fill extack if pin/device was not found
- drop pointless init of variables
- WARN_ON if dpll not registered on send event
- rename goto labels to indicate error path
- fix docs
- drop pointless init of variables
- verify pin in notify with a mark
- prevent ops->mode_set call if missing callback
- move static dpll_msg_add_pin_handle() from pin<->netdev patch
- split pin-parent nest:
- pin-parent-device - for configuration of pin-device tuple
- pin-parent-pin - for configuration od pin-pin tuple
[06/10] netdev: expose DPLL pin handle for netdevice
- net_device->dpll_pin is only valid if IS_ENABLED(CONFIG_DPLL) fix the code in net/core/rtnetlink.c to respect that.
- move dpll_msg_add_pin_handle to "dpll: netlink" patch + export the function with this patch
[07/10] ice: add admin commands to access cgu configuration
- rename MAX_NETLIST_SIZE -> ICE_MAX_NETLIST_SIZE
- simplify function: s64 convert_s48_to_s64(s64 signed_48)
- do not assign 0 to field that is already 0
[08/10] ice: implement dpll interface to control cgu
- drop pointless 0 assignement
- ice_dpll_init(..) returns void instead of int
- fix context description of the functions
- fix ice_dpll_init(..) traces
- fix use package_label instead pf board_label for rclk pin
- be consistent on cgu presence naming
- remove indent in ice_dpll_deinit(..)
- remove unused struct field lock_err_num
- fix kworker resched behavior
- remove debug log from ice_dpll_deinit_worker(..)
- reorder ice internal functions
- release resources directly on error path
- remove redundant NULL checks when releasing resources
- do not assign NULL to pointers after releasing resources
- simplify variable assignement
- fix 'int ret;' declarations across the ice_dpll.c
- remove leftover ice_dpll_find(..)
- get pf pointer from dpll_priv without type cast
- improve error reporting
- fix documentation
- fix ice_dpll_update_state(..) flow
- fix return in case out of range prio set
v7 -> v8:
[0/10] Create common DPLL configuration API
- reorder the patches in patch series
- split patch "[RFC PATCH v7 2/8] dpll: Add DPLL framework base functions" into 3 smaller patches for easier review:
- [03/10] dpll: core: Add DPLL framework base functions
- [04/10] dpll: netlink: Add DPLL framework base functions
- [05/10] dpll: api header: Add DPLL framework base
- add cli.py usage examples in commit message
[01/10] dpll: documentation on DPLL subsystem interface
- fix DPLL_MODE_MANUAL documentation
- remove DPLL_MODE_NCO
- remove DPLL_LOCK_STATUS_CALIBRATING
- add grepability Use full names of commands, attributes and values of dpll subsystem in the documentation
- align documentation with changes introduced in v8
- fix typos
- fix phrases to better show the intentions
- move dpll.rst to Documentation/driver-api/
[02/10] dpll: spec: Add Netlink spec in YAML
- remove unspec attribute values
- add 10 KHZ and 77,5 KHZ frequency defines
- fix documentation
- remove assigned values from subset attributes
- reorder dpll attributes
- fix device nested attribute usage, device get is not used on pin-get
- temperature with 3 digit float precision
- remove enum from subset definitions
- move pin-direction to pin-dpll tuple/subset
- remove DPLL_MODE_NCO
- remove DPLL_LOCK_STATUS_CALIBRATING
- fix naming scheme od notification interface functions
- separate notifications for pins
- rename attribute enum name: dplla -> dpll_a
- rename pin-idx to pin-id
- remove attributes: pin-parent-idx, device
- replace bus-name and dev-name attributes with module-name
- replace pin-label with 3 new attributes: pin-board-label, pin-panel-label, pin-package-label
- add device-id-get and pin-id-get commands
- remove rclk-dev-name atribute
- rename DPLL_PIN_DIRECTION_SOURCE -> DPLL_PIN_DIRECTION_INPUT
[03/10] dpll: core: Add DPLL framework base functions [04/10] dpll: netlink: Add DPLL framework base functions [05/10] dpll: api header: Add DPLL framework base
- remove unspec attributes after removing from dpll netlink spec
- move pin-direction to pin-dpll tuple
- pass parent_priv on state_on_pin_<get/set>
- align with new notification definitions from netlink spec
- use separated notifications for dpll pins and devices
- format notification messages as corresponding get netlink commands
- rename pin-idx to pin-id
- remove attributes pin-parent-idx, device
- use DPLL_A_PIN_PARENT to hold information on parent pin or dpll device
- refactor lookup for pins and dplls for dpll subsystem
- replace bus-name, dev-name with module-name
- replace pin-label with 3 new attributes: pin-board-label, pin-panel-label, pin-package-label
- add device-id-get and pin-id-get commands
- rename dpll_xa_lock to dpll_lock
- improve doxygen in dpll_core.c
- remove unused parent and dev fields from dpll_device struct
- use u32 for pin_idx in dpll_pin_alloc
- use driver provided pin properties struct
- verify pin/dpll owner on registering pin
- remove const arg modifier for helper _priv functions
- remove function declaration _get_by_name()
- update SPDX headers
- parse netlink set attributes with nlattr array
- remove rclk-dev-name attribute
- remove device pointer from dpll_pin_register/dpll_device_register
- remove redundant doxygen from dpll header
- use module_name() to get name of module
- add missing/remove outdated kdocs
- fix call frequency_set only if available
- fix call direction_set only for pin-dpll tuple
[06/10] netdev: expose DPLL pin handle for netdevice
- rebased on top of v8 changes
- use dpll_msg_add_pin_handle() in dpll_pin_find_from_nlattr() and dpll_msg_add_pin_parents()
- fixed handle to use DPLL_A_PIN_ID and removed temporary comments
- added documentation record for dpll_pin pointer
- fixed compilation of net/core/dev.c when CONFIG_DPLL is not enabled
- adjusted patch description a bit
[07/10] ice: add admin commands to access cgu configuration
- Remove unspec attributes after removing from dpll netlink spec.
[08/10] ice: implement dpll interface to control cgu
- remove unspec attributes
- do not store pin flags received in set commands
- use pin state field to provide pin state to the caller
- remove include of uapi header
- remove redundant check against null arguments
- propagate lock function return value to the caller
- use switch case instead of if statements
- fix dev_dbg to dev_err for error cases
- fix dpll/pin lookup on dpll subsytem callbacks
- fix extack of dpll subsystem callbacks
- remove double negation and variable cast
- simplify ice_dpll_pin_state_set function
- pass parent_priv on state_on_pin_<get/set>
- remove parent hw_idx lookup
- fix use const qualifier for dpll/dpll_pin ops
- fix IS_ERR macros usage in ice_dpll
- add notify previous source state change
- fix mutex locking on releasing pins
- use '|=' instead of '+=' when modifing capabilities field
- rename ice_dpll_register_pins function
- clock_id function to return clock ID on the stack instead of using an output variable
- DPLL_LOCK_STATUS_CALIBRATING was removed, return:
DPLL_LOCK_STATUS_LOCKED - if dpll was locked DPLL_LOCK_STATUS_LOCKED_HO_ACQ - if dpll was locked and holdover is acquired
- propagate and use dpll_priv to obtain pf pointer in corresponding functions.
- remove null check for pf pointer
- adapt to dpll: core: fix notification scheme
- expose pf related pin to corresponding netdevice
- fix dpll init error path
- fix dpll pins naming scheme source -> input
- replace pin-label with pin-board-label
- dpll remove parent and dev fields from dpll_device
- remove device pointer from dpll_pin_register/dpll_device_register
- rename DPLL_PIN_DIRECTION_SOURCE -> DPLL_PIN_DIRECTION_INPUT
[09/10] ptp_ocp: implement DPLL ops
- replace pin-label with pin-board-label
- dpll remove parent and dev fields from dpll_device
- remove device pointer from dpll_pin_register/dpll_device_register
- rename DPLL_PIN_DIRECTION_SOURCE -> DPLL_PIN_DIRECTION_INPUT
[10/10] mlx5: Implement SyncE support using DPLL infrastructure
- rebased on top of v8 changes:
- changed notification scheme
- no need to fill pin label
- implemented locked_ho_acq status
- rename DPLL_PIN_DIRECTION_SOURCE -> DPLL_PIN_DIRECTION_INPUT
- remove device pointer from dpll_pin_register/dpll_device_register
- fixed MSEES register writes
- adjusted pin state and lock state values reported
- fixed a white space issue
v6 -> v7:
* YAML spec:
- remove nested 'pin' attribute
- clean up definitions on top of the latest changes
* pin object:
- pin xarray uses id provided by the driver
- remove usage of PIN_IDX_INVALID in set function
- source_pin_get() returns object instead of idx
- fixes in frequency support API
* device and pin operations are const now
* small fixes in naming in Makefile and in the functions
* single mutex for the subsystem to avoid possible ABBA locks
* no special *_priv() helpers anymore, private data is passed as void*
* no netlink filters by name anymore, only index is supported
* update ptp_ocp and ice drivers to follow new API version
* add mlx5e driver as a new customer of the subsystem
v5 -> v6:
* rework pin part to better fit shared pins use cases
* add YAML spec to easy generate user-space apps
* simple implementation in ptp_ocp is back again
v4 -> v5:
* fix code issues found during last reviews:
- replace cookie with clock id
- follow one naming schema in dpll subsys
- move function comments to dpll_core.c, fix exports
- remove single-use helper functions
- merge device register with alloc
- lock and unlock mutex on dpll device release
- move dpll_type to uapi header
- rename DPLLA_DUMP_FILTER to DPLLA_FILTER
- rename dpll_pin_state to dpll_pin_mode
- rename DPLL_MODE_FORCED to DPLL_MODE_MANUAL
- remove DPLL_CHANGE_PIN_TYPE enum value
* rewrite framework once again (Arkadiusz)
- add clock class:
Provide userspace with clock class value of DPLL with dpll device dump netlink request. Clock class is assigned by driver allocating a dpll device. Clock class values are defined as specified in:
ITU-T G.8273.2/Y.1368.2 recommendation.
- dpll device naming schema use new pattern:
"dpll_%s_%d_%d", where:
- %s - dev_name(parent) of parent device,
- %d (1) - enum value of dpll type,
- %d (2) - device index provided by parent device.
- new muxed/shared pin registration:
Let the kernel module to register a shared or muxed pin without finding it or its parent. Instead use a parent/shared pin description to find correct pin internally in dpll_core, simplifing a dpll API
* Implement complex DPLL design in ice driver (Arkadiusz)
* Remove ptp_ocp driver from the series for now
v3 -> v4:
* redesign framework to make pins dynamically allocated (Arkadiusz)
* implement shared pins (Arkadiusz)
v2 -> v3:
* implement source select mode (Arkadiusz)
* add documentation
* implementation improvements (Jakub)
v1 -> v2:
* implement returning supported input/output types
* ptp_ocp: follow suggestions from Jonathan
* add linux-clk mailing list
v0 -> v1:
* fix code style and errors
* add linux-arm mailing list
Arkadiusz Kubalewski (3):
dpll: spec: Add Netlink spec in YAML
ice: add admin commands to access cgu configuration
ice: implement dpll interface to control cgu
Jiri Pirko (2):
netdev: expose DPLL pin handle for netdevice
mlx5: Implement SyncE support using DPLL infrastructure
Vadim Fedorenko (5):
dpll: documentation on DPLL subsystem interface
dpll: core: Add DPLL framework base functions
dpll: netlink: Add DPLL framework base functions
dpll: api header: Add DPLL framework base functions
ptp_ocp: implement DPLL ops
Arkadiusz Kubalewski (4):
tools: ynl-gen: fix enum index in _decode_enum(..)
tools: ynl-gen: fix parse multi-attr enum attribute
ice: add admin commands to access cgu configuration
ice: implement dpll interface to control cgu
Jiri Pirko (2):
netdev: expose DPLL pin handle for netdevice
mlx5: Implement SyncE support using DPLL infrastructure
Vadim Fedorenko (5):
dpll: documentation on DPLL subsystem interface
dpll: spec: Add Netlink spec in YAML
dpll: core: Add DPLL framework base functions
dpll: netlink: Add DPLL framework base functions
ptp_ocp: implement DPLL ops
Documentation/driver-api/dpll.rst | 431 ++++ Documentation/driver-api/index.rst | 1 + Documentation/netlink/specs/dpll.yaml | 475 ++++ MAINTAINERS | 11 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/dpll/Kconfig | 7 + drivers/dpll/Makefile | 9 + drivers/dpll/dpll_core.c | 799 +++++++ drivers/dpll/dpll_core.h | 90 + drivers/dpll/dpll_netlink.c | 1286 +++++++++++ drivers/dpll/dpll_netlink.h | 17 + drivers/dpll/dpll_nl.c | 163 ++ drivers/dpll/dpll_nl.h | 51 + drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 5 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 245 +- drivers/net/ethernet/intel/ice/ice_common.c | 467 ++++ drivers/net/ethernet/intel/ice/ice_common.h | 44 + drivers/net/ethernet/intel/ice/ice_dpll.c | 2053 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_dpll.h | 104 + drivers/net/ethernet/intel/ice/ice_lib.c | 17 +- drivers/net/ethernet/intel/ice/ice_main.c | 7 + drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 419 ++++ drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 231 ++ drivers/net/ethernet/intel/ice/ice_type.h | 1 + .../net/ethernet/mellanox/mlx5/core/Kconfig | 8 + .../net/ethernet/mellanox/mlx5/core/Makefile | 3 + drivers/net/ethernet/mellanox/mlx5/core/dev.c | 17 + .../net/ethernet/mellanox/mlx5/core/dpll.c | 432 ++++ drivers/ptp/Kconfig | 1 + drivers/ptp/ptp_ocp.c | 366 ++- include/linux/dpll.h | 160 ++ include/linux/mlx5/driver.h | 2 + include/linux/mlx5/mlx5_ifc.h | 59 +- include/linux/netdevice.h | 20 + include/uapi/linux/dpll.h | 186 ++ include/uapi/linux/if_link.h | 2 + net/core/dev.c | 22 + net/core/rtnetlink.c | 35 + tools/net/ynl/lib/ynl.py | 18 +- 42 files changed, 8194 insertions(+), 77 deletions(-) create mode 100644 Documentation/driver-api/dpll.rst create mode 100644 Documentation/netlink/specs/dpll.yaml create mode 100644 drivers/dpll/Kconfig create mode 100644 drivers/dpll/Makefile create mode 100644 drivers/dpll/dpll_core.c create mode 100644 drivers/dpll/dpll_core.h create mode 100644 drivers/dpll/dpll_netlink.c create mode 100644 drivers/dpll/dpll_netlink.h create mode 100644 drivers/dpll/dpll_nl.c create mode 100644 drivers/dpll/dpll_nl.h create mode 100644 drivers/net/ethernet/intel/ice/ice_dpll.c create mode 100644 drivers/net/ethernet/intel/ice/ice_dpll.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/dpll.c create mode 100644 include/linux/dpll.h create mode 100644 include/uapi/linux/dpll.h
Signature · 1 line
2.27.0
Vadim Fedorenko
maintainerPATCH 1/11 tools: ynl-gen: fix enum index in _decode_enum(..)
From: Arkadiusz Kubalewski <[email protected]>
Remove wrong index adjustement, which is leftover from adding support for sparse enums.enum.entries_by_val() function shall not subtract the start-value, as it is indexed with real enum value.
--- tools/net/ynl/lib/ynl.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tools/net/ynl/lib/ynl.py +2 -4
@@ -420,16 +420,14 @@ class YnlFamily(SpecFamily): def _decode_enum(self, rsp, attr_spec): raw = rsp[attr_spec['name']] enum = self.consts[attr_spec['enum']] - i = attr_spec.get('value-start', 0) if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']: value = set() while raw: if raw & 1: - value.add(enum.entries_by_val[i].name) + value.add(enum.entries_by_val[raw & 1].name) raw >>= 1 - i += 1 else: - value = enum.entries_by_val[raw - i].name + value = enum.entries_by_val[raw].name rsp[attr_spec['name']] = value def _decode_binary(self, attr, attr_spec):
Signature · 1 line
2.27.0
Re: [PATCH net-next 01/11] tools: ynl-gen: fix enum index in _decode_enum(..)
Quoted 3 lines · Thu, Jul 20, 2023 at 11:18:53AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
Remove wrong index adjustement, which is leftover from adding
s/adjustement/adjustment/
Quoted 7 lines
support for sparse enums.
enum.entries_by_val()function shall not subtract the start-value, as it is indexed with real enum value.Fixes c311aaa74ca1 ("tools: ynl: fix enum-as-flags in the generic CLI")Signed-off-by Arkadiusz Kubalewski <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>
Kubalewski, Arkadiusz
maintainerRE: [PATCH net-next 01/11] tools: ynl-gen: fix enum index in _decode_enum(..)
Quoted 11 lines
-----Original Message-----
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 3:40 PMQuoted 3 lines · Thu, Jul 20, 2023 at 11:18:53AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
Remove wrong index adjustement, which is leftover from adding
s/adjustement/adjustment/
Sure will fix,
Although those "tools: ynl" patches were not intended to be a part of dpll Series, they are being discussed on the other thread:
https://lore.kernel.org/netdev/[email protected]/
I think Vadim have sent them, because I included them in the branch candidate for next version, seems was not clear enough on that..
I think we can skip them for next submission.
Thank you!
Arkadiusz
Quoted 11 lines
Quoted 9 lines
support for sparse enums.
enum.entries_by_val()function shall not subtract the start-value, as it is indexed with real enum value.Fixes c311aaa74ca1 ("tools: ynl: fix enum-as-flags in the genericCLI")
Signed-off-by Arkadiusz Kubalewski <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>Reviewed-by Jiri Pirko <[email protected]>
Vadim Fedorenko
maintainerRe: [PATCH net-next 01/11] tools: ynl-gen: fix enum index in _decode_enum(..)
Quoted 12 lines · Arkadiusz
Quoted 11 lines
-----Original Message-----
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 3:40 PMQuoted 3 lines · Thu, Jul 20, 2023 at 11:18:53AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
Remove wrong index adjustement, which is leftover from adding
s/adjustement/adjustment/
Quoted 8 lines
Sure will fix,
Although those "tools: ynl" patches were not intended to be a part of dpll Series, they are being discussed on the other thread:
https://lore.kernel.org/netdev/[email protected]/I think Vadim have sent them, because I included them in the branch candidate for next version, seems was not clear enough on that..
I think we can skip them for next submission.
Yeah, I just realised that these patches have been sent earlier as separate series and are still under review. Once they are committed I'll remove them from DPLL series, but for now they are needed for spec generation of DPLL yaml, so it's good to have them anyway.
Quoted 15 lines
Thank you!
ArkadiuszQuoted 11 lines
Quoted 9 lines
support for sparse enums.
enum.entries_by_val()function shall not subtract the start-value, as it is indexed with real enum value.Fixes c311aaa74ca1 ("tools: ynl: fix enum-as-flags in the genericCLI")
Signed-off-by Arkadiusz Kubalewski <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>Reviewed-by Jiri Pirko <[email protected]>
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Vadim Fedorenko
maintainerPATCH 2/11 tools: ynl-gen: fix parse multi-attr enum attribute
In reply to Vadim FedorenkoFrom: Arkadiusz Kubalewski <[email protected]>
When attribute is enum type and marked as multi-attr, the netlink respond is not parsed, fails with stack trace:
Traceback (most recent call last):
File "/net-next/tools/net/ynl/./test.py", line 520, in <module>
main()
File "/net-next/tools/net/ynl/./test.py", line 488, in main
dplls=dplls_get(282574471561216) File "/net-next/tools/net/ynl/./test.py", line 48, in dplls_get
reply=act(args)
File "/net-next/tools/net/ynl/./test.py", line 41, in act
reply = ynl.dump(args.dump, attrs)
File "/net-next/tools/net/ynl/lib/ynl.py", line 598, in dump
return self._op(method, vals, dump=True)
File "/net-next/tools/net/ynl/lib/ynl.py", line 584, in _op
rsp_msg = self._decode(gm.raw_attrs, op.attr_set.name)
File "/net-next/tools/net/ynl/lib/ynl.py", line 451, in _decode
self._decode_enum(rsp, attr_spec)
File "/net-next/tools/net/ynl/lib/ynl.py", line 408, in _decode_enum
value = enum.entries_by_val[raw].name
TypeError: unhashable type: 'list'
error: 1
Redesign _decode_enum(..) to take a enum int value and translate it to either a bitmask or enum name as expected.
--- tools/net/ynl/lib/ynl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/net/ynl/lib/ynl.py +6 -6
@@ -417,8 +417,7 @@ class YnlFamily(SpecFamily): pad = b'\x00' * ((4 - len(attr_payload) % 4) % 4) return struct.pack('HH', len(attr_payload) + 4, nl_type) + attr_payload + pad - def _decode_enum(self, rsp, attr_spec): - raw = rsp[attr_spec['name']] + def _decode_enum(self, raw, attr_spec): enum = self.consts[attr_spec['enum']] if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']: value = set()
@@ -428,7 +427,7 @@ class YnlFamily(SpecFamily): raw >>= 1 else: value = enum.entries_by_val[raw].name - rsp[attr_spec['name']] = value + return value def _decode_binary(self, attr, attr_spec): if attr_spec.struct_name:
@@ -436,7 +435,7 @@ class YnlFamily(SpecFamily): decoded = attr.as_struct(members) for m in members: if m.enum: - self._decode_enum(decoded, m) + decoded[m] = self._decode_enum(decoded[m], m) elif attr_spec.sub_type: decoded = attr.as_c_array(attr_spec.sub_type) else:
@@ -464,6 +463,9 @@ class YnlFamily(SpecFamily): else: raise Exception(f'Unknown {attr_spec["type"]} with name {attr_spec["name"]}') + if 'enum' in attr_spec: + decoded = self._decode_enum(int.from_bytes(attr.raw, "big"), attr_spec) + if not attr_spec.is_multi: rsp[attr_spec['name']] = decoded elif attr_spec.name in rsp:
@@ -471,8 +473,6 @@ class YnlFamily(SpecFamily): else: rsp[attr_spec.name] = [decoded] - if 'enum' in attr_spec: - self._decode_enum(rsp, attr_spec) return rsp def _decode_extack_path(self, attrs, attr_set, offset, target):
Signature · 1 line
2.27.0
Vadim Fedorenko
maintainerPATCH 3/11 dpll: documentation on DPLL subsystem interface
In reply to Vadim FedorenkoAdd documentation explaining common netlink interface to configure DPLL devices and monitoring events. Common way to implement DPLL device in a driver is also covered.
---
RFC v9->v0:
- fix muxed get-pin command respond example
- fix typos
- describe DPLL_MODE_FREERUN
v8->v9:
- fix docs build warnings
- separate netlink command/attribute list
- replace enum description with uapi header
- add brief explanation what is a DPLL
- fix EOPNOTSUPP typo
- fix typo .state_get -> .state_on_dpll_get
Documentation/driver-api/dpll.rst | 431 +++++++++++++++++++++++++++++ Documentation/driver-api/index.rst | 1 + 2 files changed, 432 insertions(+) create mode 100644 Documentation/driver-api/dpll.rst
Documentation/driver-api/dpll.rst new file +431 -0
@@ -0,0 +1,431 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=============================== +The Linux kernel dpll subsystem +=============================== + +DPLL +==== + +PLL - Phase Locked Loop is an electronic circuit which syntonizes clock +signal of a device with an external clock signal. Effectively enabling +device to run on the same clock signal beat as provided on a PLL input. + +DPLL - Digital Phase Locked Loop is am integrated circuit which in +addition to plain PLL behavior incorporates a digital phase detector +and may have digital divider in the loop. As a result, the frequency on +DPLL's input and output may be configurable. + +Subsystem +========= + +The main purpose of dpll subsystem is to provide general interface +to configure devices that use any kind of Digital PLL and could use +different sources of input signal to synchronize to, as well as +different types of outputs. +The main interface is NETLINK_GENERIC based protocol with an event +monitoring multicast group defined. + +Device object +============= + +Single dpll device object means single Digital PLL circuit and bunch of +connected pins. +It reports the supported modes of operation and current status to the +user in response to the `do` request of netlink command +``DPLL_CMD_DEVICE_GET`` and list of dplls registered in the subsystem +with `dump` netlink request of the same command. +Changing the configuration of dpll device is done with `do` request of +netlink ``DPLL_CMD_DEVICE_SET`` command. +A device handle is ``DPLL_A_ID``, it shall be provided to get or set +configuration of particular device in the system. It can be obtained +with a ``DPLL_CMD_DEVICE_GET`` `dump` request or +a ``DPLL_CMD_DEVICE_ID_GET`` `do` request, where the one must provide +attributes that result in single device match. + +Pin object +========== + +A pin is amorphic object which represents either input or output, it +could be internal component of the device, as well as externally +connected. +The number of pins per dpll vary, but usually multiple pins shall be +provided for a single dpll device. +Pin's properties, capabilities and status is provided to the user in +response to `do` request of netlink ``DPLL_CMD_PIN_GET`` command. +It is also possible to list all the pins that were registered in the +system with `dump` request of ``DPLL_CMD_PIN_GET`` command. +Configuration of a pin can be changed by `do` request of netlink +``DPLL_CMD_PIN_SET`` command. +Pin handle is a ``DPLL_A_PIN_ID``, it shall be provided to get or set +configuration of particular pin in the system. It can be obtained with +``DPLL_CMD_PIN_GET`` `dump` request or ``DPLL_CMD_PIN_ID_GET`` `do` +request, where user provides attributes that result in single pin match. + +Pin selection +============= + +In general, selected pin (the one which signal is driving the dpll +device) can be obtained from ``DPLL_A_PIN_STATE`` attribute, and only +one pin shall be in ``DPLL_PIN_STATE_CONNECTED`` state for any dpll +device. + +Pin selection can be done either manually or automatically, depending +on hardware capabilities and active dpll device work mode +(``DPLL_A_MODE`` attribute). The consequence is that there are +differences for each mode in terms of available pin states, as well as +for the states the user can request for a dpll device. + +In manual mode (``DPLL_MODE_MANUAL``) the user can request or receive +one of following pin states: + +- ``DPLL_PIN_STATE_CONNECTED`` - the pin is used to drive dpll device +- ``DPLL_PIN_STATE_DISCONNECTED`` - the pin is not used to drive dpll + device + +In automatic mode (``DPLL_MODE_AUTOMATIC``) the user can request or +receive one of following pin states: + +- ``DPLL_PIN_STATE_SELECTABLE`` - the pin shall be considered as valid + input for automatic selection algorithm +- ``DPLL_PIN_STATE_DISCONNECTED`` - the pin shall be not considered as + a valid input for automatic selection algorithm + +In automatic mode (``DPLL_MODE_AUTOMATIC``) the user can only receive +pin state ``DPLL_PIN_STATE_CONNECTED`` once automatic selection +algorithm locks a dpll device with one of the inputs. + +For other dpll device operating modes there is no pin selection +mechanics. + +Shared pins +=========== + +A single pin object can be attached to multiple dpll devices. +Then there are two groups of configuration knobs: + +1) Set on a pin - the configuration affects all dpll devices pin is + registered to (i.e. ``DPLL_A_PIN_FREQUENCY``), +2) Set on a pin-dpll tuple - the configuration affects only selected + dpll device (i.e. ``DPLL_A_PIN_PRIO``, ``DPLL_A_PIN_STATE``, + ``DPLL_A_PIN_DIRECTION``). + +MUX-type pins +============= + +A pin can be MUX-type, it aggregates child pins and serves as a pin +multiplexer. One or more pins are registered with MUX-type instead of +being directly registered to a dpll device. +Pins registered with a MUX-type pin provide user with additional nested +attribute ``DPLL_A_PIN_PARENT`` for each parent they were registered +with. +If a pin was registered with multiple parent pins, they behave like a +multiple output multiplexer. In this case output of a +``DPLL_CMD_PIN_GET`` would contain multiple pin-parent nested +attributes with current state related to each parent, like:: + + 'pin': [{ + {'clock-id': 282574471561216, + 'module-name': 'ice', + 'pin-dpll-caps': 4, + 'pin-id': 13, + 'pin-parent': [{'pin-id': 2, 'pin-state': 'connected'}, + {'pin-id': 3, 'pin-state': 'disconnected'}], + 'pin-type': 'synce-eth-port'} + }] + +Only one child pin can provide its signal to the parent MUX-type pin at +a time, the selection is done by requesting change of a child pin state +on desired parent, with the use of ``DPLL_A_PIN_PARENT`` nested +attribute. Example of netlink `set state on parent pin` message format: + + ====================== ============================================= + ``DPLL_A_PIN_ID`` child pin id + ``DPLL_A_PIN_PARENT`` nested attribute for requesting configuration + related to parent pin + ``DPLL_A_PIN_ID`` parent pin id + ``DPLL_A_PIN_STATE`` requested pin state on parent + ====================== ============================================= + +Pin priority +============ + +Some devices might offer a capability of automatic pin selection mode +(enum value ``DPLL_MODE_AUTOMATIC`` of ``DPLL_A_MODE`` attribute). +Usually, automatic selection is performed on the hardware level, which +means only pins directly connected to the dpll can be used for automatic +input pin selection. +In automatic selection mode, the user cannot manually select a input +pin for the device, instead the user shall provide all directly +connected pins with a priority ``DPLL_A_PIN_PRIO``, the device would +pick a highest priority valid signal and use it to control the DPLL +device. Example of netlink `set priority on parent pin` message format: + + ===================== ============================================= + ``DPLL_A_PIN_ID`` child pin id + ``DPLL_A_PIN_PARENT`` nested attribute for requesting configuration + related to parent pin + ``DPLL_A_ID`` parent dpll id + ``DPLL_A_PIN_PRIO`` requested pin prio on parent dpll + ===================== ============================================= + +Child pin of MUX-type is not capable of automatic input pin selection, +in order to configure a input of a MUX-type pin, the user needs to +request desired pin state of the child pin on the parent pin, +as described in the ``MUX-type pins`` chapter. + +Configuration commands group +============================ + +Configuration commands are used to get information about registered +dpll devices (and pins), as well as set configuration of device or pins. +As dpll devices must be abstracted and reflect real hardware, +there is no way to add new dpll device via netlink from user space and +each device should be registered by its driver. + +All netlink commands require ``GENL_ADMIN_PERM``. This is to prevent +any spamming/DoS from unauthorized userspace applications. + +List of netlink commands with possible attributes +================================================= + +All constants identifying command types use a ``DPLL_CMD_`` prefix and +suffix according to command purpose. All attributes use a ``DPLL_A_`` +prefix and suffix according to attribute purpose: + + ==================================== ================================= + ``DPLL_CMD_DEVICE_ID_GET`` command to get device ID + ``DPLL_A_MODULE_NAME`` attr module name of registerer + ``DPLL_A_CLOCK_ID`` attr Unique Clock Identifier + (EUI-64), as defined by the + IEEE 1588 standard + ``DPLL_A_TYPE`` attr type of dpll device + ==================================== ================================= + + ==================================== ================================= + ``DPLL_CMD_DEVICE_GET`` command to get device info or + dump list of available devices + ``DPLL_A_ID`` attr unique dpll device ID + ``DPLL_A_MODULE_NAME`` attr module name of registerer + ``DPLL_A_CLOCK_ID`` attr Unique Clock Identifier + (EUI-64), as defined by the + IEEE 1588 standard + ``DPLL_A_MODE`` attr selection mode + ``DPLL_A_MODE_SUPPORTED`` attr available selection modes + ``DPLL_A_LOCK_STATUS`` attr dpll device lock status + ``DPLL_A_TEMP`` attr device temperature info + ``DPLL_A_TYPE`` attr type of dpll device + ==================================== ================================= + + ==================================== ================================= + ``DPLL_CMD_DEVICE_SET`` command to set dpll device config + ``DPLL_A_ID`` attr internal dpll device index + ``DPLL_A_MODE`` attr selection mode to configure + ==================================== ================================= + + ==================================== ================================= + ``DPLL_CMD_PIN_ID_GET`` command to get pin ID + ``DPLL_A_MODULE_NAME`` attr module name of registerer + ``DPLL_A_CLOCK_ID`` attr Unique Clock Identifier + (EUI-64), as defined by the + IEEE 1588 standard + ``DPLL_A_PIN_BOARD_LABEL`` attr pin board label provided + by registerer + ``DPLL_A_PIN_PANEL_LABEL`` attr pin panel label provided + by registerer + ``DPLL_A_PIN_PACKAGE_LABEL`` attr pin package label provided + by registerer + ``DPLL_A_PIN_TYPE`` attr type of a pin + ==================================== ================================= + + ==================================== ================================= + ``DPLL_CMD_PIN_GET`` command to get pin info or dump + list of available pins + ``DPLL_A_PIN_ID`` attr unique a pin ID + ``DPLL_A_MODULE_NAME`` attr module name of registerer + ``DPLL_A_CLOCK_ID`` attr Unique Clock Identifier + (EUI-64), as defined by the + IEEE 1588 standard + ``DPLL_A_PIN_BOARD_LABEL`` attr pin board label provided + by registerer + ``DPLL_A_PIN_PANEL_LABEL`` attr pin panel label provided + by registerer + ``DPLL_A_PIN_PACKAGE_LABEL`` attr pin package label provided + by registerer + ``DPLL_A_PIN_TYPE`` attr type of a pin + ``DPLL_A_PIN_DIRECTION`` attr direction of a pin + ``DPLL_A_PIN_FREQUENCY`` attr current frequency of a pin + ``DPLL_A_PIN_FREQUENCY_SUPPORTED`` nested attr provides supported + frequencies + ``DPLL_A_PIN_ANY_FREQUENCY_MIN`` attr minimum value of frequency + ``DPLL_A_PIN_ANY_FREQUENCY_MAX`` attr maximum value of frequency + ``DPLL_A_PIN_PARENT_DEVICE`` nested attr for each parent device + the pin is connected with + ``DPLL_A_ID`` attr provided if parent is dpll + device + ``DPLL_A_PIN_PRIO`` attr priority of pin on the + dpll device + ``DPLL_A_PIN_STATE`` attr state of pin on the parent + dpll device + ``DPLL_A_PIN_PARENT_PIN`` nested attr for each parent pin + the pin is connected with + ``DPLL_A_PIN_ID`` attr provided if parent is a pin + ``DPLL_A_PIN_STATE`` attr state of pin on the parent + pin + ``DPLL_A_PIN_DPLL_CAPS`` attr bitmask of pin-dpll + capabilities + ==================================== ================================= + + ==================================== ================================= + ``DPLL_CMD_PIN_SET`` command to set pins configuration + ``DPLL_A_PIN_ID`` attr unique a pin ID + ``DPLL_A_PIN_DIRECTION`` attr requested direction of a pin + ``DPLL_A_PIN_FREQUENCY`` attr requested frequency of a pin + ``DPLL_A_PIN_PARENT_DEVICE`` nested attr for each parent + device configuration of a pin + ``DPLL_A_ID`` attr parent dpll device id + ``DPLL_A_PIN_PRIO`` attr requested priority of pin on + the dpll device + ``DPLL_A_PIN_STATE`` attr requested state of pin on + the dpll device + ``DPLL_A_PIN_PARENT_PIN`` nested attr for each parent pin + configuration + ``DPLL_A_PIN_ID`` attr parent pin id + ``DPLL_A_PIN_STATE`` attr requested state of pin on + parent pin + ==================================== ================================= + +Netlink dump requests +===================== + +The ``DPLL_CMD_DEVICE_GET`` and ``DPLL_CMD_PIN_GET`` commands are +capable of dump type netlink requests, in which case the response is in +the same format as for their ``do`` request, but every device or pin +registered in the system is returned. + +SET commands format +=================== + +``DPLL_CMD_DEVICE_SET`` - to target a dpll device, the user provides +``DPLL_A_ID``, which is unique identifier of dpll device in the system, +as well as parameter being configured (``DPLL_A_MODE``). + +``DPLL_CMD_PIN_SET`` - to target a pin user has to provide a +``DPLL_A_PIN_ID``, which is unique identifier of a pin in the system. +Also configured pin parameters must be added. +If ``DPLL_A_PIN_DIRECTION`` or ``DPLL_A_PIN_FREQUENCY`` are configured, +this affects all the dpll device they are connected, that is why those +attributes shall not be enclosed in ``DPLL_A_PIN_PARENT``. +Other attributes: +``DPLL_A_PIN_PRIO`` or ``DPLL_A_PIN_STATE`` must be enclosed in +``DPLL_A_PIN_PARENT`` as their configuration relates to only one +parent dpll or parent pin. +Nested attribute of either ``DPLL_A_ID`` or ``DPLL_A_PIN_ID`` determines +if configuration was requested on a dpll device or on a pin +respectively. +In general, it is possible to configure multiple parameters at once, but +internally each parameter change will be invoked separately, where order +of configuration is not guaranteed by any means. + +Configuration pre-defined enums +=============================== + +.. kernel-doc:: include/uapi/linux/dpll.h + +Notifications +============= + +dpll device can provide notifications regarding status changes of the +device, i.e. lock status changes, input/output changes or other alarms. +There is one multicast group that is used to notify user-space apps via +netlink socket: ``DPLL_MCGRP_MONITOR`` + +Notifications messages: + + ============================== ===================================== + ``DPLL_CMD_DEVICE_CREATE_NTF`` dpll device was created + ``DPLL_CMD_DEVICE_DELETE_NTF`` dpll device was deleted + ``DPLL_CMD_DEVICE_CHANGE_NTF`` dpll device has changed + ``DPLL_CMD_PIN_CREATE_NTF`` dpll pin was created + ``DPLL_CMD_PIN_DELETE_NTF`` dpll pin was deleted + ``DPLL_CMD_PIN_CHANGE_NTF`` dpll pin has changed + ============================== ===================================== + +Events format is the same as for the corresponding get command. +Format of ``DPLL_CMD_DEVICE_`` events is the same as response of +``DPLL_CMD_DEVICE_GET``. +Format of ``DPLL_CMD_PIN_`` events is same as response of +``DPLL_CMD_PIN_GET``. + +Device driver implementation +============================ + +Device is allocated by dpll_device_get() call. Second call with the +same arguments will not create new object but provides pointer to +previously created device for given arguments, it also increases +refcount of that object. +Device is deallocated by dpll_device_put() call, which first +decreases the refcount, once refcount is cleared the object is +destroyed. + +Device should implement set of operations and register device via +dpll_device_register() at which point it becomes available to the +users. Multiple driver instances can obtain reference to it with +dpll_device_get(), as well as register dpll device with their own +ops and priv. + +The pins are allocated separately with dpll_pin_get(), it works +similarly to dpll_device_get(). Function first creates object and then +for each call with the same arguments only the object refcount +increases. Also dpll_pin_put() works similarly to dpll_device_put(). + +A pin can be registered with parent dpll device or parent pin, depending +on hardware needs. Each registration requires registerer to provide set +of pin callbacks, and private data pointer for calling them: + +- dpll_pin_register() - register pin with a dpll device, +- dpll_pin_on_pin_register() - register pin with another MUX type pin. + +Notifications of adding or removing dpll devices are created within +subsystem itself. +Notifications about registering/deregistering pins are also invoked by +the subsystem. +Notifications about status changes either of dpll device or a pin are +invoked in two ways: + +- after successful change was requested on dpll subsystem, the subsystem + calls corresponding notification, +- requested by device driver with dpll_device_change_ntf() or + dpll_pin_change_ntf() when driver informs about the status change. + +The device driver using dpll interface is not required to implement all +the callback operation. Neverthelessi, there are few required to be +implemented. +Required dpll device level callback operations: + +- ``.mode_get``, +- ``.lock_status_get``. + +Required pin level callback operations: + +- ``.state_on_dpll_get`` (pins registered with dpll device), +- ``.state_on_pin_get`` (pins registered with parent pin), +- ``.direction_get``. + +Every other operation handler is checked for existence and +``-EOPNOTSUPP`` is returned in case of absence of specific handler. + +SyncE enablement +================ +For SyncE enablement it is required to allow control over dpll device +for a software application which monitors and configures the inputs of +dpll device in response to current state of a dpll device and its +inputs. +In such scenario, dpll device input signal shall be also configurable +to drive dpll with signal recovered from the PHY netdevice. +This is done by exposing a pin to the netdevice - attaching pin to the +netdevice itself with +``netdev_dpll_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin)``. +Exposed pin id handle ``DPLL_A_PIN_ID`` is then identifiable by the user +as it is attached to rtnetlink respond to get ``RTM_NEWLINK`` command in +nested attribute ``IFLA_DPLL_PIN``.
Documentation/driver-api/index.rst +1 -0
@@ -114,6 +114,7 @@ available subsections can be seen below. zorro hte/index wmi + dpll .. only:: subproject and html
Signature · 1 line
2.27.0
Jiri Pirko
maintainerRe: [PATCH net-next 03/11] dpll: documentation on DPLL subsystem interface
Quoted 8 lines · Thu, Jul 20, 2023 at 11:18:55AM CEST, [email protected] wrote:
Add documentation explaining common netlink interface to configure DPLL devices and monitoring events. Common way to implement DPLL device in a driver is also covered.
Co-developed-by Bagas Sanjaya <[email protected]>Signed-off-by Bagas Sanjaya <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>Signed-off-by Arkadiusz Kubalewski <[email protected]>
Quoted 5 lines
---
RFCv9->v0:
- fix muxed get-pin command respond example
- fix typos
- describeDPLL_MODE_FREERUN
Yet, there is no mention of "freerun" mode at all :/ Could you please add it as you state here?
Vadim Fedorenko
maintainerPATCH 4/11 dpll: spec: Add Netlink spec in YAML
In reply to Vadim FedorenkoAdd a protocol spec for DPLL.
Add code generated from the spec.
---
RFC v9->v0:
- add DPLL_MODE_FREERUN
v8->v9:
- regenerate policy max values
- add missing enum descriptions
- split pin-parent nest:
- pin-parent-device - for configuration of pin-device tuple
- pin-parent-pin - for configuration od pin-pin tuple
- fix typos:
- s/working-modes/working modes/
- s/differentiate/differentiates/
- s/valid input, auto selected by dpll/input pin auto selected by dpll/
- remove FREERUN and HOLDOVER modes
Documentation/netlink/specs/dpll.yaml | 475 ++++++++++++++++++++++++++ drivers/dpll/dpll_nl.c | 163 +++++++++ drivers/dpll/dpll_nl.h | 51 +++ include/uapi/linux/dpll.h | 186 ++++++++++ 4 files changed, 875 insertions(+) create mode 100644 Documentation/netlink/specs/dpll.yaml create mode 100644 drivers/dpll/dpll_nl.c create mode 100644 drivers/dpll/dpll_nl.h create mode 100644 include/uapi/linux/dpll.h
Documentation/netlink/specs/dpll.yaml new file +475 -0
@@ -0,0 +1,475 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: dpll + +doc: DPLL subsystem. + +definitions: + - + type: enum + name: mode + doc: | + working modes a dpll can support, differentiates if and how dpll selects + one of its inputs to syntonize with it, valid values for DPLL_A_MODE + attribute + entries: + - + name: manual + doc: input can be only selected by sending a request to dpll + value: 1 + - + name: automatic + doc: highest prio input pin auto selected by dpll + - + name: freerun + doc: dpll driven on system clk + render-max: true + - + type: enum + name: lock-status + doc: | + provides information of dpll device lock status, valid values for + DPLL_A_LOCK_STATUS attribute + entries: + - + name: unlocked + doc: | + dpll was not yet locked to any valid input + value: 1 + - + name: locked + doc: | + dpll is locked to a valid signal, but no holdover available + - + name: locked-ho-acq + doc: | + dpll is locked and holdover acquired + - + name: holdover + doc: | + dpll is in holdover state - lost a valid lock or was forced + by disconnecting all the pins (latter possible only + when dpll lock-state was already DPLL_LOCK_STATUS_LOCKED_HO_ACQ, + if dpll lock-state was not DPLL_LOCK_STATUS_LOCKED_HO_ACQ, the + dpll's lock-state shall remain DPLL_LOCK_STATUS_UNLOCKED) + render-max: true + - + type: const + name: temp-divider + value: 1000 + doc: | + temperature divider allowing userspace to calculate the + temperature as float with three digit decimal precision. + Value of (DPLL_A_TEMP / DPLL_TEMP_DIVIDER) is integer part of + temperature value. + Value of (DPLL_A_TEMP % DPLL_TEMP_DIVIDER) is fractional part of + temperature value. + - + type: enum + name: type + doc: type of dpll, valid values for DPLL_A_TYPE attribute + entries: + - + name: pps + doc: dpll produces Pulse-Per-Second signal + value: 1 + - + name: eec + doc: dpll drives the Ethernet Equipment Clock + render-max: true + - + type: enum + name: pin-type + doc: | + defines possible types of a pin, valid values for DPLL_A_PIN_TYPE + attribute + entries: + - + name: mux + doc: aggregates another layer of selectable pins + value: 1 + - + name: ext + doc: external input + - + name: synce-eth-port + doc: ethernet port PHY's recovered clock + - + name: int-oscillator + doc: device internal oscillator + - + name: gnss + doc: GNSS recovered clock + render-max: true + - + type: enum + name: pin-direction + doc: | + defines possible direction of a pin, valid values for + DPLL_A_PIN_DIRECTION attribute + entries: + - + name: input + doc: pin used as a input of a signal + value: 1 + - + name: output + doc: pin used to output the signal + render-max: true + - + type: const + name: pin-frequency-1-hz + value: 1 + - + type: const + name: pin-frequency-10-khz + value: 10000 + - + type: const + name: pin-frequency-77_5-khz + value: 77500 + - + type: const + name: pin-frequency-10-mhz + value: 10000000 + - + type: enum + name: pin-state + doc: | + defines possible states of a pin, valid values for + DPLL_A_PIN_STATE attribute + entries: + - + name: connected + doc: pin connected, active input of phase locked loop + value: 1 + - + name: disconnected + doc: pin disconnected, not considered as a valid input + - + name: selectable + doc: pin enabled for automatic input selection + render-max: true + - + type: flags + name: pin-caps + doc: | + defines possible capabilities of a pin, valid flags on + DPLL_A_PIN_CAPS attribute + entries: + - + name: direction-can-change + doc: pin direction can be changed + - + name: priority-can-change + doc: pin prority can be changed + - + name: state-can-change + doc: pin state can be changed + +attribute-sets: + - + name: dpll + enum-name: dpll_a + attributes: + - + name: id + type: u32 + value: 1 + - + name: module-name + type: string + - + name: clock-id + type: u64 + - + name: mode + type: u8 + enum: mode + - + name: mode-supported + type: u8 + enum: mode + multi-attr: true + - + name: lock-status + type: u8 + enum: lock-status + - + name: temp + type: s32 + - + name: type + type: u8 + enum: type + - + name: pin-id + type: u32 + - + name: pin-board-label + type: string + - + name: pin-panel-label + type: string + - + name: pin-package-label + type: string + - + name: pin-type + type: u8 + enum: pin-type + - + name: pin-direction + type: u8 + enum: pin-direction + - + name: pin-frequency + type: u64 + - + name: pin-frequency-supported + type: nest + multi-attr: true + nested-attributes: pin-frequency-range + - + name: pin-frequency-min + type: u64 + - + name: pin-frequency-max + type: u64 + - + name: pin-prio + type: u32 + - + name: pin-state + type: u8 + enum: pin-state + - + name: pin-dpll-caps + type: u32 + - + name: pin-parent-device + type: nest + multi-attr: true + nested-attributes: pin-parent-device + - + name: pin-parent-pin + type: nest + multi-attr: true + nested-attributes: pin-parent-pin + - + name: pin-parent-device + subset-of: dpll + attributes: + - + name: id + type: u32 + - + name: pin-direction + type: u8 + - + name: pin-prio + type: u32 + - + name: pin-state + type: u8 + - + name: pin-parent-pin + subset-of: dpll + attributes: + - + name: pin-state + type: u8 + - + name: pin-id + type: u32 + - + name: pin-frequency-range + subset-of: dpll + attributes: + - + name: pin-frequency-min + type: u64 + - + name: pin-frequency-max + type: u64 + +operations: + enum-name: dpll_cmd + list: + - + name: device-id-get + doc: | + Get id of dpll device that matches given attributes + value: 1 + attribute-set: dpll + flags: [ admin-perm ] + + do: + pre: dpll-lock-doit + post: dpll-unlock-doit + request: + attributes: + - module-name + - clock-id + - type + reply: + attributes: + - id + + - + name: device-get + doc: | + Get list of DPLL devices (dump) or attributes of a single dpll device + attribute-set: dpll + flags: [ admin-perm ] + + do: + pre: dpll-pre-doit + post: dpll-post-doit + request: + attributes: + - id + - module-name + reply: &dev-attrs + attributes: + - id + - module-name + - mode + - mode-supported + - lock-status + - temp + - clock-id + - type + + dump: + pre: dpll-lock-dumpit + post: dpll-unlock-dumpit + reply: *dev-attrs + + - + name: device-set + doc: Set attributes for a DPLL device + attribute-set: dpll + flags: [ admin-perm ] + + do: + pre: dpll-pre-doit + post: dpll-post-doit + request: + attributes: + - id + - mode + - + name: device-create-ntf + doc: Notification about device appearing + notify: device-get + mcgrp: monitor + - + name: device-delete-ntf + doc: Notification about device disappearing + notify: device-get + mcgrp: monitor + - + name: device-change-ntf + doc: Notification about device configuration being changed + notify: device-get + mcgrp: monitor + - + name: pin-id-get + doc: | + Get id of a pin that matches given attributes + attribute-set: dpll + flags: [ admin-perm ] + + do: + pre: dpll-lock-doit + post: dpll-unlock-doit + request: + attributes: + - module-name + - clock-id + - pin-board-label + - pin-panel-label + - pin-package-label + - pin-type + reply: + attributes: + - pin-id + + - + name: pin-get + doc: | + Get list of pins and its attributes. + - dump request without any attributes given - list all the pins in the + system + - dump request with target dpll - list all the pins registered with + a given dpll device + - do request with target dpll and target pin - single pin attributes + attribute-set: dpll + flags: [ admin-perm ] + + do: + pre: dpll-pin-pre-doit + post: dpll-pin-post-doit + request: + attributes: + - pin-id + reply: &pin-attrs + attributes: + - pin-id + - pin-board-label + - pin-panel-label + - pin-package-label + - pin-type + - pin-frequency + - pin-frequency-supported + - pin-dpll-caps + - pin-parent-device + - pin-parent-pin + + dump: + pre: dpll-lock-dumpit + post: dpll-unlock-dumpit + request: + attributes: + - id + reply: *pin-attrs + + - + name: pin-set + doc: Set attributes of a target pin + attribute-set: dpll + flags: [ admin-perm ] + + do: + pre: dpll-pin-pre-doit + post: dpll-pin-post-doit + request: + attributes: + - pin-id + - pin-frequency + - pin-direction + - pin-prio + - pin-state + - pin-parent-device + - pin-parent-pin + - + name: pin-create-ntf + doc: Notification about pin appearing + notify: pin-get + mcgrp: monitor + - + name: pin-delete-ntf + doc: Notification about pin disappearing + notify: pin-get + mcgrp: monitor + - + name: pin-change-ntf + doc: Notification about pin configuration being changed + notify: pin-get + mcgrp: monitor + +mcast-groups: + list: + - + name: monitor
drivers/dpll/dpll_nl.c new file +163 -0
163 lines not on this page · raw message
drivers/dpll/dpll_nl.h new file +51 -0
51 lines not on this page · raw message
include/uapi/linux/dpll.h new file +186 -0
186 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH net-next 04/11] dpll: spec: Add Netlink spec in YAML
On Thu, Jul 20, 2023 at 10:18:56AM +0100, Vadim Fedorenko wrote:
...
Hi Vadim,
Some minor feedback from my side.
Quoted 1 line
Documentation/netlink/specs/dpll.yaml +0
-0
...
Documentation/netlink/specs/dpll.yaml line 165
Quoted 13 lines
Documentation/netlink/specs/dpll.yaml +13
-0+ - + type: flags + name: pin-caps + doc: | + defines possible capabilities of a pin, valid flags on + DPLL_A_PIN_CAPS attribute + entries: + - + name: direction-can-change + doc: pin direction can be changed + - + name: priority-can-change + doc: pin prority can be changed
nit: prority -> priority
...
Quoted 1 line
include/uapi/linux/dpll.h +0
-0
...
include/uapi/linux/dpll.h line 23
Quoted 12 lines
include/uapi/linux/dpll.h +12
-0+/** +* enum dpll_mode - working modes a dpll can support, differentiates if and how +* dpll selects one of its inputs to syntonize with it, valid values for +* DPLL_A_MODE attribute +* @DPLL_MODE_MANUAL: input can be only selected by sending a request to dpll +* @DPLL_MODE_AUTOMATIC: highest prio input pin auto selected by dpll +* @DPLL_MODE_FREERUN: dpll driven on system clk +*/ +enum dpll_mode { +DPLL_MODE_MANUAL =1 , +DPLL_MODE_AUTOMATIC , +DPLL_MODE_FREERUN ,
As __DPLL_MODE_MAX and DPLL_MODE_MAX are (rightly) not included in the kernel doc above. I think it is appropriate to add the following here.
/* private: */
Likewise in several other places in this patch.
...
Quoted 5 lines
+/**
+ * enumdpll_pin_caps- defines possible capabilities of a pin, valid flags on
+ *DPLL_A_PIN_CAPSattribute
+ * @DPLL_PIN_CAPS_DIRECTION_CAN_CHANGE: pin direction can be changed
+ * @DPLL_PIN_CAPS_PRIORITY_CAN_CHANGE: pin prority can be changed
prority -> priority
Quoted 2 lines
+ * @DPLL_PIN_CAPS_STATE_CAN_CHANGE: pin state can be changed
+ */
...
Vadim Fedorenko
maintainerPATCH 5/11 dpll: core: Add DPLL framework base functions
In reply to Vadim FedorenkoDPLL framework is used to represent and configure DPLL devices in systems. Each device that has DPLL and can configure inputs and outputs can use this framework.
Implement core framework functions for further interactions with device drivers implementing dpll subsystem, as well as for interactions of DPLL netlink framework part with the subsystem itself.
---
RFC v9->v0:
- remove unused mode_supported_mask from dpll_device
- fix increment refcount only if it was not already set
- remove static function comments/fix return descriptions
- add missing mutex locking on getting/registering pins
- check if dpll is registered before registering pin
- headers are squashed into this commit
- updated MAINTAINERS to add Arkadiusz and Jiri as maintainers
v8->v9:
- fix description in spdx header.
- remove refcount check if refcount was already set
- do not validate dpll ptr in dpll_device_put(..)
- fix return -ENOMEM on failed memory alloc
- do not validate pin ptr in dpll_pin_put(..)
- return -EINVAL in case of module/clock_id mismatch
- do not {} around one-line xa_for_each() macro
- move dpll_<x>_registration structs to dpll_core.c
- rephrase doc comment on device and pin id struct members
- remove ref in case of memory allocation fail
- check for required ops on pin/device registration
- mark pin with DPLL_REGISTERED once pin is registered with dpll
MAINTAINERS | 11 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/dpll/Kconfig | 7 + drivers/dpll/Makefile | 9 + drivers/dpll/dpll_core.c | 799 +++++++++++++++++++++++++++++++++++++++ drivers/dpll/dpll_core.h | 90 +++++ include/linux/dpll.h | 136 +++++++ 8 files changed, 1055 insertions(+) create mode 100644 drivers/dpll/Kconfig create mode 100644 drivers/dpll/Makefile create mode 100644 drivers/dpll/dpll_core.c create mode 100644 drivers/dpll/dpll_core.h create mode 100644 include/linux/dpll.h
MAINTAINERS +11 -0
@@ -6304,6 +6304,17 @@ F: Documentation/networking/device_drivers/ethernet/freescale/dpaa2/switch-drive F: drivers/net/ethernet/freescale/dpaa2/dpaa2-switch* F: drivers/net/ethernet/freescale/dpaa2/dpsw* +DPLL SUBSYSTEM +M: Vadim Fedorenko <[email protected]> +M: Arkadiusz Kubalewski <[email protected]> +M: Jiri Pirko <[email protected]> +L: [email protected] +S: Supported +F: Documentation/driver-api/dpll.rst +F: drivers/dpll/* +F: include/net/dpll.h +F: include/uapi/linux/dpll.h + DRBD DRIVER M: Philipp Reisner <[email protected]> M: Lars Ellenberg <[email protected]>
drivers/Kconfig +2 -0
@@ -243,4 +243,6 @@ source "drivers/hte/Kconfig" source "drivers/cdx/Kconfig" +source "drivers/dpll/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -195,3 +195,4 @@ obj-$(CONFIG_PECI) += peci/ obj-$(CONFIG_HTE) += hte/ obj-$(CONFIG_DRM_ACCEL) += accel/ obj-$(CONFIG_CDX_BUS) += cdx/ +obj-$(CONFIG_DPLL) += dpll/
drivers/dpll/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Generic DPLL drivers configuration +# + +config DPLL + bool
drivers/dpll/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for DPLL drivers. +# + +obj-$(CONFIG_DPLL) += dpll.o +dpll-y += dpll_core.o +dpll-y += dpll_netlink.o +dpll-y += dpll_nl.o
drivers/dpll/dpll_core.c new file +799 -0
799 lines not on this page · raw message
drivers/dpll/dpll_core.h new file +90 -0
90 lines not on this page · raw message
include/linux/dpll.h new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH net-next 05/11] dpll: core: Add DPLL framework base functions
On Thu, Jul 20, 2023 at 10:18:57AM +0100, Vadim Fedorenko wrote:
...
Quoted 9 lines
drivers/dpll/dpll_core.h new file +3
-0@@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2023 Meta Platforms, Inc. and affiliates
drivers/dpll/dpll_core.h line 13
Quoted 10 lines
drivers/dpll/dpll_core.h new file +10
-0+* Copyright (c) 2023 Intel and affiliates +*/ + +#ifndef __DPLL_CORE_H__ +#define __DPLL_CORE_H__ + +#include <linux/dpll.h> +#include <linux/list.h> +#include <linux/refcount.h> +#include "dpll_netlink.h"
Hi Vadim,
dpll_netlink.h is used here.
But that file it isn't added until the following patch.
...
Vadim Fedorenko
maintainerPATCH 6/11 dpll: netlink: Add DPLL framework base functions
In reply to Vadim FedorenkoDPLL framework is used to represent and configure DPLL devices in systems. Each device that has DPLL and can configure inputs and outputs can use this framework.
Implement dpll netlink framework functions for enablement of dpll subsytem netlink family.
---
RFC v9->v0:
- fix DPLL_MODE_SUPPORTED attribute in device-get response
- remove dead code from dpll_msg_add_pin_freq(..)
- don't fill dpll device for muxed pins
- API headers are added to this commit
v8->v9:
- fix pin-id-get/device-id-get behavior
- reshuffle order of functions
- avoid forward declarations
- functions for adding pin/device handle next to each other
- pass ops callback return values to the user
- remove dpll_cmd_pin_fill_details(..) function, merge the code into __dpll_cmd_pin_dump_one(..)
- rename __dpll_cmd_pin_dump_one() to dpll_cmd_pin_get_one()
- use WARN_ON macro when dpll ref is missing
- remove redundant pin's dpll list not empty check
- remove double spaces inside if statement
- add extack message when set command is not possible
- do not return error when callback is not required
- WARN_ON missing ops moved to dpll_core.c
- use DPLL_REGISTERED if pin was registered with dpll
- fix pin-id-get return and add extack errors
- fix device-id-get return and add extack errors
- drop pointless init of variables
- add macro for iterating over marked pins/devices
- move dpll_set_from_nlattr() for consistent order
- use GENL_REQ_ATTR_CHECK() for checking attibute presence
- fill extack if pin/device was not found
- drop pointless init of variables
- WARN_ON if dpll not registered on send event
- rename goto labels to indicate error path
- fix docs
- drop pointless init of variables
- verify pin in notify with a mark
- prevent ops->mode_set call if missing callback
- move static dpll_msg_add_pin_handle() from pin<->netdev patch
- split pin-parent nest:
- pin-parent-device - for configuration of pin-device tuple
- pin-parent-pin - for configuration od pin-pin tuple
drivers/dpll/dpll_netlink.c | 1273 +++++++++++++++++++++++++++++++++++ drivers/dpll/dpll_netlink.h | 17 + include/linux/dpll.h | 4 + 3 files changed, 1294 insertions(+) create mode 100644 drivers/dpll/dpll_netlink.c create mode 100644 drivers/dpll/dpll_netlink.h
drivers/dpll/dpll_netlink.c new file +1273 -0
@@ -0,0 +1,1273 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Generic netlink for DPLL management framework +* +* Copyright (c) 2023 Meta Platforms, Inc. and affiliates +* Copyright (c) 2023 Intel and affiliates +* +*/ +#include <linux/module.h> +#include <linux/kernel.h> +#include <net/genetlink.h> +#include "dpll_core.h" +#include "dpll_nl.h" +#include <uapi/linux/dpll.h> + +#define ASSERT_NOT_NULL (ptr) (WARN_ON(!ptr)) + +#define xa_for_each_marked_start (xa, index, entry, filter, start) \ + for (index = start, entry = xa_find(xa, &index, ULONG_MAX, filter); \ + entry; entry = xa_find_after(xa, &index, ULONG_MAX, filter)) + +struct dpll_dump_ctx { +unsigned long idx; +}; + +static struct dpll_dump_ctx *dpll_dump_context (struct netlink_callback *cb) +{ +return (struct dpll_dump_ctx *)cb->ctx; +} + +static int +dpll_msg_add_dev_handle (struct sk_buff *msg,struct dpll_device *dpll) +{ +if (nla_put_u32 (msg,DPLL_A_ID , dpll->id)) +return -EMSGSIZE ; + +return 0 ; +} + +/** +* dpll_msg_add_pin_handle - attach pin handle attribute to a given message +* @msg: pointer to sk_buff message to attach a pin handle +* @pin: pin pointer +* +* Return: +* * 0 - success +* * -EMSGSIZE - no space in message to attach pin handle +*/ +int dpll_msg_add_pin_handle (struct sk_buff *msg,struct dpll_pin *pin) +{ +if (!pin) +return 0 ; +if (nla_put_u32 (msg,DPLL_A_PIN_ID , pin->id)) +return -EMSGSIZE ; +return 0 ; +} + +static int +dpll_msg_add_mode (struct sk_buff *msg,struct dpll_device *dpll, +struct netlink_ext_ack *extack) +{ +const struct dpll_device_ops *ops =dpll_device_ops (dpll); +enum dpll_mode mode; +int ret; + + ret = ops->mode_get (dpll,dpll_priv (dpll), &mode, extack); +if (ret) +return ret; +if (nla_put_u8 (msg,DPLL_A_MODE , mode)) +return -EMSGSIZE ; + +return 0 ; +} + +static int +dpll_msg_add_mode_supported (struct sk_buff *msg,struct dpll_device *dpll, +struct netlink_ext_ack *extack) +{ +const struct dpll_device_ops *ops =dpll_device_ops (dpll); +enum dpll_mode mode; + +if (!ops->mode_supported) +return 0 ; +for (mode =DPLL_MODE_MANUAL ; mode <=DPLL_MODE_MAX ; mode++) +if (ops->mode_supported (dpll,dpll_priv (dpll), mode, extack)) +if (nla_put_u8 (msg,DPLL_A_MODE_SUPPORTED , mode)) +return -EMSGSIZE ; + +return 0 ; +} + +static int +dpll_msg_add_lock_status (struct sk_buff *msg,struct dpll_device *dpll, +struct netlink_ext_ack *extack) +{ +const struct dpll_device_ops *ops =dpll_device_ops (dpll); +enum dpll_lock_status status; +int ret; + + ret = ops->lock_status_get (dpll,dpll_priv (dpll), &status, extack); +if (ret) +return ret; +if (nla_put_u8 (msg,DPLL_A_LOCK_STATUS , status)) +return -EMSGSIZE ; + +return 0 ; +} + +static int +dpll_msg_add_temp (struct sk_buff *msg,struct dpll_device *dpll, +struct netlink_ext_ack *extack) +{ +const struct dpll_device_ops *ops =dpll_device_ops (dpll); +s32 temp; +int ret; + +if (!ops->temp_get) +return 0 ; + ret = ops->temp_get (dpll,dpll_priv (dpll), &temp, extack); +if (ret) +return ret; +if (nla_put_s32 (msg,DPLL_A_TEMP , temp)) +return -EMSGSIZE ; + +return 0 ; +} + +static int +dpll_msg_add_pin_prio (struct sk_buff *msg,struct dpll_pin *pin, +struct dpll_pin_ref *ref, +struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +struct dpll_device *dpll = ref->dpll; +u32 prio; +int ret; + +if (!ops->prio_get) +return 0 ; + ret = ops->prio_get (pin,dpll_pin_on_dpll_priv (dpll, pin), dpll, +dpll_priv (dpll), &prio, extack); +if (ret) +return ret; +if (nla_put_u32 (msg,DPLL_A_PIN_PRIO , prio)) +return -EMSGSIZE ; + +return 0 ; +} + +static int +dpll_msg_add_pin_on_dpll_state (struct sk_buff *msg,struct dpll_pin *pin, +struct dpll_pin_ref *ref, +struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +struct dpll_device *dpll = ref->dpll; +enum dpll_pin_state state; +int ret; + + +if (!ops->state_on_dpll_get) +return 0 ; + ret = ops->state_on_dpll_get (pin,dpll_pin_on_dpll_priv (dpll, pin), + dpll,dpll_priv (dpll), &state, extack); +if (ret) +return ret; +if (nla_put_u8 (msg,DPLL_A_PIN_STATE , state)) +return -EMSGSIZE ; + +return 0 ; +} + +static int +dpll_msg_add_pin_direction (struct sk_buff *msg,struct dpll_pin *pin, +struct dpll_pin_ref *ref, +struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +struct dpll_device *dpll = ref->dpll; +enum dpll_pin_direction direction; +int ret; + + ret = ops->direction_get (pin,dpll_pin_on_dpll_priv (dpll, pin), dpll, +dpll_priv (dpll), &direction, extack); +if (ret) +return ret; +if (nla_put_u8 (msg,DPLL_A_PIN_DIRECTION , direction)) +return -EMSGSIZE ; + +return 0 ; +} + +static int +dpll_msg_add_pin_freq (struct sk_buff *msg,struct dpll_pin *pin, +struct dpll_pin_ref *ref,struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +struct dpll_device *dpll = ref->dpll; +struct nlattr *nest; +int fs, ret; +u64 freq; + +if (!ops->frequency_get) +return 0 ; + ret = ops->frequency_get (pin,dpll_pin_on_dpll_priv (dpll, pin), dpll, +dpll_priv (dpll), &freq, extack); +if (ret) +return ret; +if (nla_put_64bit (msg,DPLL_A_PIN_FREQUENCY ,sizeof (freq), &freq,0 )) +return -EMSGSIZE ; +for (fs =0 ; fs < pin->prop->freq_supported_num; fs++) { + nest =nla_nest_start (msg,DPLL_A_PIN_FREQUENCY_SUPPORTED ); +if (!nest) +return -EMSGSIZE ; + freq = pin->prop->freq_supported[fs].min; +if (nla_put_64bit (msg,DPLL_A_PIN_FREQUENCY_MIN ,sizeof (freq), + &freq,0 )) { +nla_nest_cancel (msg, nest); +return -EMSGSIZE ; + } + freq = pin->prop->freq_supported[fs].max; +if (nla_put_64bit (msg,DPLL_A_PIN_FREQUENCY_MAX ,sizeof (freq), + &freq,0 )) { +nla_nest_cancel (msg, nest); +return -EMSGSIZE ; + } +nla_nest_end (msg, nest); + } + +return 0 ; +} + +static bool dpll_pin_is_freq_supported (struct dpll_pin *pin,u32 freq) +{ +int fs; + +for (fs =0 ; fs < pin->prop->freq_supported_num; fs++) +if (freq >= pin->prop->freq_supported[fs].min && + freq <= pin->prop->freq_supported[fs].max) +return true; +return false; +} + +static int +dpll_msg_add_pin_parents (struct sk_buff *msg,struct dpll_pin *pin, +struct dpll_pin_ref *dpll_ref, +struct netlink_ext_ack *extack) +{ +enum dpll_pin_state state; +struct dpll_pin_ref *ref; +struct dpll_pin *ppin; +struct nlattr *nest; +unsigned long index; +int ret; + +xa_for_each (&pin->parent_refs, index, ref) { +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +void *parent_priv; + + ppin = ref->pin; + parent_priv =dpll_pin_on_dpll_priv (dpll_ref->dpll, ppin); + ret = ops->state_on_pin_get (pin, +dpll_pin_on_pin_priv (ppin, pin), + ppin, parent_priv, &state, extack); +if (ret) +return ret; + nest =nla_nest_start (msg,DPLL_A_PIN_PARENT_PIN ); +if (!nest) +return -EMSGSIZE ; +if (nla_put_u32 (msg,DPLL_A_PIN_ID , ppin->id)) { + ret = -EMSGSIZE ; + goto nest_cancel; + } +if (nla_put_u8 (msg,DPLL_A_PIN_STATE , state)) { + ret = -EMSGSIZE ; + goto nest_cancel; + } +nla_nest_end (msg, nest); + } + +return 0 ; + +nest_cancel: +nla_nest_cancel (msg, nest); +return ret; +} + +static int +dpll_msg_add_pin_dplls (struct sk_buff *msg,struct dpll_pin *pin, +struct netlink_ext_ack *extack) +{ +struct dpll_pin_ref *ref; +struct nlattr *attr; +unsigned long index; +int ret; + +xa_for_each (&pin->dpll_refs, index, ref) { + attr =nla_nest_start (msg,DPLL_A_PIN_PARENT_DEVICE ); +if (!attr) +return -EMSGSIZE ; + ret =dpll_msg_add_dev_handle (msg, ref->dpll); +if (ret) + goto nest_cancel; + ret =dpll_msg_add_pin_on_dpll_state (msg, pin, ref, extack); +if (ret) + goto nest_cancel; + ret =dpll_msg_add_pin_prio (msg, pin, ref, extack); +if (ret) + goto nest_cancel; + ret =dpll_msg_add_pin_direction (msg, pin, ref, extack); +if (ret) + goto nest_cancel; +nla_nest_end (msg, attr); + } + +return 0 ; + +nest_cancel: +nla_nest_end (msg, attr); +return ret; +} + +static int +dpll_cmd_pin_get_one (struct sk_buff *msg,struct dpll_pin *pin, +struct netlink_ext_ack *extack) +{ +const struct dpll_pin_properties *prop = pin->prop; +struct dpll_pin_ref *ref; +int ret; + + ref =dpll_xa_ref_dpll_first (&pin->dpll_refs); +ASSERT_NOT_NULL (ref); + ret =dpll_msg_add_pin_handle (msg, pin); +if (ret) +return ret; +if (nla_put_string (msg,DPLL_A_MODULE_NAME ,module_name (pin->module))) +return -EMSGSIZE ; +if (nla_put_64bit (msg,DPLL_A_CLOCK_ID ,sizeof (pin->clock_id), + &pin->clock_id,0 )) +return -EMSGSIZE ; +if (prop->board_label && +nla_put_string (msg,DPLL_A_PIN_BOARD_LABEL , prop->board_label)) +return -EMSGSIZE ; +if (prop->panel_label && +nla_put_string (msg,DPLL_A_PIN_PANEL_LABEL , prop->panel_label)) +return -EMSGSIZE ; +if (prop->package_label && +nla_put_string (msg,DPLL_A_PIN_PACKAGE_LABEL , + prop->package_label)) +return -EMSGSIZE ; +if (nla_put_u8 (msg,DPLL_A_PIN_TYPE , prop->type)) +return -EMSGSIZE ; +if (nla_put_u32 (msg,DPLL_A_PIN_DPLL_CAPS , prop->capabilities)) +return -EMSGSIZE ; + ret =dpll_msg_add_pin_freq (msg, pin, ref, extack); +if (ret) +return ret; +if (xa_empty (&pin->parent_refs)) + ret =dpll_msg_add_pin_dplls (msg, pin, extack); +else + ret =dpll_msg_add_pin_parents (msg, pin, ref, extack); + +return ret; +} + +static int +dpll_device_get_one (struct dpll_device *dpll,struct sk_buff *msg, +struct netlink_ext_ack *extack) +{ +int ret; + + ret =dpll_msg_add_dev_handle (msg, dpll); +if (ret) +return ret; +if (nla_put_string (msg,DPLL_A_MODULE_NAME ,module_name (dpll->module))) +return -EMSGSIZE ; +if (nla_put_64bit (msg,DPLL_A_CLOCK_ID ,sizeof (dpll->clock_id), + &dpll->clock_id,0 )) +return -EMSGSIZE ; + ret =dpll_msg_add_temp (msg, dpll, extack); +if (ret) +return ret; + ret =dpll_msg_add_lock_status (msg, dpll, extack); +if (ret) +return ret; + ret =dpll_msg_add_mode (msg, dpll, extack); +if (ret) +return ret; + ret =dpll_msg_add_mode_supported (msg, dpll, extack); +if (ret) +return ret; +if (nla_put_u8 (msg,DPLL_A_TYPE , dpll->type)) +return -EMSGSIZE ; + +return ret; +} + +static int +dpll_device_event_send (enum dpll_cmd event,struct dpll_device *dpll) +{ +struct sk_buff *msg; +void *hdr; +int ret; + +if (WARN_ON (!xa_get_mark (&dpll_device_xa, dpll->id,DPLL_REGISTERED ))) +return -ENODEV ; + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + hdr =genlmsg_put (msg,0 ,0 , &dpll_nl_family,0 , event); +if (!hdr) + goto err_free_msg; + ret =dpll_device_get_one (dpll, msg,NULL ); +if (ret) + goto err_cancel_msg; +genlmsg_end (msg, hdr); +genlmsg_multicast (&dpll_nl_family, msg,0 ,0 ,GFP_KERNEL ); + +return 0 ; + +err_cancel_msg: +genlmsg_cancel (msg, hdr); +err_free_msg: +nlmsg_free (msg); + +return ret; +} + +int dpll_device_create_ntf (struct dpll_device *dpll) +{ +return dpll_device_event_send (DPLL_CMD_DEVICE_CREATE_NTF , dpll); +} + +int dpll_device_delete_ntf (struct dpll_device *dpll) +{ +return dpll_device_event_send (DPLL_CMD_DEVICE_DELETE_NTF , dpll); +} + +int __dpll_device_change_ntf (struct dpll_device *dpll) +{ +return dpll_device_event_send (DPLL_CMD_DEVICE_CHANGE_NTF , dpll); +} + +/** +* dpll_device_change_ntf - notify that the dpll device has been changed +* @dpll: registered dpll pointer +* +* Context: acquires and holds a dpll_lock. +* Return: 0 if succeeds, error code otherwise. +*/ +int dpll_device_change_ntf (struct dpll_device *dpll) +{ +int ret; + +mutex_lock (&dpll_lock); + ret =__dpll_device_change_ntf (dpll); +mutex_unlock (&dpll_lock); + +return ret; +} +EXPORT_SYMBOL_GPL (dpll_device_change_ntf); + +static int +dpll_pin_event_send (enum dpll_cmd event,struct dpll_pin *pin) +{ +struct sk_buff *msg; +void *hdr; +int ret; + +if (WARN_ON (!xa_get_mark (&dpll_pin_xa, pin->id,DPLL_REGISTERED ))) +return -ENODEV ; + + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + hdr =genlmsg_put (msg,0 ,0 , &dpll_nl_family,0 , event); +if (!hdr) + goto err_free_msg; + ret =dpll_cmd_pin_get_one (msg, pin,NULL ); +if (ret) + goto err_cancel_msg; +genlmsg_end (msg, hdr); +genlmsg_multicast (&dpll_nl_family, msg,0 ,0 ,GFP_KERNEL ); + +return 0 ; + +err_cancel_msg: +genlmsg_cancel (msg, hdr); +err_free_msg: +nlmsg_free (msg); + +return ret; +} + +int dpll_pin_create_ntf (struct dpll_pin *pin) +{ +return dpll_pin_event_send (DPLL_CMD_PIN_CREATE_NTF , pin); +} + +int dpll_pin_delete_ntf (struct dpll_pin *pin) +{ +return dpll_pin_event_send (DPLL_CMD_PIN_DELETE_NTF , pin); +} + +static int __dpll_pin_change_ntf (struct dpll_pin *pin) +{ +return dpll_pin_event_send (DPLL_CMD_PIN_CHANGE_NTF , pin); +} + +/** +* dpll_pin_change_ntf - notify that the pin has been changed +* @pin: registered pin pointer +* +* Context: acquires and holds a dpll_lock. +* Return: 0 if succeeds, error code otherwise. +*/ +int dpll_pin_change_ntf (struct dpll_pin *pin) +{ +int ret; + +mutex_lock (&dpll_lock); + ret =__dpll_pin_change_ntf (pin); +mutex_unlock (&dpll_lock); + +return ret; +} +EXPORT_SYMBOL_GPL (dpll_pin_change_ntf); + +static int +dpll_pin_freq_set (struct dpll_pin *pin,struct nlattr *a, +struct netlink_ext_ack *extack) +{ +u64 freq =nla_get_u64 (a); +struct dpll_pin_ref *ref; +unsigned long i; +int ret; + +if (!dpll_pin_is_freq_supported (pin, freq)) { +NL_SET_ERR_MSG_FMT (extack,"not supported freq:%llu on pin:%u" , + freq, pin->id); +return -EINVAL ; + } + +xa_for_each (&pin->dpll_refs, i, ref) { +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +struct dpll_device *dpll = ref->dpll; + +if (!ops->frequency_set) +return -EOPNOTSUPP ; + ret = ops->frequency_set (pin,dpll_pin_on_dpll_priv (dpll, pin), + dpll,dpll_priv (dpll), freq, extack); +if (ret) +return ret; +__dpll_pin_change_ntf (pin); + } + +return 0 ; +} + +static int +dpll_pin_on_pin_state_set (struct dpll_pin *pin,u32 parent_idx, +enum dpll_pin_state state, +struct netlink_ext_ack *extack) +{ +struct dpll_pin_ref *parent_ref; +const struct dpll_pin_ops *ops; +struct dpll_pin_ref *dpll_ref; +void *pin_priv, *parent_priv; +struct dpll_pin *parent; +unsigned long i; +int ret; + +if (!(DPLL_PIN_CAPS_STATE_CAN_CHANGE & pin->prop->capabilities)) { +NL_SET_ERR_MSG_FMT (extack,"pin:%u not allowed to change state" , + pin->id); +return -EOPNOTSUPP ; + } + parent =xa_load (&dpll_pin_xa, parent_idx); +if (!parent) +return -EINVAL ; + parent_ref =xa_load (&pin->parent_refs, parent->pin_idx); +if (!parent_ref) +return -EINVAL ; +xa_for_each (&parent->dpll_refs, i, dpll_ref) { + ops =dpll_pin_ops (parent_ref); +if (!ops->state_on_pin_set) +return -EOPNOTSUPP ; + pin_priv =dpll_pin_on_pin_priv (parent, pin); + parent_priv =dpll_pin_on_dpll_priv (dpll_ref->dpll, parent); + ret = ops->state_on_pin_set (pin, pin_priv, parent, parent_priv, + state, extack); +if (ret) +return ret; + } +__dpll_pin_change_ntf (pin); + +return 0 ; +} + +static int +dpll_pin_state_set (struct dpll_device *dpll,struct dpll_pin *pin, +enum dpll_pin_state state, +struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops; +struct dpll_pin_ref *ref; +int ret; + +if (!(DPLL_PIN_CAPS_STATE_CAN_CHANGE & pin->prop->capabilities)) { +NL_SET_ERR_MSG_FMT (extack,"pin:%u not allowed to change state" , + pin->id); +return -EOPNOTSUPP ; + } + ref =xa_load (&pin->dpll_refs, dpll->device_idx); +ASSERT_NOT_NULL (ref); + ops =dpll_pin_ops (ref); +if (!ops->state_on_dpll_set) +return -EOPNOTSUPP ; + ret = ops->state_on_dpll_set (pin,dpll_pin_on_dpll_priv (dpll, pin), + dpll,dpll_priv (dpll), state, extack); +if (ret) +return ret; +__dpll_pin_change_ntf (pin); + +return 0 ; +} + +static int +dpll_pin_prio_set (struct dpll_device *dpll,struct dpll_pin *pin, +u32 prio,struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops; +struct dpll_pin_ref *ref; +int ret; + +if (!(DPLL_PIN_CAPS_PRIORITY_CAN_CHANGE & pin->prop->capabilities)) { +NL_SET_ERR_MSG_FMT (extack,"pin:%u not allowed to change prio" , + pin->id); +return -EOPNOTSUPP ; + } + ref =xa_load (&pin->dpll_refs, dpll->device_idx); +ASSERT_NOT_NULL (ref); + ops =dpll_pin_ops (ref); +if (!ops->prio_set) +return -EOPNOTSUPP ; + ret = ops->prio_set (pin,dpll_pin_on_dpll_priv (dpll, pin), dpll, +dpll_priv (dpll), prio, extack); +if (ret) +return ret; +__dpll_pin_change_ntf (pin); + +return 0 ; +} + +static int +dpll_pin_direction_set (struct dpll_pin *pin,struct dpll_device *dpll, +enum dpll_pin_direction direction, +struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops; +struct dpll_pin_ref *ref; +int ret; + +if (!(DPLL_PIN_CAPS_DIRECTION_CAN_CHANGE & pin->prop->capabilities)) { +NL_SET_ERR_MSG_FMT (extack, +"pin:%u not allowed to change direction" , + pin->id); +return -EOPNOTSUPP ; + } + ref =xa_load (&pin->dpll_refs, dpll->device_idx); +ASSERT_NOT_NULL (ref); + ops =dpll_pin_ops (ref); +if (!ops->direction_set) +return -EOPNOTSUPP ; + ret = ops->direction_set (pin,dpll_pin_on_dpll_priv (dpll, pin), + dpll,dpll_priv (dpll), direction, extack); +if (ret) +return ret; +__dpll_pin_change_ntf (pin); + +return 0 ; +} + +static int +dpll_pin_parent_device_set (struct dpll_pin *pin,struct nlattr *parent_nest, +struct netlink_ext_ack *extack) +{ +struct nlattr *tb[DPLL_A_MAX +1 ]; +enum dpll_pin_direction direction; +enum dpll_pin_state state; +struct dpll_pin_ref *ref; +struct dpll_device *dpll; +u32 pdpll_idx, prio; +int ret; + +nla_parse_nested (tb,DPLL_A_MAX , parent_nest, +NULL , extack); +if (!tb[DPLL_A_ID ]) { +NL_SET_ERR_MSG (extack,"device parent id expected" ); +return -EINVAL ; + } + pdpll_idx =nla_get_u32 (tb[DPLL_A_ID ]); + dpll =xa_load (&dpll_device_xa, pdpll_idx); +if (!dpll) +return -EINVAL ; + ref =xa_load (&pin->dpll_refs, dpll->device_idx); +ASSERT_NOT_NULL (ref); +if (tb[DPLL_A_PIN_STATE ]) { + state =nla_get_u8 (tb[DPLL_A_PIN_STATE ]); + ret =dpll_pin_state_set (dpll, pin, state, extack); +if (ret) +return ret; + } +if (tb[DPLL_A_PIN_PRIO ]) { + prio =nla_get_u8 (tb[DPLL_A_PIN_PRIO ]); + ret =dpll_pin_prio_set (dpll, pin, prio, extack); +if (ret) +return ret; + } +if (tb[DPLL_A_PIN_DIRECTION ]) { + direction =nla_get_u8 (tb[DPLL_A_PIN_DIRECTION ]); + ret =dpll_pin_direction_set (pin, dpll, direction, extack); +if (ret) +return ret; + } +return 0 ; +} + +static int +dpll_pin_parent_pin_set (struct dpll_pin *pin,struct nlattr *parent_nest, +struct netlink_ext_ack *extack) +{ +struct nlattr *tb[DPLL_A_MAX +1 ]; +enum dpll_pin_state state; +u32 ppin_idx; +int ret; + +nla_parse_nested (tb,DPLL_A_MAX , parent_nest, +NULL , extack); +if (!tb[DPLL_A_PIN_ID ]) { +NL_SET_ERR_MSG (extack,"parent pin id expected" ); +return -EINVAL ; + } + ppin_idx =nla_get_u32 (tb[DPLL_A_PIN_ID ]); + state =nla_get_u8 (tb[DPLL_A_PIN_STATE ]); + ret =dpll_pin_on_pin_state_set (pin, ppin_idx, state, extack); +if (ret) +return ret; + +return 0 ; +} + +static int +dpll_pin_set_from_nlattr (struct dpll_pin *pin,struct genl_info *info) +{ +int rem, ret = -EINVAL ; +struct nlattr *a; + +nla_for_each_attr (a,genlmsg_data (info->genlhdr), +genlmsg_len (info->genlhdr), rem) { +switch (nla_type (a)) { +case DPLL_A_PIN_FREQUENCY : + ret =dpll_pin_freq_set (pin, a, info->extack); +if (ret) +return ret; +break ; +case DPLL_A_PIN_PARENT_DEVICE : + ret =dpll_pin_parent_device_set (pin, a, info->extack); +if (ret) +return ret; +break ; +case DPLL_A_PIN_PARENT_PIN : + ret =dpll_pin_parent_pin_set (pin, a, info->extack); +if (ret) +return ret; +break ; +case DPLL_A_PIN_ID : +case DPLL_A_ID : +break ; +default : +NL_SET_ERR_MSG_FMT (info->extack, +"unsupported attribute (%d)" , +nla_type (a)); +return -EINVAL ; + } + } + +return 0 ; +} + +static struct dpll_pin * +dpll_pin_find (u64 clock_id,struct nlattr *mod_name_attr, +enum dpll_pin_type type,struct nlattr *board_label, +struct nlattr *panel_label,struct nlattr *package_label, +struct netlink_ext_ack *extack) +{ +bool board_match, panel_match, package_match; +struct dpll_pin *pin_match =NULL , *pin; +const struct dpll_pin_properties *prop; +bool cid_match, mod_match, type_match; +unsigned long i; + +xa_for_each_marked (&dpll_pin_xa, i, pin,DPLL_REGISTERED ) { + prop = pin->prop; + cid_match = clock_id ? pin->clock_id == clock_id : true; + mod_match = mod_name_attr &&module_name (pin->module) ? + !nla_strcmp (mod_name_attr, +module_name (pin->module)) : true; + type_match = type ? prop->type == type : true; + board_match = board_label ? (prop->board_label ? + !nla_strcmp (board_label, prop->board_label) : false) : + true; + panel_match = panel_label ? (prop->panel_label ? + !nla_strcmp (panel_label, prop->panel_label) : false) : + true; + package_match = package_label ? (prop->package_label ? + !nla_strcmp (package_label, prop->package_label) : + false) : true; +if (cid_match && mod_match && type_match && board_match && + panel_match && package_match) { +if (pin_match) { +NL_SET_ERR_MSG (extack,"multiple matches" ); +return ERR_PTR (-EINVAL ); + } + pin_match = pin; + }; + } +if (!pin_match) { +NL_SET_ERR_MSG (extack,"not found" ); +return ERR_PTR (-ENODEV ); + } +return pin_match; +} + +static struct dpll_pin *dpll_pin_find_from_nlattr (struct genl_info *info) +{ +struct nlattr *attr, *mod_name_attr =NULL , *board_label_attr =NULL , + *panel_label_attr =NULL , *package_label_attr =NULL ; +enum dpll_pin_type type =0 ; +u64 clock_id =0 ; +int rem =0 ; + +nla_for_each_attr (attr,genlmsg_data (info->genlhdr), +genlmsg_len (info->genlhdr), rem) { +switch (nla_type (attr)) { +case DPLL_A_CLOCK_ID : +if (clock_id) + goto duplicated_attr; + clock_id =nla_get_u64 (attr); +break ; +case DPLL_A_MODULE_NAME : +if (mod_name_attr) + goto duplicated_attr; + mod_name_attr = attr; +break ; +case DPLL_A_PIN_TYPE : +if (type) + goto duplicated_attr; + type =nla_get_u8 (attr); +break ; +case DPLL_A_PIN_BOARD_LABEL : +if (board_label_attr) + goto duplicated_attr; + board_label_attr = attr; +break ; +case DPLL_A_PIN_PANEL_LABEL : +if (panel_label_attr) + goto duplicated_attr; + panel_label_attr = attr; +break ; +case DPLL_A_PIN_PACKAGE_LABEL : +if (package_label_attr) + goto duplicated_attr; + package_label_attr = attr; +break ; +default : +break ; + } + } +if (!(clock_id || mod_name_attr || board_label_attr || + panel_label_attr || package_label_attr)) { +NL_SET_ERR_MSG (info->extack,"missing attributes" ); +return ERR_PTR (-EINVAL ); + } +return dpll_pin_find (clock_id, mod_name_attr, type, board_label_attr, + panel_label_attr, package_label_attr, + info->extack); +duplicated_attr: +NL_SET_ERR_MSG (info->extack,"duplicated attribute" ); +return ERR_PTR (-EINVAL ); +} + +int dpll_nl_pin_id_get_doit (struct sk_buff *skb,struct genl_info *info) +{ +struct dpll_pin *pin; +struct sk_buff *msg; +struct nlattr *hdr; +int ret; + + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + hdr =genlmsg_put_reply (msg, info, &dpll_nl_family,0 , +DPLL_CMD_PIN_ID_GET ); +if (!hdr) +return -EMSGSIZE ; + + pin =dpll_pin_find_from_nlattr (info); +if (!IS_ERR (pin)) { + ret =dpll_msg_add_pin_handle (msg, pin); +if (ret) { +nlmsg_free (msg); +return ret; + } + } +genlmsg_end (msg, hdr); + +return genlmsg_reply (msg, info); +} + +int dpll_nl_pin_get_doit (struct sk_buff *skb,struct genl_info *info) +{ +struct dpll_pin *pin = info->user_ptr[0 ]; +struct sk_buff *msg; +struct nlattr *hdr; +int ret; + +if (!pin) +return -ENODEV ; + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + hdr =genlmsg_put_reply (msg, info, &dpll_nl_family,0 , +DPLL_CMD_PIN_GET ); +if (!hdr) +return -EMSGSIZE ; + ret =dpll_cmd_pin_get_one (msg, pin, info->extack); +if (ret) { +nlmsg_free (msg); +return ret; + } +genlmsg_end (msg, hdr); + +return genlmsg_reply (msg, info); +} + +int dpll_nl_pin_get_dumpit (struct sk_buff *skb,struct netlink_callback *cb) +{ +struct dpll_dump_ctx *ctx =dpll_dump_context (cb); +struct dpll_pin *pin; +struct nlattr *hdr; +unsigned long i; +int ret =0 ; + +xa_for_each_marked_start (&dpll_pin_xa, i, pin,DPLL_REGISTERED , + ctx->idx) { + hdr =genlmsg_put (skb,NETLINK_CB (cb->skb).portid, + cb->nlh->nlmsg_seq, + &dpll_nl_family,NLM_F_MULTI , +DPLL_CMD_PIN_GET ); +if (!hdr) { + ret = -EMSGSIZE ; +break ; + } + ret =dpll_cmd_pin_get_one (skb, pin, cb->extack); +if (ret) { +genlmsg_cancel (skb, hdr); +break ; + } +genlmsg_end (skb, hdr); + } +if (ret == -EMSGSIZE ) { + ctx->idx = i; +return skb->len; + } +return ret; +} + +int dpll_nl_pin_set_doit (struct sk_buff *skb,struct genl_info *info) +{ +struct dpll_pin *pin = info->user_ptr[0 ]; + +return dpll_pin_set_from_nlattr (pin, info); +} + +static int +dpll_set_from_nlattr (struct dpll_device *dpll,struct genl_info *info) +{ +const struct dpll_device_ops *ops =dpll_device_ops (dpll); +struct nlattr *tb[DPLL_A_MAX +1 ]; +int ret; + +nla_parse (tb,DPLL_A_MAX ,genlmsg_data (info->genlhdr), +genlmsg_len (info->genlhdr),NULL , info->extack); +if (tb[DPLL_A_MODE ]) { +if (!ops->mode_set) { +NL_SET_ERR_MSG (info->extack,"mode set not supported" ); +return -EINVAL ; + } + ret = ops->mode_set (dpll,dpll_priv (dpll), +nla_get_u8 (tb[DPLL_A_MODE ]), info->extack); +if (ret) +return ret; +__dpll_device_change_ntf (dpll); + } + +return 0 ; +} + +static struct dpll_device * +dpll_device_find (u64 clock_id,struct nlattr *mod_name_attr, +enum dpll_type type,struct netlink_ext_ack *extack) +{ +struct dpll_device *dpll_match =NULL , *dpll; +bool cid_match, mod_match, type_match; +unsigned long i; + +xa_for_each_marked (&dpll_device_xa, i, dpll,DPLL_REGISTERED ) { + cid_match = clock_id ? dpll->clock_id == clock_id : true; + mod_match = mod_name_attr ? (module_name (dpll->module) ? + !nla_strcmp (mod_name_attr, +module_name (dpll->module)) : false) : true; + type_match = type ? dpll->type == type : true; +if (cid_match && mod_match && type_match) { +if (dpll_match) { +NL_SET_ERR_MSG (extack,"multiple matches" ); +return ERR_PTR (-EINVAL ); + } + dpll_match = dpll; + } + } +if (!dpll_match) { +NL_SET_ERR_MSG (extack,"not found" ); +return ERR_PTR (-ENODEV ); + } + +return dpll_match; +} + +static struct dpll_device * +dpll_device_find_from_nlattr (struct genl_info *info) +{ +struct nlattr *attr, *mod_name_attr =NULL ; +enum dpll_type type =0 ; +u64 clock_id =0 ; +int rem =0 ; + +nla_for_each_attr (attr,genlmsg_data (info->genlhdr), +genlmsg_len (info->genlhdr), rem) { +switch (nla_type (attr)) { +case DPLL_A_CLOCK_ID : +if (clock_id) + goto duplicated_attr; + clock_id =nla_get_u64 (attr); +break ; +case DPLL_A_MODULE_NAME : +if (mod_name_attr) + goto duplicated_attr; + mod_name_attr = attr; +break ; +case DPLL_A_TYPE : +if (type) + goto duplicated_attr; + type =nla_get_u8 (attr); +break ; +default : +break ; + } + } +if (!clock_id && !mod_name_attr && !type) { +NL_SET_ERR_MSG (info->extack,"missing attributes" ); +return ERR_PTR (-EINVAL ); + } +return dpll_device_find (clock_id, mod_name_attr, type, info->extack); +duplicated_attr: +NL_SET_ERR_MSG (info->extack,"duplicated attribute" ); +return ERR_PTR (-EINVAL ); +} + +int dpll_nl_device_id_get_doit (struct sk_buff *skb,struct genl_info *info) +{ +struct dpll_device *dpll; +struct sk_buff *msg; +struct nlattr *hdr; +int ret; + + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + hdr =genlmsg_put_reply (msg, info, &dpll_nl_family,0 , +DPLL_CMD_DEVICE_ID_GET ); +if (!hdr) +return -EMSGSIZE ; + + dpll =dpll_device_find_from_nlattr (info); +if (!IS_ERR (dpll)) { + ret =dpll_msg_add_dev_handle (msg, dpll); +if (ret) { +nlmsg_free (msg); +return ret; + } + } +genlmsg_end (msg, hdr); + +return genlmsg_reply (msg, info); +} + +int dpll_nl_device_get_doit (struct sk_buff *skb,struct genl_info *info) +{ +struct dpll_device *dpll = info->user_ptr[0 ]; +struct sk_buff *msg; +struct nlattr *hdr; +int ret; + + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + hdr =genlmsg_put_reply (msg, info, &dpll_nl_family,0 , +DPLL_CMD_DEVICE_GET ); +if (!hdr) +return -EMSGSIZE ; + + ret =dpll_device_get_one (dpll, msg, info->extack); +if (ret) { +nlmsg_free (msg); +return ret; + } +genlmsg_end (msg, hdr); + +return genlmsg_reply (msg, info); +} + +int dpll_nl_device_set_doit (struct sk_buff *skb,struct genl_info *info) +{ +struct dpll_device *dpll = info->user_ptr[0 ]; + +return dpll_set_from_nlattr (dpll, info); +} + +int dpll_nl_device_get_dumpit (struct sk_buff *skb,struct netlink_callback *cb) +{ +struct dpll_dump_ctx *ctx =dpll_dump_context (cb); +struct dpll_device *dpll; +struct nlattr *hdr; +unsigned long i; +int ret =0 ; + +xa_for_each_marked_start (&dpll_device_xa, i, dpll,DPLL_REGISTERED , + ctx->idx) { + hdr =genlmsg_put (skb,NETLINK_CB (cb->skb).portid, + cb->nlh->nlmsg_seq, &dpll_nl_family, +NLM_F_MULTI ,DPLL_CMD_DEVICE_GET ); +if (!hdr) { + ret = -EMSGSIZE ; +break ; + } + ret =dpll_device_get_one (dpll, skb, cb->extack); +if (ret) { +genlmsg_cancel (skb, hdr); +break ; + } +genlmsg_end (skb, hdr); + } +if (ret == -EMSGSIZE ) { + ctx->idx = i; +return skb->len; + } +return ret; +} + +int dpll_pre_doit (const struct genl_split_ops *ops,struct sk_buff *skb, +struct genl_info *info) +{ +u32 id; + +if (GENL_REQ_ATTR_CHECK (info,DPLL_A_ID )) +return -EINVAL ; + +mutex_lock (&dpll_lock); + id =nla_get_u32 (info->attrs[DPLL_A_ID ]); + info->user_ptr[0 ] =dpll_device_get_by_id (id); +if (!info->user_ptr[0 ]) { +NL_SET_ERR_MSG (info->extack,"device not found" ); + goto unlock; + } +return 0 ; +unlock: +mutex_unlock (&dpll_lock); +return -ENODEV ; +} + +void dpll_post_doit (const struct genl_split_ops *ops,struct sk_buff *skb, +struct genl_info *info) +{ +mutex_unlock (&dpll_lock); +} + +int +dpll_lock_doit (const struct genl_split_ops *ops,struct sk_buff *skb, +struct genl_info *info) +{ +mutex_lock (&dpll_lock); + +return 0 ; +} + +void +dpll_unlock_doit (const struct genl_split_ops *ops,struct sk_buff *skb, +struct genl_info *info) +{ +mutex_unlock (&dpll_lock); +} + +int dpll_lock_dumpit (struct netlink_callback *cb) +{ +mutex_lock (&dpll_lock); + +return 0 ; +} + +int dpll_unlock_dumpit (struct netlink_callback *cb) +{ +mutex_unlock (&dpll_lock); + +return 0 ; +} + +int dpll_pin_pre_doit (const struct genl_split_ops *ops,struct sk_buff *skb, +struct genl_info *info) +{ +int ret; + +mutex_lock (&dpll_lock); +if (GENL_REQ_ATTR_CHECK (info,DPLL_A_PIN_ID )) { + ret = -EINVAL ; + goto unlock_dev; + } + info->user_ptr[0 ] =xa_load (&dpll_pin_xa, +nla_get_u32 (info->attrs[DPLL_A_PIN_ID ])); +if (!info->user_ptr[0 ]) { +NL_SET_ERR_MSG (info->extack,"pin not found" ); + ret = -ENODEV ; + goto unlock_dev; + } + +return 0 ; + +unlock_dev: +mutex_unlock (&dpll_lock); +return ret; +} + +void dpll_pin_post_doit (const struct genl_split_ops *ops,struct sk_buff *skb, +struct genl_info *info) +{ +mutex_unlock (&dpll_lock); +} + +int __init dpll_netlink_init (void ) +{ +return genl_register_family (&dpll_nl_family); +} + +void dpll_netlink_finish (void ) +{ +genl_unregister_family (&dpll_nl_family); +} + +void __exit dpll_netlink_fini(void) +{ +dpll_netlink_finish (); +}
drivers/dpll/dpll_netlink.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2023 Meta Platforms, Inc. and affiliates +* Copyright (c) 2023 Intel and affiliates +*/ + +int dpll_device_create_ntf (struct dpll_device *dpll); + +int dpll_device_delete_ntf (struct dpll_device *dpll); + +int dpll_pin_create_ntf (struct dpll_pin *pin); + +int dpll_pin_delete_ntf (struct dpll_pin *pin); + +int __init dpll_netlink_init (void ); + +void dpll_netlink_finish (void );
include/linux/dpll.h +4 -0
@@ -133,4 +133,8 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,void dpll_pin_on_pin_unregister (struct dpll_pin *parent,struct dpll_pin *pin,const struct dpll_pin_ops *ops,void *priv); +int dpll_device_change_ntf (struct dpll_device *dpll); + +int dpll_pin_change_ntf (struct dpll_pin *pin); +#endif
Signature · 1 line
2.27.0
Re: [PATCH net-next 06/11] dpll: netlink: Add DPLL framework base functions
Quoted 3 lines · Vadim Fedorenko
DPLL framework is used to represent and configure DPLL devices in systems. Each device that has DPLL and can configure inputs and outputs can use this framework.
Hi Vadim,
some minor feedback from my side.
Quoted 3 lines
Implement dpll netlink framework functions for enablement of dpll subsytem netlink family.
subsytem -> subsystem
...
Quoted 1 line
drivers/dpll/dpll_netlink.c +0
-0
...
drivers/dpll/dpll_netlink.c line 49
Quoted 10 lines
drivers/dpll/dpll_netlink.c +10
-0+/** +* dpll_msg_add_pin_handle - attach pin handle attribute to a given message +* @msg: pointer to sk_buff message to attach a pin handle +* @pin: pin pointer +* +* Return: +* * 0 - success +* * -EMSGSIZE - no space in message to attach pin handle +*/ +int dpll_msg_add_pin_handle (struct sk_buff *msg,struct dpll_pin *pin)
This function seems to only be used in this file.
Should it be static.
...
drivers/dpll/dpll_netlink.c line 160
Quoted 11 lines
drivers/dpll/dpll_netlink.c +11
-0+static int +dpll_msg_add_pin_on_dpll_state (struct sk_buff *msg,struct dpll_pin *pin, +struct dpll_pin_ref *ref, +struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +struct dpll_device *dpll = ref->dpll; +enum dpll_pin_state state; +int ret; + +
nit: one blank line is enough
...
Quoted 15 lines
drivers/dpll/dpll_netlink.c +15
-0+static int +dpll_msg_add_pin_freq (struct sk_buff *msg,struct dpll_pin *pin, +struct dpll_pin_ref *ref,struct netlink_ext_ack *extack) +{ +const struct dpll_pin_ops *ops =dpll_pin_ops (ref); +struct dpll_device *dpll = ref->dpll; +struct nlattr *nest; +int fs, ret; +u64 freq; + +if (!ops->frequency_get) +return 0 ; + ret = ops->frequency_get (pin,dpll_pin_on_dpll_priv (dpll, pin), dpll, +dpll_priv (dpll), &freq, extack); +if (ret)
drivers/dpll/dpll_netlink.c line 217
Quoted 10 lines
drivers/dpll/dpll_netlink.c +10
-0+return ret; +if (nla_put_64bit (msg,DPLL_A_PIN_FREQUENCY ,sizeof (freq), &freq,0 )) +return -EMSGSIZE ; +for (fs =0 ; fs < pin->prop->freq_supported_num; fs++) { + nest =nla_nest_start (msg,DPLL_A_PIN_FREQUENCY_SUPPORTED ); +if (!nest) +return -EMSGSIZE ; + freq = pin->prop->freq_supported[fs].min; +if (nla_put_64bit (msg,DPLL_A_PIN_FREQUENCY_MIN ,sizeof (freq), + &freq,0 )) {
nit: The indention of the line above isn't quite right.
There is one space too many.
drivers/dpll/dpll_netlink.c line 223
Quoted 6 lines
drivers/dpll/dpll_netlink.c +6
-0+nla_nest_cancel (msg, nest); +return -EMSGSIZE ; + } + freq = pin->prop->freq_supported[fs].max; +if (nla_put_64bit (msg,DPLL_A_PIN_FREQUENCY_MAX ,sizeof (freq), + &freq,0 )) {
Ditto.
Quoted 8 lines
drivers/dpll/dpll_netlink.c +8
-0+nla_nest_cancel (msg, nest); +return -EMSGSIZE ; + } +nla_nest_end (msg, nest); + } + +return 0 ; +}
...
Quoted 5 lines
drivers/dpll/dpll_netlink.c +5
-0+static int +dpll_device_event_send (enum dpll_cmd event,struct dpll_device *dpll) +{ +struct sk_buff *msg; +void *hdr;
drivers/dpll/dpll_netlink.c line 412
Quoted 10 lines
drivers/dpll/dpll_netlink.c +10
-0+int ret; + +if (WARN_ON (!xa_get_mark (&dpll_device_xa, dpll->id,DPLL_REGISTERED ))) +return -ENODEV ; + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + hdr =genlmsg_put (msg,0 ,0 , &dpll_nl_family,0 , event); +if (!hdr) + goto err_free_msg;
ret is uninitialised here, but it is used in the error path.
This is flagged by a clang-16 W=1 build, and Smatch.
Quoted 15 lines
drivers/dpll/dpll_netlink.c +15
-0+ ret =dpll_device_get_one (dpll, msg,NULL ); +if (ret) + goto err_cancel_msg; +genlmsg_end (msg, hdr); +genlmsg_multicast (&dpll_nl_family, msg,0 ,0 ,GFP_KERNEL ); + +return 0 ; + +err_cancel_msg: +genlmsg_cancel (msg, hdr); +err_free_msg: +nlmsg_free (msg); + +return ret; +}
...
drivers/dpll/dpll_netlink.c line 442
Quoted 4 lines
drivers/dpll/dpll_netlink.c +4
-0+int __dpll_device_change_ntf (struct dpll_device *dpll) +{ +return dpll_device_event_send (DPLL_CMD_DEVICE_CHANGE_NTF , dpll); +}
Should this function be static?
...
Quoted 7 lines
drivers/dpll/dpll_netlink.c +7
-0+static int +dpll_pin_event_send (enum dpll_cmd event,struct dpll_pin *pin) +{ +struct sk_buff *msg; +void *hdr; +int ret; +
drivers/dpll/dpll_netlink.c line 479
Quoted 10 lines
drivers/dpll/dpll_netlink.c +10
-0+if (WARN_ON (!xa_get_mark (&dpll_pin_xa, pin->id,DPLL_REGISTERED ))) +return -ENODEV ; + + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + hdr =genlmsg_put (msg,0 ,0 , &dpll_nl_family,0 , event); +if (!hdr) + goto err_free_msg;
It looks like ret is used uninitialised here too.
Quoted 15 lines
drivers/dpll/dpll_netlink.c +15
-0+ ret =dpll_cmd_pin_get_one (msg, pin,NULL ); +if (ret) + goto err_cancel_msg; +genlmsg_end (msg, hdr); +genlmsg_multicast (&dpll_nl_family, msg,0 ,0 ,GFP_KERNEL ); + +return 0 ; + +err_cancel_msg: +genlmsg_cancel (msg, hdr); +err_free_msg: +nlmsg_free (msg); + +return ret; +}
...
drivers/dpll/dpll_netlink.c line 1210
Quoted 3 lines
drivers/dpll/dpll_netlink.c +3
-0+void +dpll_unlock_doit (const struct genl_split_ops *ops,struct sk_buff *skb, +struct genl_info *info)
The indentation of the line above is not correct.
There are two spaces too many.
...
drivers/dpll/dpll_netlink.c line 1268
Quoted 4 lines
drivers/dpll/dpll_netlink.c +4
-0+void dpll_netlink_finish (void ) +{ +genl_unregister_family (&dpll_nl_family); +}
Should this function be static?
...
Jiri Pirko
maintainerRe: [PATCH net-next 06/11] dpll: netlink: Add DPLL framework base functions
In reply to Vadim FedorenkoThu, Jul 20, 2023 at 11:18:58AM CEST, [email protected] wrote:
[...]
Quoted 5 lines
drivers/dpll/dpll_netlink.c new file +5
-0+ +static int +dpll_pin_parent_device_set (struct dpll_pin *pin,struct nlattr *parent_nest, +struct netlink_ext_ack *extack) +{
drivers/dpll/dpll_netlink.c line 698
Quoted 10 lines
drivers/dpll/dpll_netlink.c new file +10
-0+struct nlattr *tb[DPLL_A_MAX +1 ]; +enum dpll_pin_direction direction; +enum dpll_pin_state state; +struct dpll_pin_ref *ref; +struct dpll_device *dpll; +u32 pdpll_idx, prio; +int ret; + +nla_parse_nested (tb,DPLL_A_MAX , parent_nest, +NULL , extack);
Please pass proper policy instead of NULL here.dpll_pin_parent_device_nl_policy
Quoted 32 lines
drivers/dpll/dpll_netlink.c new file +32
-0+if (!tb[DPLL_A_ID ]) { +NL_SET_ERR_MSG (extack,"device parent id expected" ); +return -EINVAL ; + } + pdpll_idx =nla_get_u32 (tb[DPLL_A_ID ]); + dpll =xa_load (&dpll_device_xa, pdpll_idx); +if (!dpll) +return -EINVAL ; + ref =xa_load (&pin->dpll_refs, dpll->device_idx); +ASSERT_NOT_NULL (ref); +if (tb[DPLL_A_PIN_STATE ]) { + state =nla_get_u8 (tb[DPLL_A_PIN_STATE ]); + ret =dpll_pin_state_set (dpll, pin, state, extack); +if (ret) +return ret; + } +if (tb[DPLL_A_PIN_PRIO ]) { + prio =nla_get_u8 (tb[DPLL_A_PIN_PRIO ]); + ret =dpll_pin_prio_set (dpll, pin, prio, extack); +if (ret) +return ret; + } +if (tb[DPLL_A_PIN_DIRECTION ]) { + direction =nla_get_u8 (tb[DPLL_A_PIN_DIRECTION ]); + ret =dpll_pin_direction_set (pin, dpll, direction, extack); +if (ret) +return ret; + } +return 0 ; +} + +static int
drivers/dpll/dpll_netlink.c line 740
Quoted 10 lines
drivers/dpll/dpll_netlink.c new file +10
-0+dpll_pin_parent_pin_set(struct dpll_pin *pin, struct nlattr *parent_nest, + struct netlink_ext_ack *extack) +{ + struct nlattr *tb[DPLL_A_MAX + 1]; +enum dpll_pin_state state; +u32 ppin_idx; +int ret; + +nla_parse_nested (tb,DPLL_A_MAX , parent_nest, +NULL , extack);
Please pass proper policy instead of NULL here.dpll_pin_parent_pin_nl_policy
Quoted 12 lines
drivers/dpll/dpll_netlink.c new file +12
-0+if (!tb[DPLL_A_PIN_ID ]) { +NL_SET_ERR_MSG (extack,"parent pin id expected" ); +return -EINVAL ; + } + ppin_idx =nla_get_u32 (tb[DPLL_A_PIN_ID ]); + state =nla_get_u8 (tb[DPLL_A_PIN_STATE ]); + ret =dpll_pin_on_pin_state_set (pin, ppin_idx, state, extack); +if (ret) +return ret; + +return 0 ; +}
[...]
Vadim Fedorenko
maintainerPATCH 7/11 netdev: expose DPLL pin handle for netdevice
In reply to Vadim FedorenkoFrom: Jiri Pirko <[email protected]>
In case netdevice represents a SyncE port, the user needs to understand the connection between netdevice and associated DPLL pin. There might me multiple netdevices pointing to the same pin, in case of VF/SF implementation.
Add a IFLA Netlink attribute to nest the DPLL pin handle, similar to how it is implemented for devlink port. Add a struct dpll_pin pointer to netdev and protect access to it by RTNL. Expose netdev_dpll_pin_set() and netdev_dpll_pin_clear() helpers to the drivers so they can set/clear the DPLL pin relationship to netdev.
Note that during the lifetime of struct dpll_pin the pin handle does not change. Therefore it is save to access it lockless. It is drivers responsibility to call netdev_dpll_pin_clear() before dpll_pin_put().
---
RFC v9->v0:
- rearrange function definition according to usagev8->v9:
- net_device->dpll_pin is only valid if IS_ENABLED(CONFIG_DPLL) fix the code in net/core/rtnetlink.c to respect that.
- move dpll_msg_add_pin_handle to "dpll: netlink" patch + export the function with this patch
drivers/dpll/dpll_netlink.c | 19 ++++++++++++++++--- include/linux/dpll.h | 20 ++++++++++++++++++++ include/linux/netdevice.h | 20 ++++++++++++++++++++ include/uapi/linux/if_link.h | 2 ++ net/core/dev.c | 22 ++++++++++++++++++++++ net/core/rtnetlink.c | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 115 insertions(+), 3 deletions(-)
drivers/dpll/dpll_netlink.c +16 -3
@@ -37,6 +37,18 @@ dpll_msg_add_dev_handle(struct sk_buff *msg, struct dpll_device *dpll)return 0 ; } +/** +* dpll_msg_pin_handle_size - get size of pin handle attribute for given pin +* @pin: pin pointer +* +* Return: byte size of pin handle attribute for given pin. +*/ +size_t dpll_msg_pin_handle_size (struct dpll_pin *pin) +{ +return pin ?nla_total_size (4 ) :0 ;/* DPLL_A_PIN_ID */ +} +EXPORT_SYMBOL_GPL (dpll_msg_pin_handle_size); +/** * dpll_msg_add_pin_handle - attach pin handle attribute to a given message * @msg: pointer to sk_buff message to attach a pin handle
@@ -54,6 +66,7 @@ int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin)return -EMSGSIZE ;return 0 ; } +EXPORT_SYMBOL_GPL (dpll_msg_add_pin_handle); static int dpll_msg_add_mode(struct sk_buff *msg, struct dpll_device *dpll,
@@ -267,10 +280,9 @@ dpll_msg_add_pin_parents(struct sk_buff *msg, struct dpll_pin *pin, nest =nla_nest_start (msg,DPLL_A_PIN_PARENT_PIN );if (!nest)return -EMSGSIZE ; -if (nla_put_u32 (msg,DPLL_A_PIN_ID , ppin->id)) { - ret = -EMSGSIZE ; + ret =dpll_msg_add_pin_handle (msg, ppin); +if (ret) goto nest_cancel; - }if (nla_put_u8 (msg,DPLL_A_PIN_STATE , state)) { ret = -EMSGSIZE ; goto nest_cancel;
@@ -330,6 +342,7 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin, ref =dpll_xa_ref_dpll_first (&pin->dpll_refs);ASSERT_NOT_NULL (ref); + ret =dpll_msg_add_pin_handle (msg, pin);if (ret)return ret;
include/linux/dpll.h +20 -0
@@ -104,6 +104,26 @@ struct dpll_pin_properties {struct dpll_pin_frequency *freq_supported; }; +#if IS_ENABLED (CONFIG_DPLL ) + +size_t dpll_msg_pin_handle_size (struct dpll_pin *pin); + +int dpll_msg_add_pin_handle (struct sk_buff *msg,struct dpll_pin *pin); + +#else + +static inline size_t dpll_msg_pin_handle_size (struct dpll_pin *pin) +{ +return 0 ; +} + +static inline int dpll_msg_add_pin_handle (struct sk_buff *msg,struct dpll_pin *pin) +{ +return 0 ; +} + +#endif +struct dpll_device *dpll_device_get (u64 clock_id,u32 dev_driver_id,struct module *module);
include/linux/netdevice.h +20 -0
@@ -34,6 +34,7 @@#include <linux/rculist.h> #include <linux/workqueue.h> #include <linux/dynamic_queue_limits.h> +#include <linux/dpll.h> #include <net/net_namespace.h> #ifdef CONFIG_DCB
@@ -2058,6 +2059,9 @@ enum netdev_ml_priv_type {* SET_NETDEV_DEVLINK_PORT macro. This pointer is static * during the time netdevice is registered. * +* @dpll_pin: Pointer to the SyncE source pin of a DPLL subsystem, +* where the clock is recovered. +* * FIXME: cleanup struct net_device such that network protocol info * moves out. */
@@ -2414,6 +2418,10 @@ struct net_device {struct rtnl_hw_stats64 *offload_xstats_l3;struct devlink_port *devlink_port; + +#if IS_ENABLED (CONFIG_DPLL ) +struct dpll_pin *dpll_pin; +#endif };#define to_net_dev (d) container_of(d, struct net_device, dev)
@@ -3961,6 +3969,18 @@ int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name);int dev_get_port_parent_id (struct net_device *dev,struct netdev_phys_item_id *ppid,bool recurse);bool netdev_port_same_parent_id (struct net_device *a,struct net_device *b); +void netdev_dpll_pin_set (struct net_device *dev,struct dpll_pin *dpll_pin); +void netdev_dpll_pin_clear (struct net_device *dev); + +static inline struct dpll_pin *netdev_dpll_pin (const struct net_device *dev) +{ +#if IS_ENABLED (CONFIG_DPLL ) +return dev->dpll_pin; +#else +return NULL ; +#endif +} +struct sk_buff *validate_xmit_skb_list (struct sk_buff *skb,struct net_device *dev,bool *again);struct sk_buff *dev_hard_start_xmit (struct sk_buff *skb,struct net_device *dev,struct netdev_queue *txq,int *ret);
include/uapi/linux/if_link.h +2 -0
@@ -377,6 +377,8 @@ enum {IFLA_GSO_IPV4_MAX_SIZE ,IFLA_GRO_IPV4_MAX_SIZE , +IFLA_DPLL_PIN , + __IFLA_MAX };
net/core/dev.c +22 -0
@@ -8952,6 +8952,28 @@ bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b) }EXPORT_SYMBOL (netdev_port_same_parent_id); +static void netdev_dpll_pin_assign (struct net_device *dev,struct dpll_pin *dpll_pin) +{ +#if IS_ENABLED (CONFIG_DPLL ) +rtnl_lock (); + dev->dpll_pin = dpll_pin; +rtnl_unlock (); +#endif +} + +void netdev_dpll_pin_set (struct net_device *dev,struct dpll_pin *dpll_pin) +{ +WARN_ON (!dpll_pin); +netdev_dpll_pin_assign (dev, dpll_pin); +} +EXPORT_SYMBOL (netdev_dpll_pin_set); + +void netdev_dpll_pin_clear (struct net_device *dev) +{ +netdev_dpll_pin_assign (dev,NULL ); +} +EXPORT_SYMBOL (netdev_dpll_pin_clear); +/** * dev_change_proto_down - set carrier according to proto_down. *
net/core/rtnetlink.c +35 -0
@@ -1055,6 +1055,15 @@ static size_t rtnl_devlink_port_size(const struct net_device *dev)return size; } +static size_t rtnl_dpll_pin_size (const struct net_device *dev) +{ +size_t size =nla_total_size (0 );/* nest IFLA_DPLL_PIN */ + + size +=dpll_msg_pin_handle_size (netdev_dpll_pin (dev)); + +return size; +} + static noinline size_t if_nlmsg_size(const struct net_device *dev,u32 ext_filter_mask) {
@@ -1111,6 +1120,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, +rtnl_prop_list_size (dev) +nla_total_size (MAX_ADDR_LEN )/* IFLA_PERM_ADDRESS */ +rtnl_devlink_port_size (dev) + +rtnl_dpll_pin_size (dev) +0 ; }
@@ -1774,6 +1784,28 @@ static int rtnl_fill_devlink_port(struct sk_buff *skb,return ret; } +static int rtnl_fill_dpll_pin (struct sk_buff *skb, +const struct net_device *dev) +{ +struct nlattr *dpll_pin_nest; +int ret; + + dpll_pin_nest =nla_nest_start (skb,IFLA_DPLL_PIN ); +if (!dpll_pin_nest) +return -EMSGSIZE ; + + ret =dpll_msg_add_pin_handle (skb,netdev_dpll_pin (dev)); +if (ret <0 ) + goto nest_cancel; + +nla_nest_end (skb, dpll_pin_nest); +return 0 ; + +nest_cancel: +nla_nest_cancel (skb, dpll_pin_nest); +return ret; +} + static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, struct net *src_net, int type, u32 pid, u32 seq, u32 change,
@@ -1916,6 +1948,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,if (rtnl_fill_devlink_port (skb, dev)) goto nla_put_failure; +if (rtnl_fill_dpll_pin (skb, dev)) + goto nla_put_failure; +nlmsg_end (skb, nlh);return 0 ;
Signature · 1 line
2.27.0
Vadim Fedorenko
maintainerRe: [PATCH net-next 07/11] netdev: expose DPLL pin handle for netdevice
Quoted 61 lines · Vadim Fedorenko
From: Jiri Pirko <[email protected]>
In case netdevice represents a SyncE port, the user needs to understand the connection between netdevice and associated DPLL pin. There might me multiple netdevices pointing to the same pin, in case of VF/SF implementation.
Add a IFLA Netlink attribute to nest the DPLL pin handle, similar to how it is implemented for devlink port. Add a struct
dpll_pinpointer to netdev and protect access to it by RTNL. Exposenetdev_dpll_pin_set()andnetdev_dpll_pin_clear()helpers to the drivers so they can set/clear the DPLL pin relationship to netdev.Note that during the lifetime of struct
dpll_pinthe pin handle does not change. Therefore it is save to access it lockless. It is drivers responsibility to callnetdev_dpll_pin_clear()beforedpll_pin_put().Signed-off-by Jiri Pirko <[email protected]>Signed-off-by Arkadiusz Kubalewski <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>---
RFCv9->v0:
- rearrange function definition according to usagev8->v9:
-net_device->dpll_pinis only valid ifIS_ENABLED(CONFIG_DPLL)fix the code innet/core/rtnetlink.cto respect that.
- movedpll_msg_add_pin_handleto "dpll: netlink" patch + export the function with this patchdrivers/dpll/dpll_netlink.c | 19 ++++++++++++++++--- include/linux/dpll.h | 20 ++++++++++++++++++++ include/linux/netdevice.h | 20 ++++++++++++++++++++ include/uapi/linux/if_link.h | 2 ++ net/core/dev.c | 22 ++++++++++++++++++++++ net/core/rtnetlink.c | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 115 insertions(+), 3 deletions(-)drivers/dpll/dpll_netlink.c +12
-0@@ -37,6 +37,18 @@ dpll_msg_add_dev_handle(struct sk_buff *msg, struct dpll_device *dpll)return 0 ; } +/** +* dpll_msg_pin_handle_size - get size of pin handle attribute for given pin +* @pin: pin pointer +* +* Return: byte size of pin handle attribute for given pin. +*/ +size_t dpll_msg_pin_handle_size (struct dpll_pin *pin) +{ +return pin ?nla_total_size (4 ) :0 ;/* DPLL_A_PIN_ID */ +} +EXPORT_SYMBOL_GPL (dpll_msg_pin_handle_size); +/** * dpll_msg_add_pin_handle - attach pin handle attribute to a given message * @msg: pointer to sk_buff message to attach a pin handle
drivers/dpll/dpll_netlink.c int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin) · line 69
Quoted 4 lines
drivers/dpll/dpll_netlink.c +1
-0@@ -54,6 +66,7 @@ int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin)return -EMSGSIZE ;return 0 ; } +EXPORT_SYMBOL_GPL (dpll_msg_add_pin_handle);
Jiri, could you please remind me what is the reason to export this function? Because I cannot any usage of this function in drivers.
[....]
Vadim Fedorenko
maintainerRe: [PATCH net-next 07/11] netdev: expose DPLL pin handle for netdevice
Quoted 63 lines · Vadim Fedorenko
Quoted 62 lines · Vadim Fedorenko
From: Jiri Pirko <[email protected]>
In case netdevice represents a SyncE port, the user needs to understand the connection between netdevice and associated DPLL pin. There might me multiple netdevices pointing to the same pin, in case of VF/SF implementation.
Add a IFLA Netlink attribute to nest the DPLL pin handle, similar to how it is implemented for devlink port. Add a struct
dpll_pinpointer to netdev and protect access to it by RTNL. Exposenetdev_dpll_pin_set()andnetdev_dpll_pin_clear()helpers to the drivers so they can set/clear the DPLL pin relationship to netdev.Note that during the lifetime of struct
dpll_pinthe pin handle does not change. Therefore it is save to access it lockless. It is drivers responsibility to callnetdev_dpll_pin_clear()beforedpll_pin_put().Signed-off-by Jiri Pirko <[email protected]>Signed-off-by Arkadiusz Kubalewski <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>---
RFCv9->v0:
- rearrange function definition according to usagev8->v9:
-net_device->dpll_pinis only valid ifIS_ENABLED(CONFIG_DPLL)fix the code innet/core/rtnetlink.cto respect that.
- movedpll_msg_add_pin_handleto "dpll: netlink" patch + export the function with this patchdrivers/dpll/dpll_netlink.c | 19 ++++++++++++++++--- include/linux/dpll.h | 20 ++++++++++++++++++++ include/linux/netdevice.h | 20 ++++++++++++++++++++
include/uapi/linux/if_link.h| 2 ++
net/core/dev.c | 22 ++++++++++++++++++++++ net/core/rtnetlink.c | 35 +++++++++++++++++++++++++++++++++++6 files changed, 115 insertions(+), 3 deletions(-)drivers/dpll/dpll_netlink.c +2
-0@@ -37,6 +37,18 @@ dpll_msg_add_dev_handle(struct sk_buff *msg, struct dpll_device *dpll) return 0; } +/** +* dpll_msg_pin_handle_size - get size of pin handle attribute for given pin
+ * @pin: pin pointer
+ *
+ * Return: byte size of pin handle attribute for given pin.
+ */drivers/dpll/dpll_netlink.c +6
-0+size_t dpll_msg_pin_handle_size (struct dpll_pin *pin) +{ + return pin ? nla_total_size(4) : 0; /* DPLL_A_PIN_ID */ +} +EXPORT_SYMBOL_GPL (dpll_msg_pin_handle_size); +/**
*dpll_msg_add_pin_handle- attach pin handle attribute to a given message
* @msg: pointer tosk_buffmessage to attach a pin handledrivers/dpll/dpll_netlink.c +0
-0@@ -54,6 +66,7 @@ int dpll_msg_add_pin_handle(struct sk_buff *msg,
Quoted 9 lines
drivers/dpll/dpll_netlink.c int dpll_msg_add_pin_handle(struct sk_buff *msg, struct dpll_pin *pin) · line 69
Quoted 5 lines
drivers/dpll/dpll_netlink.c +1
-0struct dpll_pin *pin) return -EMSGSIZE; return 0; } +EXPORT_SYMBOL_GPL (dpll_msg_add_pin_handle);Jiri, could you please remind me what is the reason to export this function? Because I cannot any usage of this function in drivers.
Ah, found it, sorry for the noise.
Quoted 2 lines
[....]
Vadim Fedorenko
maintainerPATCH 8/11 ice: add admin commands to access cgu configuration
In reply to Vadim FedorenkoFrom: Arkadiusz Kubalewski <[email protected]>
Add firmware admin command to access clock generation unit configuration, it is required to enable Extended PTP and SyncE features in the driver.
Add definitions of possible hardware variations of input and output pins related to clock generation unit and functions to access the data.
---
RFC v9->v0:
- add support for DPLL_MODE_FREERUN mode
- remove freq from ice_aq_get_phy_rec_clk_out() as no longer supported
- add node_handle out argument to ice_aq_get_phy_rec_clk_out()
v8->v9:
- rename MAX_NETLIST_SIZE -> ICE_MAX_NETLIST_SIZE
- simplify function: s64 convert_s48_to_s64(s64 signed_48)
- do not assign 0 to field that is already 0
drivers/net/ethernet/intel/ice/ice.h | 2 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 245 ++++++++- drivers/net/ethernet/intel/ice/ice_common.c | 467 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_common.h | 44 ++ drivers/net/ethernet/intel/ice/ice_lib.c | 17 +- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 419 ++++++++++++++++ drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 231 +++++++++ drivers/net/ethernet/intel/ice/ice_type.h | 1 + 8 files changed, 1421 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +2 -0
@@ -198,7 +198,9 @@enum ice_feature {ICE_F_DSCP ,ICE_F_PTP_EXTTS , +ICE_F_PHY_RCLK ,ICE_F_SMA_CTRL , +ICE_F_CGU ,ICE_F_GNSS ,ICE_F_MAX };
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +244 -1
293 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_common.c +467 -0
485 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_common.h +44 -0
56 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.c +13 -4
@@ -4030,13 +4030,22 @@ void ice_init_feature_support(struct ice_pf *pf)case ICE_DEV_ID_E810C_BACKPLANE :case ICE_DEV_ID_E810C_QSFP :case ICE_DEV_ID_E810C_SFP : +case ICE_DEV_ID_E810_XXV_BACKPLANE : +case ICE_DEV_ID_E810_XXV_QSFP : +case ICE_DEV_ID_E810_XXV_SFP :ice_set_feature_support (pf,ICE_F_DSCP );ice_set_feature_support (pf,ICE_F_PTP_EXTTS ); -if (ice_is_e810t (&pf->hw)) { +if (ice_is_phy_rclk_present (&pf->hw)) +ice_set_feature_support (pf,ICE_F_PHY_RCLK ); +/* If we don't own the timer - don't enable other caps */ +if (!pf->hw.func_caps.ts_func_info.src_tmr_owned) +break ; +if (ice_is_cgu_present (&pf->hw)) +ice_set_feature_support (pf,ICE_F_CGU ); +if (ice_is_clock_mux_present_e810t (&pf->hw))ice_set_feature_support (pf,ICE_F_SMA_CTRL ); -if (ice_gnss_is_gps_present (&pf->hw)) -ice_set_feature_support (pf,ICE_F_GNSS ); - } +if (ice_gnss_is_gps_present (&pf->hw)) +ice_set_feature_support (pf,ICE_F_GNSS );break ;default :break ;
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +419 -0
428 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +231 -0
249 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -963,6 +963,7 @@ struct ice_hw {DECLARE_BITMAP (hw_ptype,ICE_FLOW_PTYPE_MAX );u8 dvm_ena;u16 io_expander_handle; +u8 cgu_part_number; };/* Statistics collected by each port, VSI, VEB, and S-channel */
Signature · 1 line
2.27.0
Re: [PATCH net-next 08/11] ice: add admin commands to access cgu configuration
On Thu, Jul 20, 2023 at 10:19:00AM +0100, Vadim Fedorenko wrote:
...
Hi Vadim,
Quoted 1 line
drivers/net/ethernet/intel/ice/ice_common.c +0
-0
...
Quoted 6 lines
+/**
+ *ice_aq_get_cgu_dpll_status
+ * @hw: pointer to the HW struct
+ * @dpll_num: DPLL index
+ * @ref_state: Reference clock state
+ * @dpll_state: DPLL state
./scripts/kernel-doc says that @config is missing here.
Quoted 9 lines
+ * @phase_offset: Phase offset in ns
+ * @eec_mode:EEC_mode
+ *
+ * Get CGU DPLL status (0x0C66)
+ */drivers/net/ethernet/intel/ice/ice_common.c +4
-0+int +ice_aq_get_cgu_dpll_status (struct ice_hw *hw,u8 dpll_num,u8 *ref_state, +u8 *dpll_state,u8 *config,s64 *phase_offset, +u8 *eec_mode)
...
Quoted 1 line
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0
-0
...
Quoted 7 lines
+/**
+ *ice_get_cgu_state- get the state of the DPLL
+ * @hw: pointer to the hw struct
+ * @dpll_idx: Index of internal DPLL unit
+ * @last_dpll_state: last known state of DPLL
+ * @pin: pointer to a buffer for returning currently active pin
+ * @ref_state: reference clock state
Likewise, @eec_mode is missing here.
Quoted 2 lines
+ * @phase_offset: pointer to a buffer for returning phase offset
+ * @dpll_state: state of the DPLL (output)
And @mode is missing here.
Quoted 12 lines
+ *
+ * This function will read the state of theDPLL(dpll_idx). Non-null
+ * 'pin', 'ref_state', 'eec_mode' and 'phase_offset' parameters are used to
+ * retrieve currently active pin, state, mode andphase_offsetrespectively.
+ *
+ * Return: state of the DPLL
+ */drivers/net/ethernet/intel/ice/ice_ptp_hw.c +5
-0+int ice_get_cgu_state (struct ice_hw *hw,u8 dpll_idx, +enum dpll_lock_status last_dpll_state,u8 *pin, +u8 *ref_state,u8 *eec_mode,s64 *phase_offset, +enum dpll_lock_status *dpll_state, +enum dpll_mode *mode)
drivers/net/ethernet/intel/ice/ice_ptp_hw.c int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready) · line 3694
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +10
-0+{ +u8 hw_ref_state, hw_dpll_state, hw_eec_mode, hw_config; +s64 hw_phase_offset; +int status; + + status =ice_aq_get_cgu_dpll_status (hw, dpll_idx, &hw_ref_state, + &hw_dpll_state, &hw_config, + &hw_phase_offset, &hw_eec_mode); +if (status) { + *dpll_state =ICE_CGU_STATE_INVALID ;
dpll_state is of type enum dpll_lock_status.
But the type of ICE_CGU_STATE_INVALID is enum ice_cgu_state. Is this intended?
As flagged by gcc-12 W=1 and clang-16 W=1 builds.
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +4
-0+return status; + } + +if (pin)
drivers/net/ethernet/intel/ice/ice_ptp_hw.c int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready) · line 3708
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +10
-0+/* current ref pin in dpll_state_refsel_status_X register */ + *pin = hw_config &ICE_AQC_GET_CGU_DPLL_CONFIG_CLK_REF_SEL ; +if (phase_offset) + *phase_offset = hw_phase_offset; +if (ref_state) + *ref_state = hw_ref_state; +if (eec_mode) + *eec_mode = hw_eec_mode; +if (!dpll_state) +return status;
Here dpll_state is checked for NULL.
But, above, it is dereferenced in the case where ice_aq_get_cgu_dpll_status fails. Is that safe?
Also, perhaps it makes things a bit clearer to return 0 here.
...
Quoted 1 line
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0
-0
...
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +5
-0+static const struct ice_cgu_pin_desc ice_e810t_sfp_cgu_inputs[] = { + {"CVL-SDP22" ,ZL_REF0P ,DPLL_PIN_TYPE_INT_OSCILLATOR , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"CVL-SDP20" ,ZL_REF0N ,DPLL_PIN_TYPE_INT_OSCILLATOR , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common },
drivers/net/ethernet/intel/ice/ice_ptp_hw.h struct ice_cgu_pll_params_e822 { · line 230
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +10
-0+ { "C827_0-RCLKA", ZL_REF1P, DPLL_PIN_TYPE_MUX, 0, }, + { "C827_0-RCLKB", ZL_REF1N, DPLL_PIN_TYPE_MUX, 0, }, + { "SMA1", ZL_REF3P, DPLL_PIN_TYPE_EXT, + ARRAY_SIZE(ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + { "SMA2/U.FL2", ZL_REF3N, DPLL_PIN_TYPE_EXT, + ARRAY_SIZE(ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + { "GNSS-1PPS", ZL_REF4P, DPLL_PIN_TYPE_GNSS, + ARRAY_SIZE(ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + { "OCXO", ZL_REF4N, DPLL_PIN_TYPE_INT_OSCILLATOR, 0, }, +};
A gcc-12 W=1 build warns that ice_e810t_sfp_cgu_inputs, and the similar static variables below, are unused when ice_ptp_hw.h is included in ice_main.c via ice.h.
Looking at ice_e823_zl_cgu_outputs[], it seems to only be used in ice_ptp_hw.c, so perhaps it could be defined there.
Perhaps that is also true of the other static variables below, but I didn't check that.
Quoted 101 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +98
-0+ +static const struct ice_cgu_pin_desc ice_e810t_qsfp_cgu_inputs[] = { + {"CVL-SDP22" ,ZL_REF0P ,DPLL_PIN_TYPE_INT_OSCILLATOR , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"CVL-SDP20" ,ZL_REF0N ,DPLL_PIN_TYPE_INT_OSCILLATOR , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"C827_0-RCLKA" ,ZL_REF1P ,DPLL_PIN_TYPE_MUX , }, + {"C827_0-RCLKB" ,ZL_REF1N ,DPLL_PIN_TYPE_MUX , }, + {"C827_1-RCLKA" ,ZL_REF2P ,DPLL_PIN_TYPE_MUX , }, + {"C827_1-RCLKB" ,ZL_REF2N ,DPLL_PIN_TYPE_MUX , }, + {"SMA1" ,ZL_REF3P ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"SMA2/U.FL2" ,ZL_REF3N ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"GNSS-1PPS" ,ZL_REF4P ,DPLL_PIN_TYPE_GNSS , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"OCXO" ,ZL_REF4N ,DPLL_PIN_TYPE_INT_OSCILLATOR , }, +}; + +static const struct ice_cgu_pin_desc ice_e810t_sfp_cgu_outputs[] = { + {"REF-SMA1" ,ZL_OUT0 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"REF-SMA2/U.FL2" ,ZL_OUT1 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"PHY-CLK" ,ZL_OUT2 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT , }, + {"MAC-CLK" ,ZL_OUT3 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT , }, + {"CVL-SDP21" ,ZL_OUT4 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"CVL-SDP23" ,ZL_OUT5 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, +}; + +static const struct ice_cgu_pin_desc ice_e810t_qsfp_cgu_outputs[] = { + {"REF-SMA1" ,ZL_OUT0 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"REF-SMA2/U.FL2" ,ZL_OUT1 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"PHY-CLK" ,ZL_OUT2 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"PHY2-CLK" ,ZL_OUT3 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"MAC-CLK" ,ZL_OUT4 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"CVL-SDP21" ,ZL_OUT5 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"CVL-SDP23" ,ZL_OUT6 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, +}; + +static const struct ice_cgu_pin_desc ice_e823_si_cgu_inputs[] = { + {"NONE" ,SI_REF0P ,0 ,0 }, + {"NONE" ,SI_REF0N ,0 ,0 }, + {"SYNCE0_DP" ,SI_REF1P ,DPLL_PIN_TYPE_MUX ,0 }, + {"SYNCE0_DN" ,SI_REF1N ,DPLL_PIN_TYPE_MUX ,0 }, + {"EXT_CLK_SYNC" ,SI_REF2P ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"NONE" ,SI_REF2N ,0 ,0 }, + {"EXT_PPS_OUT" ,SI_REF3 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"INT_PPS_OUT" ,SI_REF4 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, +}; + +static const struct ice_cgu_pin_desc ice_e823_si_cgu_outputs[] = { + {"1588-TIME_SYNC" ,SI_OUT0 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"PHY-CLK" ,SI_OUT1 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"10MHZ-SMA2" ,SI_OUT2 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_10_mhz), ice_cgu_pin_freq_10_mhz }, + {"PPS-SMA1" ,SI_OUT3 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, +}; + +static const struct ice_cgu_pin_desc ice_e823_zl_cgu_inputs[] = { + {"NONE" ,ZL_REF0P ,0 ,0 }, + {"INT_PPS_OUT" ,ZL_REF0N ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"SYNCE0_DP" ,ZL_REF1P ,DPLL_PIN_TYPE_MUX ,0 }, + {"SYNCE0_DN" ,ZL_REF1N ,DPLL_PIN_TYPE_MUX ,0 }, + {"NONE" ,ZL_REF2P ,0 ,0 }, + {"NONE" ,ZL_REF2N ,0 ,0 }, + {"EXT_CLK_SYNC" ,ZL_REF3P ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"NONE" ,ZL_REF3N ,0 ,0 }, + {"EXT_PPS_OUT" ,ZL_REF4P ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"OCXO" ,ZL_REF4N ,DPLL_PIN_TYPE_INT_OSCILLATOR ,0 }, +}; + +static const struct ice_cgu_pin_desc ice_e823_zl_cgu_outputs[] = { + {"PPS-SMA1" ,ZL_OUT0 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"10MHZ-SMA2" ,ZL_OUT1 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_10_mhz), ice_cgu_pin_freq_10_mhz }, + {"PHY-CLK" ,ZL_OUT2 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"1588-TIME_REF" ,ZL_OUT3 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"CPK-TIME_SYNC" ,ZL_OUT4 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"NONE" ,ZL_OUT5 ,0 ,0 }, +}; +extern const struct ice_cgu_pll_params_e822 e822_cgu_params[NUM_ICE_TIME_REF_FREQ ];
...
Kubalewski, Arkadiusz
maintainerRE: [PATCH net-next 08/11] ice: add admin commands to access cgu configuration
Quoted 14 lines
From: Simon Horman <[email protected]>
Sent: Monday, July 24, 2023 7:22 PMOn Thu, Jul 20, 2023 at 10:19:00AM +0100, Vadim Fedorenko wrote:
...
Hi Vadim,
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/net/ethernet/intel/ice/ice_common.c...
Quoted 9 lines
Quoted 6 lines
+/**
+ *ice_aq_get_cgu_dpll_status
+ * @hw: pointer to the HW struct
+ * @dpll_num: DPLL index
+ * @ref_state: Reference clock state
+ * @dpll_state: DPLL state
./scripts/kernel-docsays that @config is missing here.
Sure, will fix.
Quoted 26 lines
Review
Quoted 7 lines
+ * @phase_offset: Phase offset in ns
+ * @eec_mode:EEC_mode
+ *
+ * Get CGU DPLL status (0x0C66)
+ */(quoted diff) +2
-0+int +ice_aq_get_cgu_dpll_status(struct ice_hw *hw, u8 dpll_num, u8
*ref_state,Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_common.c +2
-0+ u8 *dpll_state, u8 *config, s64 *phase_offset, + u8 *eec_mode)...
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c...
Quoted 7 lines
+/**
+ *ice_get_cgu_state- get the state of the DPLL
+ * @hw: pointer to the hw struct
+ * @dpll_idx: Index of internal DPLL unit
+ * @last_dpll_state: last known state of DPLL
+ * @pin: pointer to a buffer for returning currently active pin
+ * @ref_state: reference clock state
Quoted 1 line
Likewise, @eec_mode is missing here.
Sure, will fix.
Quoted 6 lines
Quoted 3 lines
+ * @phase_offset: pointer to a buffer for returning phase offset
+ * @dpll_state: state of the DPLL (output)And @mode is missing here.
Sure, will fix.
Quoted 27 lines
Quoted 12 lines
+ *
+ * This function will read the state of theDPLL(dpll_idx). Non-null
+ * 'pin', 'ref_state', 'eec_mode' and 'phase_offset' parameters are used to
+ * retrieve currently active pin, state, mode andphase_offsetrespectively.
+ *
+ * Return: state of the DPLL
+ */drivers/net/ethernet/intel/ice/ice_ptp_hw.c +5
-0+int ice_get_cgu_state (struct ice_hw *hw,u8 dpll_idx, +enum dpll_lock_status last_dpll_state,u8 *pin, +u8 *ref_state,u8 *eec_mode,s64 *phase_offset, +enum dpll_lock_status *dpll_state, +enum dpll_mode *mode)drivers/net/ethernet/intel/ice/ice_ptp_hw.c int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready) · line 3694
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +10
-0+{ +u8 hw_ref_state, hw_dpll_state, hw_eec_mode, hw_config; +s64 hw_phase_offset; +int status; + + status =ice_aq_get_cgu_dpll_status (hw, dpll_idx, &hw_ref_state, + &hw_dpll_state, &hw_config, + &hw_phase_offset, &hw_eec_mode); +if (status) { + *dpll_state =ICE_CGU_STATE_INVALID ;
dpll_stateis of type enumdpll_lock_status.
But the type ofICE_CGU_STATE_INVALIDis enumice_cgu_state. Is this intended?
Quoted 2 lines
As flagged by gcc-12 W=1 and clang-16 W=1 builds.
No it's leftover, thanks for catching!
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +10
-0+return status; + } + +if (pin) +/* current ref pin in dpll_state_refsel_status_X register */ + *pin = hw_config &ICE_AQC_GET_CGU_DPLL_CONFIG_CLK_REF_SEL ; +if (phase_offset) + *phase_offset = hw_phase_offset; +if (ref_state) + *ref_state = hw_ref_state;
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready) · line 3708
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +4
-0+if (eec_mode) + *eec_mode = hw_eec_mode; +if (!dpll_state) +return status;Here
dpll_stateis checked for NULL.
But, above, it is dereferenced in the case whereice_aq_get_cgu_dpll_statusfails. Is that safe?
Yes, will fix.
Quoted 1 line
Also, perhaps it makes things a bit clearer to return 0 here.
True, will fix.
Quoted 28 lines
...
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h...
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +5
-0+static const struct ice_cgu_pin_desc ice_e810t_sfp_cgu_inputs[] = { + {"CVL-SDP22" ,ZL_REF0P ,DPLL_PIN_TYPE_INT_OSCILLATOR , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"CVL-SDP20" ,ZL_REF0N ,DPLL_PIN_TYPE_INT_OSCILLATOR , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common },drivers/net/ethernet/intel/ice/ice_ptp_hw.h struct ice_cgu_pll_params_e822 { · line 230
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +10
-0+ { "C827_0-RCLKA", ZL_REF1P, DPLL_PIN_TYPE_MUX, 0, }, + { "C827_0-RCLKB", ZL_REF1N, DPLL_PIN_TYPE_MUX, 0, }, + { "SMA1", ZL_REF3P, DPLL_PIN_TYPE_EXT, + ARRAY_SIZE(ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + { "SMA2/U.FL2", ZL_REF3N, DPLL_PIN_TYPE_EXT, + ARRAY_SIZE(ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + { "GNSS-1PPS", ZL_REF4P, DPLL_PIN_TYPE_GNSS, + ARRAY_SIZE(ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + { "OCXO", ZL_REF4N, DPLL_PIN_TYPE_INT_OSCILLATOR, 0, }, +};A gcc-12 W=1 build warns that
ice_e810t_sfp_cgu_inputs, and the similar static variables below, are unused whenice_ptp_hw.his included inice_main.cviaice.h.
Quoted 5 lines
Looking at ice_e823_zl_cgu_outputs[], it seems to only be used in
ice_ptp_hw.c, so perhaps it could be defined there.Perhaps that is also true of the other static variables below, but I didn't check that.
Yes, great catches, will fix.
Thank you for all of them!
Arkadiusz
Quoted 104 lines
Quoted 102 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +98
-0+ +static const struct ice_cgu_pin_desc ice_e810t_qsfp_cgu_inputs[] = { + {"CVL-SDP22" ,ZL_REF0P ,DPLL_PIN_TYPE_INT_OSCILLATOR , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"CVL-SDP20" ,ZL_REF0N ,DPLL_PIN_TYPE_INT_OSCILLATOR , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"C827_0-RCLKA" ,ZL_REF1P ,DPLL_PIN_TYPE_MUX , }, + {"C827_0-RCLKB" ,ZL_REF1N ,DPLL_PIN_TYPE_MUX , }, + {"C827_1-RCLKA" ,ZL_REF2P ,DPLL_PIN_TYPE_MUX , }, + {"C827_1-RCLKB" ,ZL_REF2N ,DPLL_PIN_TYPE_MUX , }, + {"SMA1" ,ZL_REF3P ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"SMA2/U.FL2" ,ZL_REF3N ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"GNSS-1PPS" ,ZL_REF4P ,DPLL_PIN_TYPE_GNSS , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"OCXO" ,ZL_REF4N ,DPLL_PIN_TYPE_INT_OSCILLATOR , }, +}; + +static const struct ice_cgu_pin_desc ice_e810t_sfp_cgu_outputs[] = { + {"REF-SMA1" ,ZL_OUT0 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"REF-SMA2/U.FL2" ,ZL_OUT1 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"PHY-CLK" ,ZL_OUT2 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT , }, + {"MAC-CLK" ,ZL_OUT3 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT , }, + {"CVL-SDP21" ,ZL_OUT4 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"CVL-SDP23" ,ZL_OUT5 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, +}; + +static const struct ice_cgu_pin_desc ice_e810t_qsfp_cgu_outputs[] = { + {"REF-SMA1" ,ZL_OUT0 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"REF-SMA2/U.FL2" ,ZL_OUT1 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"PHY-CLK" ,ZL_OUT2 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"PHY2-CLK" ,ZL_OUT3 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"MAC-CLK" ,ZL_OUT4 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"CVL-SDP21" ,ZL_OUT5 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"CVL-SDP23" ,ZL_OUT6 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, +}; + +static const struct ice_cgu_pin_desc ice_e823_si_cgu_inputs[] = { + {"NONE" ,SI_REF0P ,0 ,0 }, + {"NONE" ,SI_REF0N ,0 ,0 }, + {"SYNCE0_DP" ,SI_REF1P ,DPLL_PIN_TYPE_MUX ,0 }, + {"SYNCE0_DN" ,SI_REF1N ,DPLL_PIN_TYPE_MUX ,0 }, + {"EXT_CLK_SYNC" ,SI_REF2P ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"NONE" ,SI_REF2N ,0 ,0 }, + {"EXT_PPS_OUT" ,SI_REF3 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"INT_PPS_OUT" ,SI_REF4 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, +}; + +static const struct ice_cgu_pin_desc ice_e823_si_cgu_outputs[] = { + {"1588-TIME_SYNC" ,SI_OUT0 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"PHY-CLK" ,SI_OUT1 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"10MHZ-SMA2" ,SI_OUT2 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_10_mhz), ice_cgu_pin_freq_10_mhz }, + {"PPS-SMA1" ,SI_OUT3 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, +}; + +static const struct ice_cgu_pin_desc ice_e823_zl_cgu_inputs[] = { + {"NONE" ,ZL_REF0P ,0 ,0 }, + {"INT_PPS_OUT" ,ZL_REF0N ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"SYNCE0_DP" ,ZL_REF1P ,DPLL_PIN_TYPE_MUX ,0 }, + {"SYNCE0_DN" ,ZL_REF1N ,DPLL_PIN_TYPE_MUX ,0 }, + {"NONE" ,ZL_REF2P ,0 ,0 }, + {"NONE" ,ZL_REF2N ,0 ,0 }, + {"EXT_CLK_SYNC" ,ZL_REF3P ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"NONE" ,ZL_REF3N ,0 ,0 }, + {"EXT_PPS_OUT" ,ZL_REF4P ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"OCXO" ,ZL_REF4N ,DPLL_PIN_TYPE_INT_OSCILLATOR ,0 }, +}; + +static const struct ice_cgu_pin_desc ice_e823_zl_cgu_outputs[] = { + {"PPS-SMA1" ,ZL_OUT0 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_1_hz), ice_cgu_pin_freq_1_hz }, + {"10MHZ-SMA2" ,ZL_OUT1 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_10_mhz), ice_cgu_pin_freq_10_mhz }, + {"PHY-CLK" ,ZL_OUT2 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"1588-TIME_REF" ,ZL_OUT3 ,DPLL_PIN_TYPE_SYNCE_ETH_PORT ,0 }, + {"CPK-TIME_SYNC" ,ZL_OUT4 ,DPLL_PIN_TYPE_EXT , +ARRAY_SIZE (ice_cgu_pin_freq_common), ice_cgu_pin_freq_common }, + {"NONE" ,ZL_OUT5 ,0 ,0 }, +}; +extern const struct ice_cgu_pll_params_e822 e822_cgu_params[NUM_ICE_TIME_REF_FREQ ];...
Vadim Fedorenko
maintainerPATCH 9/11 ice: implement dpll interface to control cgu
In reply to Vadim FedorenkoFrom: Arkadiusz Kubalewski <[email protected]>
Control over clock generation unit is required for further development of Synchronous Ethernet feature. Interface provides ability to obtain current state of a dpll, its sources and outputs which are pins, and allows their configuration.
---
RFC v9->v0:
- add support for DPLL_MODE_FREERUN mode
- use DPLL_LOCK_STATUS, remove ICE_DPLL_LOCK_STATUS
- fix mutex locking scheme
- remove rclk pin label
- fix/remmove struct fields descriptions
v8->v9:
- drop pointless 0 assignement
- ice_dpll_init(..) returns void instead of int
- fix context description of the functions
- fix ice_dpll_init(..) traces
- fix use package_label instead pf board_label for rclk pin
- be consistent on cgu presence naming
- remove indent in ice_dpll_deinit(..)
- remove unused struct field lock_err_num
- fix kworker resched behavior
- remove debug log from ice_dpll_deinit_worker(..)
- reorder ice internal functions
- release resources directly on error path
- remove redundant NULL checks when releasing resources
- do not assign NULL to pointers after releasing resources
- simplify variable assignement
- fix 'int ret;' declarations across the ice_dpll.c
- remove leftover ice_dpll_find(..)
- get pf pointer from dpll_priv without type cast
- improve error reporting
- fix documentation
- fix ice_dpll_update_state(..) flow
- fix return in case out of range prio set
drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 3 + drivers/net/ethernet/intel/ice/ice_dpll.c | 2053 +++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_dpll.h | 104 ++ drivers/net/ethernet/intel/ice/ice_main.c | 7 + 6 files changed, 2170 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_dpll.c create mode 100644 drivers/net/ethernet/intel/ice/ice_dpll.h
drivers/net/ethernet/intel/Kconfig +1 -0
@@ -284,6 +284,7 @@ config ICE select DIMLIB select NET_DEVLINK select PLDMFW + select DPLL help This driver supports Intel(R) Ethernet Connection E800 Series of devices. For more information on how to identify your adapter, go
drivers/net/ethernet/intel/ice/Makefile +2 -1
@@ -34,7 +34,8 @@ ice-y := ice_main.o \ ice_lag.o \ ice_ethtool.o \ ice_repr.o \ - ice_tc_lib.o + ice_tc_lib.o \ + ice_dpll.o ice-$(CONFIG_PCI_IOV) += \ ice_sriov.o \ ice_virtchnl.o \
drivers/net/ethernet/intel/ice/ice.h +3 -0
@@ -76,6 +76,7 @@#include "ice_vsi_vlan_ops.h" #include "ice_gnss.h" #include "ice_irq.h" +#include "ice_dpll.h" #define ICE_BAR0 0#define ICE_REQ_DESC_MULTIPLE 32
@@ -507,6 +508,7 @@ enum ice_pf_flags {ICE_FLAG_UNPLUG_AUX_DEV ,ICE_FLAG_MTU_CHANGED ,ICE_FLAG_GNSS ,/* GNSS successfully initialized */ +ICE_FLAG_DPLL ,/* SyncE/PTP dplls initialized */ ICE_PF_FLAGS_NBITS /* must be last */ };
@@ -636,6 +638,7 @@ struct ice_pf {#define ICE_VF_AGG_NODE_ID_START 65#define ICE_MAX_VF_AGG_NODES 32struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES ]; +struct ice_dplls dplls; };struct ice_netdev_priv {
drivers/net/ethernet/intel/ice/ice_dpll.c new file +2053 -0
2,053 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_dpll.h new file +104 -0
104 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +7 -0
@@ -4613,6 +4613,10 @@ static void ice_init_features(struct ice_pf *pf)if (ice_is_feature_supported (pf,ICE_F_GNSS ))ice_gnss_init (pf); +if (ice_is_feature_supported (pf,ICE_F_CGU ) || +ice_is_feature_supported (pf,ICE_F_PHY_RCLK )) +ice_dpll_init (pf); +/* Note: Flow director init failure is non-fatal to load */ if (ice_init_fdir (pf))dev_err (dev,"could not initialize flow director\n" );
@@ -4639,6 +4643,9 @@ static void ice_deinit_features(struct ice_pf *pf)ice_gnss_exit (pf);if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags))ice_ptp_release (pf); +if (ice_is_feature_supported (pf,ICE_F_PHY_RCLK ) || +ice_is_feature_supported (pf,ICE_F_CGU )) +ice_dpll_deinit (pf); }static void ice_init_wakeup (struct ice_pf *pf)
Signature · 1 line
2.27.0
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +12
-0+/** +* ice_dpll_pin_enable - enable a pin on dplls +* @hw: board private hw structure +* @pin: pointer to a pin +* @pin_type: type of pin being enabled +* @extack: error reporting +* +* Enable a pin on both dplls. Store current state in pin->flags. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK
drivers/net/ethernet/intel/ice/ice_dpll.c line 325
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+* * negative - error +*/ +static int +ice_dpll_pin_enable (struct ice_hw *hw,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{ +u8 flags =0 ; +int ret; +
I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)
You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clock
For mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
-> pin_id: 10
SenceE daemon will use PIN_GET with pin_id 10 to get DPLL device id
-> device_id: 2 SynceE daemon does PIN_SET cmd on pin_id 10, device_id 2 -> state = CONNECTED
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
-> pin_id: 11
SenceE daemon will use PIN_GET with pin_id 11 to get DPLL device id
-> device_id: 2 SynceE daemon does PIN_SET cmd on pin_id 10, device_id 2 -> state = CONNECTED (that will in HW disconnect previously connected pin 10, there will be
notification of pin_id 10, device_id -> state DISCONNECT)
Thanks!
[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 28 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +19
-0+/** +* ice_dpll_pin_enable - enable a pin on dplls +* @hw: board private hw structure +* @pin: pointer to a pin +* @pin_type: type of pin being enabled +* @extack: error reporting +* +* Enable a pin on both dplls. Store current state in pin->flags. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK +* * negative - error +*/ +static int +ice_dpll_pin_enable (struct ice_hw *hw,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 325
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+u8 flags =0 ; +int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered. If the dpll is in mode FREERUN, it shall not try to synchronize or monitor any of the pins.
Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?
The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 seconds
Case II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 seconds
Basically in AUTOMATIC mode the sources are still monitored even when they are not in SELECTABLE state, while in FREERUN there is no such monitoring, so in the end process of synchronizing with the source takes much longer as dpll need to start the process from scratch.
Quoted 4 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
Quoted 16 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clock
Quoted 8 lines
For mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Quoted 13 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)
This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through the MUX pin).
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 -> pin_id: 13
b) SyncE daemon uses PIN_GET to find a parent MUX type pin -> pin_id: 2 (in case of dpll_id is needed, would be find in this response also)
c) SyncE daemon uses PIN_SET to set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while all the other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon uses PIN_SET to set state of pin_id:13 to CONNECTED with parent pin (pin-id:2)
2) (basically the same, only eth1 would get different pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 -> pin_id: 14
b) SyncE daemon uses PIN_GET to find parent MUX type pin -> pin_id: 2
c) SyncE daemon uses PIN_SET to set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while all the other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon uses PIN_SET to set state of pin_id:14 to CONNECTED with parent pin (pin-id:2)
Where step c) is required due to AUTOMATIC mode, and step d) required due to phy recovery clock pin being connected through the MUX type pin.
Thank you!
Arkadiusz
Quoted 5 lines
Thanks!
[...]
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 62 lines · Thu, Jul 20, 2023 at 07:31:14PM CEST, [email protected] wrote:
Quoted 28 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +19
-0+/** +* ice_dpll_pin_enable - enable a pin on dplls +* @hw: board private hw structure +* @pin: pointer to a pin +* @pin_type: type of pin being enabled +* @extack: error reporting +* +* Enable a pin on both dplls. Store current state in pin->flags. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK +* * negative - error +*/ +static int +ice_dpll_pin_enable (struct ice_hw *hw,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 325
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+u8 flags =0 ; +int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered. If the dpll is in mode FREERUN, it shall not try to synchronize or monitor any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 seconds
Quoted 4 lines
Basically in AUTOMATIC mode the sources are still monitored even when they are not in SELECTABLE state, while in FREERUN there is no such monitoring, so in the end process of synchronizing with the source takes much longer as dpll need to start the process from scratch.
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
Quoted 7 lines
Quoted 5 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
Quoted 26 lines
Quoted 17 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockQuoted 8 lines
For mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2
Quoted 2 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Sure it has to. The PIN_SET accepts pin_id and device_id attrs as input. You need to set the state on a pin on a certain DPLL device.
Quoted 20 lines
Quoted 4 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 10 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through the MUX pin).
Quoted 7 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while all the other pins shall be lower prio i.e. pin-prio:1)
Yeah, for this you need pin_id 2 and device_id. Because you are setting state on DPLL device.
Quoted 2 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with parent pin (pin-id:2)
For this you need pin_id and pin_parent_id because you set the state on a parent pin.
Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just need a simple thing: "select this pin as a source" :/
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 21 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while all the other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to phy recovery clock pin being connected through the MUX type pin.
Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 71 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMQuoted 62 lines · Thu, Jul 20, 2023 at 07:31:14PM CEST, [email protected] wrote:
Quoted 28 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +19
-0+/** +* ice_dpll_pin_enable - enable a pin on dplls +* @hw: board private hw structure +* @pin: pointer to a pin +* @pin_type: type of pin being enabled +* @extack: error reporting +* +* Enable a pin on both dplls. Store current state in pin->flags. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK +* * negative - error +*/ +static int +ice_dpll_pin_enable (struct ice_hw *hw,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 325
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+u8 flags =0 ; +int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered. If the dpll is in mode FREERUN, it shall not try to synchronize or monitor any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 4 lines
Basically in AUTOMATIC mode the sources are still monitored even when they are not in SELECTABLE state, while in FREERUN there is no such monitoring, so in the end process of synchronizing with the source takes much longer as dpll need to start the process from scratch.
Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
And we will have the same discussion later.. But implementation is already there.
As said in our previous discussion, without mode_set there is no point to have command DEVICE_SET at all, and there you said that you are ok with having the command as a placeholder, which doesn't make sense, since it is not used.
Also this is not HW implementation detail but a synchronizer chip feature, once dpll is in FREERUN mode, the measurements like phase offset between the input and dpll's output won't be available.
For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine, where disconnecting sources is not, as they are still used, monitored and measured.
So probably most important fact that you are missing here: assuming the user disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED state but into HOLDOVER.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
mode_set was there from the very beginning.. now implemented in ice driver as it should.
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2
Quoted 6 lines
Quoted 2 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input. You need to set the state on a pin on a certain DPLL device.
The thing is pin can be connected to multiple dplls and SyncE daemon shall know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE daemon learns it.
But let's park it, as this is not really relevant.
Quoted 48 lines
Quoted 21 lines
Quoted 5 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 10 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through the MUX pin).
Quoted 8 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while all the other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting state on DPLL device.Quoted 2 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just need a simple thing: "select this pin as a source" :/
Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Multiple level of muxes possibly could be hidden in the driver, but the fact they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type pin.
Thank you!
Arkadiusz
Quoted 24 lines
Quoted 24 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while all the other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to phy recovery clock pin being connected through the MUX type pin.
Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 78 lines · Fri, Jul 21, 2023 at 01:17:59PM CEST, [email protected] wrote:
Quoted 71 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMQuoted 62 lines · Thu, Jul 20, 2023 at 07:31:14PM CEST, [email protected] wrote:
Quoted 28 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +19
-0+/** +* ice_dpll_pin_enable - enable a pin on dplls +* @hw: board private hw structure +* @pin: pointer to a pin +* @pin_type: type of pin being enabled +* @extack: error reporting +* +* Enable a pin on both dplls. Store current state in pin->flags. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK +* * negative - error +*/ +static int +ice_dpll_pin_enable (struct ice_hw *hw,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 325
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+u8 flags =0 ; +int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered. If the dpll is in mode FREERUN, it shall not try to synchronize or monitor any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 4 lines
Basically in AUTOMATIC mode the sources are still monitored even when they are not in SELECTABLE state, while in FREERUN there is no such monitoring, so in the end process of synchronizing with the source takes much longer as dpll need to start the process from scratch.
Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
Quoted 2 lines
And we will have the same discussion later.. But implementation is already there.
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
Quoted 3 lines
As said in our previous discussion, without
mode_setthere is no point to have commandDEVICE_SETat all, and there you said that you are ok with having the command as a placeholder, which doesn't make sense, since it is not used.
I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
Quoted 9 lines
Also this is not HW implementation detail but a synchronizer chip feature, once dpll is in FREERUN mode, the measurements like phase offset between the input and dpll's output won't be available.
For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine, where disconnecting sources is not, as they are still used, monitored and measured.
So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Please don't mix config and state. I think we untangled this in the past :/
Perhaps you just need an extra cmd like DPLL_CMD_DEVICE_STATE_RESET cmd to hit this button.
Quoted 12 lines
So probably most important fact that you are missing here: assuming the user disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED state but into HOLDOVER.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
mode_setwas there from the very beginning.. now implemented in ice driver as it should.
I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 19 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockQuoted 8 lines
For mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Quoted 8 lines
Quoted 3 lines
Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input. You need to set the state on a pin on a certain DPLL device.The thing is pin can be connected to multiple dplls and SyncE daemon shall know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE daemon learns it.
Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 53 lines
Quoted 49 lines
Quoted 22 lines
Quoted 6 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 10 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through the MUX pin).
Quoted 8 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while all the other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting state on DPLL device.Quoted 2 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just need a simple thing: "select this pin as a source" :/
Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 6 lines
Multiple level of muxes possibly could be hidden in the driver, but the fact they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type pin.
Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
Do we need a dpll library to do this magic?
Quoted 29 lines
Thank you!
ArkadiuszQuoted 24 lines
Quoted 24 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while all the other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to phy recovery clock pin being connected through the MUX type pin.
Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 82 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 2:02 PMQuoted 78 lines · Fri, Jul 21, 2023 at 01:17:59PM CEST, [email protected] wrote:
Quoted 77 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMQuoted 62 lines · Thu, Jul 20, 2023 at 07:31:14PM CEST, [email protected] wrote:
Quoted 28 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +19
-0+/** +* ice_dpll_pin_enable - enable a pin on dplls +* @hw: board private hw structure +* @pin: pointer to a pin +* @pin_type: type of pin being enabled +* @extack: error reporting +* +* Enable a pin on both dplls. Store current state in pin->flags. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK +* * negative - error +*/ +static int +ice_dpll_pin_enable (struct ice_hw *hw,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 325
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+u8 flags =0 ; +int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered. If the dpll is in mode FREERUN, it shall not try to synchronize or monitor any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 4 lines
Basically in AUTOMATIC mode the sources are still monitored even when they are not in SELECTABLE state, while in FREERUN there is no such monitoring, so in the end process of synchronizing with the source takes much longer as dpll need to start the process from scratch.
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
Quoted 7 lines
Quoted 2 lines
And we will have the same discussion later.. But implementation is already there.
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
It is not blocking anything. Most of it was defined and available for long time already. Only ice implementing set_mode is a new part. No clue what is the problem you are implying here.
Quoted 11 lines
Quoted 6 lines
As said in our previous discussion, without
mode_setthere is no point to have
commandDEVICE_SETat all, and there you said that you are ok with having the
command as a placeholder, which doesn't make sense, since it is not used.I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
The argument is that I already implemented and tested, and have the need for the existence to set_mode to configure DPLL, which is there to switch the mode between AUTOMATIC and FREERUN.
Quoted 12 lines
Quoted 11 lines
Also this is not HW implementation detail but a synchronizer chip feature, once dpll is in FREERUN mode, the measurements like phase offset between the
input and dpll's output won't be available.For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine, where disconnecting sources is not, as they are still used, monitored and measured.
Quoted 7 lines
So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Please don't mix config and state. I think we untangled this in the past :/
I don't mix anything, this is the way dpll works, which means mode of dpll.
Quoted 4 lines
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.
As already said there are measurement in place in AUTOMATIC, there are no such thing in FREERUN. Going into FREERUN resets the state machine of dpll which is a side effect of going to FREERUN.
Quoted 21 lines
Quoted 21 lines
So probably most important fact that you are missing here: assuming the user disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED
state but into HOLDOVER.Quoted 13 lines
Quoted 9 lines
Quoted 7 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
Quoted 6 lines
Quoted 2 lines
mode_setwas there from the very beginning.. now implemented in ice driver as it should.I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Well, I don't understand the fixation about removing it. set_mode was there for a long time, now the callback is properly implemented and you are trying to imply that this is not needed.
We require it, as there is no other other way to stop AUTOMATIC mode dpll to do its work.
Quoted 111 lines
Quoted 36 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Quoted 6 lines
Quoted 2 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input. You need to set the state on a pin on a certain DPLL device.Quoted 5 lines
The thing is pin can be connected to multiple dplls and SyncE daemon shall know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE daemon
learns it.Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 54 lines
Quoted 50 lines
Quoted 22 lines
Quoted 6 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 10 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through the MUX pin).
Quoted 9 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting state on DPLL device.Quoted 2 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just need a simple thing: "select this pin as a source" :/
Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 6 lines
Multiple level of muxes possibly could be hidden in the driver, but the fact they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type pin.
Quoted 6 lines
Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
This is dpll subsystem not SyncE one.
Quoted 2 lines
Do we need a dpll library to do this magic?
IMHO rather SyncE library :)
Thank you!
Arkadiusz
Quoted 32 lines
Quoted 32 lines
Thank you!
ArkadiuszQuoted 26 lines
Quoted 26 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to
phy recovery clock pin being connected through the MUX type pin.Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 85 lines · Fri, Jul 21, 2023 at 03:36:17PM CEST, [email protected] wrote:
Quoted 85 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 2:02 PMQuoted 80 lines · Fri, Jul 21, 2023 at 01:17:59PM CEST, [email protected] wrote:
Quoted 71 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMQuoted 62 lines · Thu, Jul 20, 2023 at 07:31:14PM CEST, [email protected] wrote:
Quoted 28 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
(quoted diff) +19
-0+/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ u8 flags = 0; + int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered. If the dpll is in mode FREERUN, it shall not try to synchronize or monitor any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 4 lines
Basically in AUTOMATIC mode the sources are still monitored even when they are not in SELECTABLE state, while in FREERUN there is no such monitoring, so in the end process of synchronizing with the source takes much longer as dpll need to start the process from scratch.
Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
And we will have the same discussion later.. But implementation is already there.
Quoted 8 lines
Quoted 4 lines
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
It is not blocking anything. Most of it was defined and available for long time already. Only ice implementing
set_modeis a new part. No clue what is the problem you are implying here.
Problem is that I believe you freerun mode should not exist. I believe it is wrong.
Quoted 34 lines
Quoted 8 lines
Quoted 7 lines
As said in our previous discussion, without
mode_setthere is no point to have
commandDEVICE_SETat all, and there you said that you are ok with having the
command as a placeholder, which doesn't make sense, since it is not used.Quoted 4 lines
I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
The argument is that I already implemented and tested, and have the need for the existence to
set_modeto configure DPLL, which is there to switch the mode between AUTOMATIC and FREERUN.Quoted 17 lines
Quoted 11 lines
Also this is not HW implementation detail but a synchronizer chip feature, once dpll is in FREERUN mode, the measurements like phase offset between the
input and dpll's output won't be available.For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine, where disconnecting sources is not, as they are still used, monitored and measured.So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Quoted 4 lines
Quoted 2 lines
Please don't mix config and state. I think we untangled this in the past :/
I don't mix anything, this is the way dpll works, which means mode of dpll.
You do. You want to force-change the state yet you mangle the mode in. The fact that some specific dpll implemented it as mode does not mean it has to be exposed like that to user. We have to find the right abstraction.
Quoted 31 lines
Quoted 5 lines
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.As already said there are measurement in place in AUTOMATIC, there are no such thing in FREERUN. Going into FREERUN resets the state machine of dpll which is a side effect of going to FREERUN.
Quoted 21 lines
Quoted 21 lines
So probably most important fact that you are missing here: assuming the user disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED
state but into HOLDOVER.Quoted 13 lines
Quoted 9 lines
Quoted 7 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
mode_setwas there from the very beginning.. now implemented in ice driver as it should.I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Well, I don't understand the fixation about removing it.
It is needed only for your freerun mode, which is questionable. This discussion it not about mode_set. I don't care about it, if it is needed, should be there, if not, so be it.
As you say, you need existance of your freerun mode to justify existence of mode_set(). Could you please, please drop both for now so we can move on? I'm tired of this. Thanks!
Quoted 116 lines
set_modewas there for a long time, now the callback is properly implemented and you are trying to imply that this is not needed.
We require it, as there is no other other way to stop AUTOMATIC mode dpll to do its work.Quoted 111 lines
Quoted 36 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Quoted 6 lines
Quoted 2 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input. You need to set the state on a pin on a certain DPLL device.Quoted 5 lines
The thing is pin can be connected to multiple dplls and SyncE daemon shall know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE daemon
learns it.Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 60 lines
Quoted 50 lines
Quoted 22 lines
Quoted 6 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 10 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through the MUX pin).
Quoted 9 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting state on DPLL device.Quoted 2 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just need a simple thing: "select this pin as a source" :/
Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Multiple level of muxes possibly could be hidden in the driver, but the fact they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type pin.
Quoted 8 lines
Quoted 6 lines
Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
This is dpll subsystem not SyncE one.
SyncE is very legit use case of the UAPI. I would say perhaps the most important.
Quoted 41 lines
Quoted 3 lines
Do we need a dpll library to do this magic?
IMHO rather SyncE library :)
Thank you!
ArkadiuszQuoted 32 lines
Quoted 32 lines
Thank you!
ArkadiuszQuoted 26 lines
Quoted 26 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to
phy recovery clock pin being connected through the MUX type pin.Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 147 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 5:46 PMQuoted 92 lines · Fri, Jul 21, 2023 at 03:36:17PM CEST, [email protected] wrote:
Quoted 92 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 2:02 PMFri, Jul 21, 2023 at 01:17:59PM CEST, [email protected]
Quoted 86 lines · wrote:
Quoted 77 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMThu, Jul 20, 2023 at 07:31:14PM CEST, [email protected]
Quoted 64 lines · wrote:
Quoted 29 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMThu, Jul 20, 2023 at 11:19:01AM CEST, [email protected]
Quoted 1 line · wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
(quoted diff) +19
-0+/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ u8 flags = 0; + int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered. If the dpll is in mode FREERUN, it shall not try to synchronize or monitor
any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 7 lines
Basically in AUTOMATIC mode the sources are still monitored even when they
are not in SELECTABLE state, while in FREERUN there is no such monitoring,
so in the end process of synchronizing with the source takes much longer as
dpll need to start the process from scratch.Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
And we will have the same discussion later.. But implementation is already there.
Quoted 8 lines
Quoted 4 lines
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
It is not blocking anything. Most of it was defined and available for long time already. Only ice implementing
set_modeis a new part. No clue what is the problem you are implying here.Problem is that I believe you freerun mode should not exist. I believe it is wrong.
Quoted 38 lines
Quoted 8 lines
Quoted 7 lines
As said in our previous discussion, without
mode_setthere is no point to have
commandDEVICE_SETat all, and there you said that you are ok with having the
command as a placeholder, which doesn't make sense, since it is not used.Quoted 4 lines
I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
The argument is that I already implemented and tested, and have the need for the
existence toset_modeto configure DPLL, which is there to switch the mode between AUTOMATIC and FREERUN.Quoted 19 lines
Quoted 11 lines
Also this is not HW implementation detail but a synchronizer chip feature, once dpll is in FREERUN mode, the measurements like phase offset between the
input and dpll's output won't be available.For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine, where disconnecting sources is not, as they are still used, monitored and measured.So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Please don't mix config and state. I think we untangled this in the past :/
Quoted 7 lines
Quoted 1 line
I don't mix anything, this is the way dpll works, which means mode of dpll.
You do. You want to force-change the state yet you mangle the mode in. The fact that some specific dpll implemented it as mode does not mean it has to be exposed like that to user. We have to find the right abstraction.
Just to make it clear:
AUTOMATIC:
- inputs monitored, validated, phase measurements available
- possible states: unlocked, locked, locked-ho-acq, holdover
FREERUN:
- inputs not monitored, not validated, no phase measurements available
- possible states: unlocked
Quoted 45 lines
Quoted 39 lines
Quoted 6 lines
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.As already said there are measurement in place in AUTOMATIC, there are no such
thing in FREERUN. Going into FREERUN resets the state machine of dpll which
is a side effect of going to FREERUN.Quoted 26 lines
Quoted 25 lines
So probably most important fact that you are missing here: assuming the user
disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED
state but into HOLDOVER.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
mode_setwas there from the very beginning.. now implemented in ice driver
as it should.Quoted 5 lines
Quoted 3 lines
I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Well, I don't understand the fixation about removing it.
Quoted 8 lines
It is needed only for your freerun mode, which is questionable. This discussion it not about
mode_set. I don't care about it, if it is needed, should be there, if not, so be it.As you say, you need existance of your freerun mode to justify existence of
mode_set(). Could you please, please drop both for now so we can move on? I'm tired of this. Thanks!
Reason for dpll subsystem is to control the dpll. So the mode_set and different modes are there for the same reason.
Explained this multiple times already, we need a way to let the user switch to FREERUN, so all the activities on dpll are stopped.
Quoted 128 lines
Quoted 128 lines
set_modewas there for a long time, now the callback is properly implemented and you are trying to imply that this is not needed.
We require it, as there is no other other way to stop AUTOMATIC mode dpll to do its work.Quoted 121 lines
Quoted 36 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Quoted 6 lines
Quoted 2 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input. You need to set the state on a pin on a certain DPLL device.Quoted 5 lines
The thing is pin can be connected to multiple dplls and SyncE daemon shall know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE daemon
learns it.Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 56 lines
Quoted 52 lines
Quoted 22 lines
Quoted 6 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 10 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through the MUX pin).
Quoted 9 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting state on DPLL device.Quoted 3 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with
parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just
need a simple thing: "select this pin as a source" :/Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 8 lines
Multiple level of muxes possibly could be hidden in the driver, but the fact
they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type
pin.Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
Quoted 5 lines
Quoted 1 line
This is dpll subsystem not SyncE one.
SyncE is very legit use case of the UAPI. I would say perhaps the most important.
But it is still a dpll subsystem.
Thank you!
Arkadiusz
Quoted 43 lines
Quoted 43 lines
Quoted 4 lines
Do we need a dpll library to do this magic?
IMHO rather SyncE library :)
Thank you!
ArkadiuszQuoted 33 lines
Quoted 33 lines
Thank you!
ArkadiuszQuoted 27 lines
Quoted 27 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with
parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to
phy recovery clock pin being connected through the MUX type pin.Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 157 lines · Fri, Jul 21, 2023 at 09:48:18PM CEST, [email protected] wrote:
Quoted 147 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 5:46 PMQuoted 92 lines · Fri, Jul 21, 2023 at 03:36:17PM CEST, [email protected] wrote:
Quoted 92 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 2:02 PMFri, Jul 21, 2023 at 01:17:59PM CEST, [email protected]
Quoted 86 lines · wrote:
Quoted 77 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMThu, Jul 20, 2023 at 07:31:14PM CEST, [email protected]
Quoted 64 lines · wrote:
Quoted 29 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMThu, Jul 20, 2023 at 11:19:01AM CEST, [email protected]
Quoted 1 line · wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
(quoted diff) +19
-0+/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ u8 flags = 0; + int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered. If the dpll is in mode FREERUN, it shall not try to synchronize or monitor
any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 7 lines
Basically in AUTOMATIC mode the sources are still monitored even when they
are not in SELECTABLE state, while in FREERUN there is no such monitoring,
so in the end process of synchronizing with the source takes much longer as
dpll need to start the process from scratch.Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
And we will have the same discussion later.. But implementation is already there.
Quoted 8 lines
Quoted 4 lines
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
It is not blocking anything. Most of it was defined and available for long time already. Only ice implementing
set_modeis a new part. No clue what is the problem you are implying here.Problem is that I believe you freerun mode should not exist. I believe it is wrong.
Quoted 38 lines
Quoted 8 lines
Quoted 7 lines
As said in our previous discussion, without
mode_setthere is no point to have
commandDEVICE_SETat all, and there you said that you are ok with having the
command as a placeholder, which doesn't make sense, since it is not used.Quoted 4 lines
I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
The argument is that I already implemented and tested, and have the need for the
existence toset_modeto configure DPLL, which is there to switch the mode between AUTOMATIC and FREERUN.Quoted 19 lines
Quoted 11 lines
Also this is not HW implementation detail but a synchronizer chip feature, once dpll is in FREERUN mode, the measurements like phase offset between the
input and dpll's output won't be available.For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine, where disconnecting sources is not, as they are still used, monitored and measured.So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Please don't mix config and state. I think we untangled this in the past :/
Quoted 7 lines
Quoted 1 line
I don't mix anything, this is the way dpll works, which means mode of dpll.
You do. You want to force-change the state yet you mangle the mode in. The fact that some specific dpll implemented it as mode does not mean it has to be exposed like that to user. We have to find the right abstraction.
Just to make it clear:
Quoted 7 lines
AUTOMATIC:
- inputs monitored, validated, phase measurements available
- possible states: unlocked, locked, locked-ho-acq, holdoverFREERUN:
- inputs not monitored, not validated, no phase measurements available
- possible states: unlocked
This is your implementation of DPLL. Others may have it done differently. But the fact the input is monitored or not, does not make any difference from user perspective.
When he has automatic mode and does:
1) disconnect all pins
2) reset state (however you implement it in the driver is totaly up
to the device, you may go to your freerun dpll mode internally and to automatic back, up to you)
-> state will go to unlocked
The behaviour is exactly the same, without any special mode.
We are talking about UAPI here. It should provide the abstraction, leaving the internal implementation behind the curtain. What is important is:
1) clear configuration knobs
2) the outcome (hw behaviour)
Quoted 242 lines
Quoted 46 lines
Quoted 40 lines
Quoted 7 lines
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.As already said there are measurement in place in AUTOMATIC, there are no such
thing in FREERUN. Going into FREERUN resets the state machine of dpll which
is a side effect of going to FREERUN.Quoted 26 lines
Quoted 25 lines
So probably most important fact that you are missing here: assuming the user
disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED
state but into HOLDOVER.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
mode_setwas there from the very beginning.. now implemented in ice driver
as it should.Quoted 5 lines
Quoted 3 lines
I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Well, I don't understand the fixation about removing it.
Quoted 8 lines
It is needed only for your freerun mode, which is questionable. This discussion it not about
mode_set. I don't care about it, if it is needed, should be there, if not, so be it.As you say, you need existance of your freerun mode to justify existence of
mode_set(). Could you please, please drop both for now so we can move on? I'm tired of this. Thanks!Reason for dpll subsystem is to control the dpll. So the
mode_setand different modes are there for the same reason.
Explained this multiple times already, we need a way to let the user switch to FREERUN, so all the activities on dpll are stopped.Quoted 128 lines
Quoted 128 lines
set_modewas there for a long time, now the callback is properly implemented and you are trying to imply that this is not needed.
We require it, as there is no other other way to stop AUTOMATIC mode dpll to do its work.Quoted 121 lines
Quoted 36 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Quoted 6 lines
Quoted 2 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input. You need to set the state on a pin on a certain DPLL device.Quoted 5 lines
The thing is pin can be connected to multiple dplls and SyncE daemon shall know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE daemon
learns it.Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 56 lines
Quoted 52 lines
Quoted 22 lines
Quoted 6 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 10 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through the MUX pin).
Quoted 9 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting state on DPLL device.Quoted 3 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with
parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just
need a simple thing: "select this pin as a source" :/Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 8 lines
Multiple level of muxes possibly could be hidden in the driver, but the fact
they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type
pin.Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
Quoted 5 lines
Quoted 1 line
This is dpll subsystem not SyncE one.
SyncE is very legit use case of the UAPI. I would say perhaps the most important.
But it is still a dpll subsystem.
Thank you!
ArkadiuszQuoted 43 lines
Quoted 43 lines
Quoted 4 lines
Do we need a dpll library to do this magic?
IMHO rather SyncE library :)
Thank you!
ArkadiuszQuoted 33 lines
Quoted 33 lines
Thank you!
ArkadiuszQuoted 27 lines
Quoted 27 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with
parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to
phy recovery clock pin being connected through the MUX type pin.Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 176 lines
From: Jiri Pirko <[email protected]>
Sent: Saturday, July 22, 2023 8:37 AMQuoted 160 lines · Fri, Jul 21, 2023 at 09:48:18PM CEST, [email protected] wrote:
Quoted 150 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 5:46 PMQuoted 94 lines · Fri, Jul 21, 2023 at 03:36:17PM CEST, [email protected] wrote:
Quoted 94 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 2:02 PMFri, Jul 21, 2023 at 01:17:59PM CEST, [email protected]
Quoted 88 lines · wrote:
Quoted 78 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMThu, Jul 20, 2023 at 07:31:14PM CEST, [email protected]
Quoted 65 lines · wrote:
Quoted 29 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMThu, Jul 20, 2023 at 11:19:01AM CEST, [email protected]
Quoted 1 line · wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
(quoted diff) +19
-0+/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ u8 flags = 0; + int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered.
If the dpll is in mode FREERUN, it shall not try to synchronize or monitor
any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 7 lines
Basically in AUTOMATIC mode the sources are still monitored even when they
are not in SELECTABLE state, while in FREERUN there is no such monitoring,
so in the end process of synchronizing with the source takes much longer as
dpll need to start the process from scratch.Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
And we will have the same discussion later.. But implementation is already
there.Quoted 8 lines
Quoted 4 lines
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
It is not blocking anything. Most of it was defined and available for long time already. Only ice implementing
set_modeis a new part. No clue what is the problem you are implying here.Problem is that I believe you freerun mode should not exist. I believe it is wrong.
Quoted 39 lines
Quoted 8 lines
Quoted 7 lines
As said in our previous discussion, without
mode_setthere is no point to have
commandDEVICE_SETat all, and there you said that you are ok with having the
command as a placeholder, which doesn't make sense, since it is not used.Quoted 4 lines
I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
The argument is that I already implemented and tested, and have the need for the
existence toset_modeto configure DPLL, which is there to switch the mode between AUTOMATIC and FREERUN.Quoted 20 lines
Quoted 8 lines
Also this is not HW implementation detail but a synchronizer chip feature,
once dpll is in FREERUN mode, the measurements like phase offset between the
input and dpll's output won't be available.Quoted 4 lines
For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine, where disconnecting sources is not, as they are still used, monitored and measured.So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Please don't mix config and state. I think we untangled this in the past :/
Quoted 7 lines
Quoted 1 line
I don't mix anything, this is the way dpll works, which means mode of dpll.
You do. You want to force-change the state yet you mangle the mode in. The fact that some specific dpll implemented it as mode does not mean it has to be exposed like that to user. We have to find the right abstraction.
Just to make it clear:
Quoted 7 lines
AUTOMATIC:
- inputs monitored, validated, phase measurements available
- possible states: unlocked, locked, locked-ho-acq, holdoverFREERUN:
- inputs not monitored, not validated, no phase measurements available
- possible states: unlockedThis is your implementation of DPLL. Others may have it done differently. But the fact the input is monitored or not, does not make any difference from user perspective.
Quoted 8 lines
When he has automatic mode and does:
1) disconnect all pins
2) reset state (however you implement it in the driver is totaly up
to the device, you may go to your freerun dpll mode internally and to automatic back, up to you)
-> state will go to unlockedThe behaviour is exactly the same, without any special mode.
In this case there is special reset button, which doesn't exist in reality, actually your suggestion to go into FREERUN and back to AUTOMATIC to pretend the some kind of reset has happened, where in reality dpll went to FREERUN and AUTOMATIC.
For me it seems it seems like unnecessary complication of user's life. The idea of FREERUN mode is to run dpll on its system clock, so all the "external" dpll sources shall be disconnected when dpll is in FREERUN. Let's assume your HW doesn't have a FREERUN, can't you just create it by disconnecting all the sources?
BTW, what chip are you using on mlx5 for this?
I don't understand why the user would have to mangle state of all the pins just to stop dpll's work if he could just go into FREERUN and voila. Also what if user doesn't want change the configuration of the pins at all, and he just want to desynchronize it's dpll for i.e. testing reason.
Quoted 254 lines
We are talking about UAPI here. It should provide the abstraction, leaving the
internal implementation behind the curtain. What is important is:
1) clear configuration knobs
2) the outcome (hw behaviour)Quoted 245 lines
Quoted 46 lines
Quoted 40 lines
Quoted 7 lines
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.As already said there are measurement in place in AUTOMATIC, there are no such
thing in FREERUN. Going into FREERUN resets the state machine of dpll which
is a side effect of going to FREERUN.Quoted 26 lines
Quoted 25 lines
So probably most important fact that you are missing here: assuming the user
disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED
state but into HOLDOVER.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
mode_setwas there from the very beginning.. now implemented in ice driver
as it should.Quoted 5 lines
Quoted 3 lines
I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Well, I don't understand the fixation about removing it.
Quoted 8 lines
It is needed only for your freerun mode, which is questionable. This discussion it not about
mode_set. I don't care about it, if it is needed, should be there, if not, so be it.As you say, you need existance of your freerun mode to justify existence of
mode_set(). Could you please, please drop both for now so we can move on? I'm tired of this. Thanks!Reason for dpll subsystem is to control the dpll. So the
mode_setand different modes are there for the same reason.
Explained this multiple times already, we need a way to let the user switch to FREERUN, so all the activities on dpll are stopped.Quoted 131 lines
Quoted 131 lines
set_modewas there for a long time, now the callback is properly implemented
and you are trying to imply that this is not needed.
We require it, as there is no other other way to stop AUTOMATIC mode dpll to do its work.Quoted 123 lines
Quoted 36 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Quoted 6 lines
Quoted 2 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input. You need to set the state on a pin on a certain DPLL device.Quoted 5 lines
The thing is pin can be connected to multiple dplls and SyncE daemon shall know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE daemon
learns it.Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 58 lines
Quoted 54 lines
Quoted 24 lines
Quoted 6 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 11 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through
the MUX pin).Quoted 9 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting state on DPLL device.Quoted 3 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with
parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just
need a simple thing: "select this pin as a source" :/Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 8 lines
Multiple level of muxes possibly could be hidden in the driver, but the fact
they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type
pin.Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
Quoted 5 lines
Quoted 1 line
This is dpll subsystem not SyncE one.
SyncE is very legit use case of the UAPI. I would say perhaps the most important.
But it is still a dpll subsystem.
Thank you!
ArkadiuszQuoted 43 lines
Quoted 43 lines
Quoted 4 lines
Do we need a dpll library to do this magic?
IMHO rather SyncE library :)
Thank you!
ArkadiuszQuoted 33 lines
Quoted 33 lines
Thank you!
ArkadiuszQuoted 27 lines
Quoted 27 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with
parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to
phy recovery clock pin being connected through the MUX type pin.Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 183 lines · Mon, Jul 24, 2023 at 05:03:55PM CEST, [email protected] wrote:
Quoted 183 lines
From: Jiri Pirko <[email protected]>
Sent: Saturday, July 22, 2023 8:37 AMQuoted 160 lines · Fri, Jul 21, 2023 at 09:48:18PM CEST, [email protected] wrote:
Quoted 150 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 5:46 PMQuoted 94 lines · Fri, Jul 21, 2023 at 03:36:17PM CEST, [email protected] wrote:
Quoted 94 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 2:02 PMFri, Jul 21, 2023 at 01:17:59PM CEST, [email protected]
Quoted 88 lines · wrote:
Quoted 78 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMThu, Jul 20, 2023 at 07:31:14PM CEST, [email protected]
Quoted 65 lines · wrote:
Quoted 29 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMThu, Jul 20, 2023 at 11:19:01AM CEST, [email protected]
Quoted 1 line · wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
(quoted diff) +19
-0+/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ u8 flags = 0; + int ret; +I don't follow. Howcome you don't check if the mode is freerun here or not? Is it valid to enable a pin when freerun mode? What happens?
Because you are probably still thinking the modes are somehow connected to the state of the pin, but it is the other way around.
The dpll device mode is a state of DPLL before pins are even considered.
If the dpll is in mode FREERUN, it shall not try to synchronize or monitor
any of the pins.Quoted 5 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 7 lines
Basically in AUTOMATIC mode the sources are still monitored even when they
are not in SELECTABLE state, while in FREERUN there is no such monitoring,
so in the end process of synchronizing with the source takes much longer as
dpll need to start the process from scratch.Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
And we will have the same discussion later.. But implementation is already
there.Quoted 8 lines
Quoted 4 lines
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
It is not blocking anything. Most of it was defined and available for long time already. Only ice implementing
set_modeis a new part. No clue what is the problem you are implying here.Problem is that I believe you freerun mode should not exist. I believe it is wrong.
Quoted 39 lines
Quoted 8 lines
Quoted 7 lines
As said in our previous discussion, without
mode_setthere is no point to have
commandDEVICE_SETat all, and there you said that you are ok with having the
command as a placeholder, which doesn't make sense, since it is not used.Quoted 4 lines
I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
The argument is that I already implemented and tested, and have the need for the
existence toset_modeto configure DPLL, which is there to switch the mode between AUTOMATIC and FREERUN.Quoted 20 lines
Quoted 8 lines
Also this is not HW implementation detail but a synchronizer chip feature,
once dpll is in FREERUN mode, the measurements like phase offset between the
input and dpll's output won't be available.Quoted 4 lines
For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine, where disconnecting sources is not, as they are still used, monitored and measured.So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Please don't mix config and state. I think we untangled this in the past :/
Quoted 7 lines
Quoted 1 line
I don't mix anything, this is the way dpll works, which means mode of dpll.
You do. You want to force-change the state yet you mangle the mode in. The fact that some specific dpll implemented it as mode does not mean it has to be exposed like that to user. We have to find the right abstraction.
Just to make it clear:
Quoted 7 lines
AUTOMATIC:
- inputs monitored, validated, phase measurements available
- possible states: unlocked, locked, locked-ho-acq, holdoverFREERUN:
- inputs not monitored, not validated, no phase measurements available
- possible states: unlockedThis is your implementation of DPLL. Others may have it done differently. But the fact the input is monitored or not, does not make any difference from user perspective.
When he has automatic mode and does:
1) disconnect all pins
2) reset state (however you implement it in the driver is totaly up
to the device, you may go to your freerun dpll mode internally and to automatic back, up to you)
-> state will go to unlocked
Quoted 6 lines
Quoted 1 line
The behaviour is exactly the same, without any special mode.
In this case there is special reset button, which doesn't exist in reality, actually your suggestion to go into FREERUN and back to AUTOMATIC to pretend the some kind of reset has happened, where in reality dpll went to FREERUN and AUTOMATIC.
There are 3 pin states:
disconnected
connected
selectable
When the last source disconnects, go to your internal freerun. When some source gets selectable or connected, go to your internal automatic mode.
From user perspactive, the mode didn't change.
From user perepective, this is exacly the behaviour he requested.
Quoted 3 lines
For me it seems it seems like unnecessary complication of user's life. The idea of FREERUN mode is to run dpll on its system clock, so all the "external" dpll sources shall be disconnected when dpll is in FREERUN.
Yes, that is when you set all pins to disconnect. no mode change needed.
Quoted 2 lines
Let's assume your HW doesn't have a FREERUN, can't you just create it by disconnecting all the sources?
Yep, that's what we do.
Quoted 5 lines
BTW, what chip are you using on mlx5 for this?
I don't understand why the user would have to mangle state of all the pins just to stop dpll's work if he could just go into FREERUN and voila. Also what if user doesn't want change the configuration of the pins at all, and he just want to desynchronize it's dpll for i.e. testing reason.
I tried to explain multiple times. Let the user have clean an abstracted api, with clear semantics. Simple as that. Your internal freerun mode is just something to abstract out, it is not needed to expose it.
Quoted 255 lines
Quoted 255 lines
We are talking about UAPI here. It should provide the abstraction, leaving the
internal implementation behind the curtain. What is important is:
1) clear configuration knobs
2) the outcome (hw behaviour)Quoted 245 lines
Quoted 46 lines
Quoted 40 lines
Quoted 7 lines
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.As already said there are measurement in place in AUTOMATIC, there are no such
thing in FREERUN. Going into FREERUN resets the state machine of dpll which
is a side effect of going to FREERUN.Quoted 26 lines
Quoted 25 lines
So probably most important fact that you are missing here: assuming the user
disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED
state but into HOLDOVER.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This needs to be documented, please.
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded it in the first place in the last patchset version.
mode_setwas there from the very beginning.. now implemented in ice driver
as it should.Quoted 5 lines
Quoted 3 lines
I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Well, I don't understand the fixation about removing it.
Quoted 8 lines
It is needed only for your freerun mode, which is questionable. This discussion it not about
mode_set. I don't care about it, if it is needed, should be there, if not, so be it.As you say, you need existance of your freerun mode to justify existence of
mode_set(). Could you please, please drop both for now so we can move on? I'm tired of this. Thanks!Reason for dpll subsystem is to control the dpll. So the
mode_setand different modes are there for the same reason.
Explained this multiple times already, we need a way to let the user switch to FREERUN, so all the activities on dpll are stopped.Quoted 131 lines
Quoted 131 lines
set_modewas there for a long time, now the callback is properly implemented
and you are trying to imply that this is not needed.
We require it, as there is no other other way to stop AUTOMATIC mode dpll to do its work.Quoted 123 lines
Quoted 36 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Quoted 6 lines
Quoted 2 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't relate to the dpll interface..
Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input. You need to set the state on a pin on a certain DPLL device.Quoted 5 lines
The thing is pin can be connected to multiple dplls and SyncE daemon shall know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE daemon
learns it.Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 58 lines
Quoted 54 lines
Quoted 24 lines
Quoted 6 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state = CONNECTEDQuoted 11 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state = CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although they come from the fact, the ice is using AUTOMATIC mode and recovered clock pins which are not directly connected to a dpll (connected through
the MUX pin).Quoted 9 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2 (in case ofdpll_idis needed, would be find in this response also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting state on DPLL device.Quoted 3 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with
parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just
need a simple thing: "select this pin as a source" :/Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 8 lines
Multiple level of muxes possibly could be hidden in the driver, but the fact
they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type
pin.Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
Quoted 5 lines
Quoted 1 line
This is dpll subsystem not SyncE one.
SyncE is very legit use case of the UAPI. I would say perhaps the most important.
But it is still a dpll subsystem.
Thank you!
ArkadiuszQuoted 43 lines
Quoted 43 lines
Quoted 4 lines
Do we need a dpll library to do this magic?
IMHO rather SyncE library :)
Thank you!
ArkadiuszQuoted 33 lines
Quoted 33 lines
Thank you!
ArkadiuszQuoted 27 lines
Quoted 27 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id: 2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0, while
all the
other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED with
parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required due to
phy recovery clock pin being connected through the MUX type pin.Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 209 lines
From: Jiri Pirko <[email protected]>
Sent: Tuesday, July 25, 2023 10:04 AMQuoted 197 lines · Mon, Jul 24, 2023 at 05:03:55PM CEST, [email protected] wrote:
Quoted 197 lines
From: Jiri Pirko <[email protected]>
Sent: Saturday, July 22, 2023 8:37 AMQuoted 174 lines · Fri, Jul 21, 2023 at 09:48:18PM CEST, [email protected] wrote:
Quoted 163 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 5:46 PMFri, Jul 21, 2023 at 03:36:17PM CEST, [email protected]
Quoted 97 lines · wrote:
Quoted 97 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 2:02 PMFri, Jul 21, 2023 at 01:17:59PM CEST, [email protected]
Quoted 91 lines · wrote:
Quoted 81 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMThu, Jul 20, 2023 at 07:31:14PM CEST, [email protected]
Quoted 68 lines · wrote:
Quoted 30 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMThu, Jul 20, 2023 at 11:19:01AM CEST, [email protected]
Quoted 1 line · wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 20 lines
(quoted diff) +20
-0+/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin-flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0;Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ int ret; +I don't follow. Howcome you don't check if the mode is freerun here or
not? Is it valid to enable a pin when freerun mode? What happens?Because you are probably still thinking the modes are somehow connected
to the state of the pin, but it is the other way around. The dpll device mode is a state of DPLL before pins are even considered.
If the dpll is in mode FREERUN, it shall not try to synchronize or monitor
any of the pins.Quoted 6 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is
diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 7 lines
Basically in AUTOMATIC mode the sources are still monitored even when they
are not in SELECTABLE state, while in FREERUN there is no such monitoring,
so in the end process of synchronizing with the source takes much longer as
dpll need to start the process from scratch.Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
And we will have the same discussion later.. But implementation is already
there.Quoted 8 lines
Quoted 4 lines
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
It is not blocking anything. Most of it was defined and available for long time already. Only ice implementing
set_modeis a new part. No clue what is the problem you are implying here.Problem is that I believe you freerun mode should not exist. I believe it is wrong.
Quoted 48 lines
Quoted 11 lines
Quoted 10 lines
As said in our previous discussion, without
mode_setthere is no point to
have
commandDEVICE_SETat all, and there you said that you are ok with having
the
command as a placeholder, which doesn't make sense, since it is not used.Quoted 4 lines
I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
The argument is that I already implemented and tested, and have the need for the
existence toset_modeto configure DPLL, which is there to switch the mode
between AUTOMATIC and FREERUN.Quoted 25 lines
Quoted 9 lines
Also this is not HW implementation detail but a synchronizer chip feature,
once dpll is in FREERUN mode, the measurements like phase offset between
the
input and dpll's output won't be available.Quoted 6 lines
For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine,
where disconnecting sources is not, as they are still used, monitored and
measured.So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked,
holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.Please don't mix config and state. I think we untangled this in the past
:/Quoted 8 lines
Quoted 2 lines
I don't mix anything, this is the way dpll works, which means mode of dpll.
You do. You want to force-change the state yet you mangle the mode in. The fact that some specific dpll implemented it as mode does not mean it has to be exposed like that to user. We have to find the right abstraction.
Just to make it clear:
Quoted 7 lines
AUTOMATIC:
- inputs monitored, validated, phase measurements available
- possible states: unlocked, locked, locked-ho-acq, holdoverFREERUN:
- inputs not monitored, not validated, no phase measurements available
- possible states: unlockedThis is your implementation of DPLL. Others may have it done differently. But the fact the input is monitored or not, does not make any difference from user perspective.
When he has automatic mode and does:
1) disconnect all pins
2) reset state (however you implement it in the driver is totaly up
to the device, you may go to your freerun dpll mode internally and to automatic back, up to you)
-> state will go to unlockedQuoted 7 lines
Quoted 1 line
The behaviour is exactly the same, without any special mode.
In this case there is special reset button, which doesn't exist in reality, actually your suggestion to go into FREERUN and back to AUTOMATIC to pretend the some kind of reset has happened, where in reality dpll went to
FREERUN and AUTOMATIC.
Quoted 9 lines
There are 3 pin states:
disconnected
connected
selectableWhen the last source disconnects, go to your internal freerun. When some source gets selectable or connected, go to your internal automatic mode.
This would make the driver to check if all the sources are disconnected each time someone disconnects a source. Which in first place is not efficient, but also dpll design already allows different driver instances to control separated sources, which in this case would force a driver to implement additional communication between the instances just to allow such hidden FREERUN mode.
Which seems another argument not to do this in the way you are proposing:
inefficient and unnecessarily complicated.
We know that you could also implement FREERUN mode by disconnecting all the sources, even if HW doesn't support it explicitly.
Quoted 2 lines
From user perspactive, the mode didn't change.
The user didn't change the mode, the mode shall not change.
You wrote to do it silently, so user didn't change the mode but it would have changed, and we would have pretended the different working mode of DPLL doesn't exist.
Quoted 2 lines
From user perepective, this is exacly the behaviour he requested.
IMHO this is wrong and comes from the definition of pin state DISCONNECTED, which is not sharp, for our HW means that the input will not be considered as valid input, but is not disconnecting anything, as input is still monitored and measured.
Shall we have additional mode like PIN_STATE_NOT_SELECTABLE? As it is not possible to actually disconnect a pin..
Quoted 7 lines
Quoted 4 lines
For me it seems it seems like unnecessary complication of user's life. The idea of FREERUN mode is to run dpll on its system clock, so all the "external" dpll sources shall be disconnected when dpll is in FREERUN.
Yes, that is when you set all pins to disconnect. no mode change needed.
We don't disconnect anything, we used a pin state DISCONNECTED as this seemed most appropriate.
Quoted 6 lines
Quoted 3 lines
Let's assume your HW doesn't have a FREERUN, can't you just create it by disconnecting all the sources?
Yep, that's what we do.
No, you were saying that the mode doesn't exist and that your hardware doesn't support it. At the same time it can be achieved by manually disconnecting all the sources.
Quoted 9 lines
Quoted 8 lines
BTW, what chip are you using on mlx5 for this?
I don't understand why the user would have to mangle state of all the pins just
to stop dpll's work if he could just go into FREERUN and voila. Also what if user doesn't want change the configuration of the pins at all, and he just want
to desynchronize it's dpll for i.e. testing reason.
Quoted 4 lines
I tried to explain multiple times. Let the user have clean an abstracted api, with clear semantics. Simple as that. Your internal freerun mode is just something to abstract out, it is not needed to expose it.
Our hardware can support in total 4 modes, and 2 are now supported in ice. I don't get the idea for abstraction of hardware switches, modes or capabilities, and having those somehow achievable through different functionalities.
I think we already discussed this long enough to make a decision.. Though I am not convinced by your arguments, and you are not convinced by mine.
Perhaps someone else could step in and cut the rope, so we could go further with this?
Thank you!
Arkadiusz
Quoted 283 lines
Quoted 283 lines
Quoted 283 lines
We are talking about UAPI here. It should provide the abstraction, leaving the
internal implementation behind the curtain. What is important is:
1) clear configuration knobs
2) the outcome (hw behaviour)Quoted 272 lines
Quoted 49 lines
Quoted 43 lines
Quoted 7 lines
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.As already said there are measurement in place in AUTOMATIC, there are no
such
thing in FREERUN. Going into FREERUN resets the state machine of dpll which
is a side effect of going to FREERUN.Quoted 28 lines
Quoted 27 lines
So probably most important fact that you are missing here: assuming the user
disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED
state but into HOLDOVER.Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This
needs to be documented, please.Quoted 6 lines
Quoted 1 line
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded
it in the first place in the last patchset version.
mode_setwas there from the very beginning.. now implemented in ice driver
as it should.Quoted 5 lines
Quoted 3 lines
I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Well, I don't understand the fixation about removing it.
Quoted 8 lines
It is needed only for your freerun mode, which is questionable. This discussion it not about
mode_set. I don't care about it, if it is needed, should be there, if not, so be it.As you say, you need existance of your freerun mode to justify existence of
mode_set(). Could you please, please drop both for now so we can move on? I'm tired of this. Thanks!Reason for dpll subsystem is to control the dpll. So the
mode_setand different modes are there for the same reason.
Explained this multiple times already, we need a way to let the user switch to FREERUN, so all the activities on dpll are stopped.Quoted 150 lines
Quoted 150 lines
set_modewas there for a long time, now the callback is properly implemented
and you are trying to imply that this is not needed.
We require it, as there is no other other way to stop AUTOMATIC mode dpll to do its work.Quoted 142 lines
Quoted 38 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Quoted 8 lines
Quoted 3 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't
relate to the dpll interface..Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input.
You need to set the state on a pin on a certain DPLL device.Quoted 7 lines
The thing is pin can be connected to multiple dplls and SyncE daemon shall
know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE
daemon
learns it.Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 73 lines
Quoted 69 lines
Quoted 29 lines
Quoted 7 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state =
CONNECTEDQuoted 13 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state =
CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although
they come from the fact, the ice is using AUTOMATIC mode and recovered
clock pins which are not directly connected to a dpll (connected through
the MUX pin).Quoted 13 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2
(in case ofdpll_idis needed, would be find in this response
also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id:
2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0,
while
all the
other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting
state on DPLL device.Quoted 4 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED
with
parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on
a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the
muxes and magic around it hidden from the user. Now every userspace app
working with this has to implement a logic of tracking pin and the mux
parents (possibly multiple levels) and configure everything. But it just
need a simple thing: "select this pin as a source" :/Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 8 lines
Multiple level of muxes possibly could be hidden in the driver, but the fact
they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type
pin.Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
Quoted 5 lines
Quoted 1 line
This is dpll subsystem not SyncE one.
SyncE is very legit use case of the UAPI. I would say perhaps the most important.
But it is still a dpll subsystem.
Thank you!
ArkadiuszQuoted 48 lines
Quoted 48 lines
Quoted 4 lines
Do we need a dpll library to do this magic?
IMHO rather SyncE library :)
Thank you!
ArkadiuszQuoted 38 lines
Quoted 38 lines
Thank you!
ArkadiuszQuoted 32 lines
Quoted 32 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id:
2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0,
while
all the
other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED
with
parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required
due to
phy recovery clock pin being connected through the MUX type pin.Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 290 lines · Tue, Jul 25, 2023 at 04:01:33PM CEST, [email protected] wrote:
Quoted 209 lines
From: Jiri Pirko <[email protected]>
Sent: Tuesday, July 25, 2023 10:04 AMQuoted 197 lines · Mon, Jul 24, 2023 at 05:03:55PM CEST, [email protected] wrote:
Quoted 197 lines
From: Jiri Pirko <[email protected]>
Sent: Saturday, July 22, 2023 8:37 AMQuoted 174 lines · Fri, Jul 21, 2023 at 09:48:18PM CEST, [email protected] wrote:
Quoted 163 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 5:46 PMFri, Jul 21, 2023 at 03:36:17PM CEST, [email protected]
Quoted 97 lines · wrote:
Quoted 97 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 2:02 PMFri, Jul 21, 2023 at 01:17:59PM CEST, [email protected]
Quoted 91 lines · wrote:
Quoted 81 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 9:33 AMThu, Jul 20, 2023 at 07:31:14PM CEST, [email protected]
Quoted 68 lines · wrote:
Quoted 30 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, July 20, 2023 4:09 PMThu, Jul 20, 2023 at 11:19:01AM CEST, [email protected]
Quoted 1 line · wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 20 lines
+/**
+ * ice_dpll_pin_enable - enable a pin on dplls
+ * @hw: board private hw structure
+ * @pin: pointer to a pin
+ * @pin_type: type of pin being enabled
+ * @extack: error reporting
+ *
+ * Enable a pin on both dplls. Store current state in pin-flags.
+ *
+ * Context: Called under pf->dplls.lock
+ * Return:
+ * * 0 - OK
+ * * negative - error
+ */
+static int
+ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin,
+ enum ice_dpll_pin_type pin_type,
+ struct netlink_ext_ack *extack)
+{
+ u8 flags = 0;Quoted 9 lines
Quoted 2 lines
+ int ret;
+I don't follow. Howcome you don't check if the mode is freerun here or
not? Is it valid to enable a pin when freerun mode? What happens?Because you are probably still thinking the modes are somehow connected
to the state of the pin, but it is the other way around. The dpll device mode is a state of DPLL before pins are even considered.
If the dpll is in mode FREERUN, it shall not try to synchronize or monitor
any of the pins.Quoted 6 lines
Also, I am probably slow, but I still don't see anywhere in this patchset any description about why we need the freerun mode. What is
diffrerent between:
1) freerun mode
2) automatic mode & all pins disabled?The difference:
Case I:
1. set dpll to FREERUN and configure the source as if it would be in AUTOMATIC
2. switch to AUTOMATIC
3. connecting to the valid source takes ~50 secondsCase II:
1. set dpll to AUTOMATIC, set all the source to disconnected
2. switch one valid source to SELECTABLE
3. connecting to the valid source takes ~10 secondsQuoted 7 lines
Basically in AUTOMATIC mode the sources are still monitored even when they
are not in SELECTABLE state, while in FREERUN there is no such monitoring,
so in the end process of synchronizing with the source takes much longer as
dpll need to start the process from scratch.Quoted 6 lines
I believe this is implementation detail of your HW. How you do it is up to you. User does not have any visibility to this behaviour, therefore makes no sense to expose UAPI that is considering it. Please drop it at least for the initial patchset version. If you really need it later on (which I honestly doubt), you can send it as a follow-up patchset.
And we will have the same discussion later.. But implementation is already
there.Quoted 8 lines
Quoted 4 lines
Yeah, it wouldn't block the initial submission. I would like to see this merged, so anything which is blocking us and is totally optional (as this freerun mode) is better to be dropped.
It is not blocking anything. Most of it was defined and available for long time already. Only ice implementing
set_modeis a new part. No clue what is the problem you are implying here.Problem is that I believe you freerun mode should not exist. I believe it is wrong.
Quoted 48 lines
Quoted 11 lines
Quoted 10 lines
As said in our previous discussion, without
mode_setthere is no point to
have
commandDEVICE_SETat all, and there you said that you are ok with having
the
command as a placeholder, which doesn't make sense, since it is not used.Quoted 4 lines
I don't see any problem in having enum value reserved. But it does not need to be there at all. You can add it to the end of the list when needed. No problem. This is not an argument.
The argument is that I already implemented and tested, and have the need for the
existence toset_modeto configure DPLL, which is there to switch the mode
between AUTOMATIC and FREERUN.Quoted 25 lines
Quoted 9 lines
Also this is not HW implementation detail but a synchronizer chip feature,
once dpll is in FREERUN mode, the measurements like phase offset between
the
input and dpll's output won't be available.Quoted 6 lines
For the user there is a difference..
Enabling the FREERUN mode is a reset button on the dpll's state machine,
where disconnecting sources is not, as they are still used, monitored and
measured.So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked,
holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.Please don't mix config and state. I think we untangled this in the past
:/Quoted 8 lines
Quoted 2 lines
I don't mix anything, this is the way dpll works, which means mode of dpll.
You do. You want to force-change the state yet you mangle the mode in. The fact that some specific dpll implemented it as mode does not mean it has to be exposed like that to user. We have to find the right abstraction.
Just to make it clear:
Quoted 7 lines
AUTOMATIC:
- inputs monitored, validated, phase measurements available
- possible states: unlocked, locked, locked-ho-acq, holdoverFREERUN:
- inputs not monitored, not validated, no phase measurements available
- possible states: unlockedThis is your implementation of DPLL. Others may have it done differently. But the fact the input is monitored or not, does not make any difference from user perspective.
When he has automatic mode and does:
1) disconnect all pins
2) reset state (however you implement it in the driver is totaly up
to the device, you may go to your freerun dpll mode internally and to automatic back, up to you)
-> state will go to unlockedQuoted 7 lines
Quoted 1 line
The behaviour is exactly the same, without any special mode.
In this case there is special reset button, which doesn't exist in reality, actually your suggestion to go into FREERUN and back to AUTOMATIC to pretend the some kind of reset has happened, where in reality dpll went to
FREERUN and AUTOMATIC.Quoted 9 lines
There are 3 pin states:
disconnected
connected
selectableWhen the last source disconnects, go to your internal freerun. When some source gets selectable or connected, go to your internal automatic mode.
This would make the driver to check if all the sources are disconnected each time someone disconnects a source. Which in first place is not efficient, but also dpll design already allows different driver instances to control separated sources, which in this case would force a driver to implement additional communication between the instances just to allow such hidden FREERUN mode.
Which seems another argument not to do this in the way you are proposing:
inefficient and unnecessarily complicated.We know that you could also implement FREERUN mode by disconnecting all the sources, even if HW doesn't support it explicitly.
Quoted 2 lines
From user perspactive, the mode didn't change.
The user didn't change the mode, the mode shall not change.
You wrote to do it silently, so user didn't change the mode but it would have changed, and we would have pretended the different working mode of DPLL doesn't exist.Quoted 2 lines
From user perepective, this is exacly the behaviour he requested.
IMHO this is wrong and comes from the definition of pin state DISCONNECTED, which is not sharp, for our HW means that the input will not be considered as valid input, but is not disconnecting anything, as input is still monitored and measured.
Shall we have additional mode likePIN_STATE_NOT_SELECTABLE? As it is not possible to actually disconnect a pin..Quoted 7 lines
Quoted 4 lines
For me it seems it seems like unnecessary complication of user's life. The idea of FREERUN mode is to run dpll on its system clock, so all the "external" dpll sources shall be disconnected when dpll is in FREERUN.
Yes, that is when you set all pins to disconnect. no mode change needed.
We don't disconnect anything, we used a pin state DISCONNECTED as this seemed most appropriate.
Quoted 6 lines
Quoted 3 lines
Let's assume your HW doesn't have a FREERUN, can't you just create it by disconnecting all the sources?
Yep, that's what we do.
No, you were saying that the mode doesn't exist and that your hardware doesn't support it. At the same time it can be achieved by manually disconnecting all the sources.
Quoted 9 lines
Quoted 8 lines
BTW, what chip are you using on mlx5 for this?
I don't understand why the user would have to mangle state of all the pins just
to stop dpll's work if he could just go into FREERUN and voila. Also what if user doesn't want change the configuration of the pins at all, and he just want
to desynchronize it's dpll for i.e. testing reason.Quoted 4 lines
I tried to explain multiple times. Let the user have clean an abstracted api, with clear semantics. Simple as that. Your internal freerun mode is just something to abstract out, it is not needed to expose it.
Our hardware can support in total 4 modes, and 2 are now supported in ice. I don't get the idea for abstraction of hardware switches, modes or capabilities, and having those somehow achievable through different functionalities.
Quoted 5 lines
I think we already discussed this long enough to make a decision.. Though I am not convinced by your arguments, and you are not convinced by mine.
Perhaps someone else could step in and cut the rope, so we could go further with this?
Or, even better, please drop this for the initial patchset and have this as a follow-up. Thanks!
Quoted 288 lines
Thank you!
ArkadiuszQuoted 283 lines
Quoted 283 lines
Quoted 283 lines
We are talking about UAPI here. It should provide the abstraction, leaving the
internal implementation behind the curtain. What is important is:
1) clear configuration knobs
2) the outcome (hw behaviour)Quoted 272 lines
Quoted 49 lines
Quoted 43 lines
Quoted 7 lines
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.As already said there are measurement in place in AUTOMATIC, there are no
such
thing in FREERUN. Going into FREERUN resets the state machine of dpll which
is a side effect of going to FREERUN.Quoted 28 lines
Quoted 27 lines
So probably most important fact that you are missing here: assuming the user
disconnects the pin that dpll was locked with, our dpll doesn't go into UNLOCKED
state but into HOLDOVER.Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Isn't the behaviour of 1) and 2) exactly the same? If no, why? This
needs to be documented, please.Quoted 6 lines
Quoted 1 line
Sure will add the description of FREERUN to the docs.
No, please drop it from this patchset. I have no clue why you readded
it in the first place in the last patchset version.
mode_setwas there from the very beginning.. now implemented in ice driver
as it should.Quoted 5 lines
Quoted 3 lines
I don't understand the fixation on a callback to be implemented. Just remove it. It can be easily added when needed. No problem.
Well, I don't understand the fixation about removing it.
Quoted 8 lines
It is needed only for your freerun mode, which is questionable. This discussion it not about
mode_set. I don't care about it, if it is needed, should be there, if not, so be it.As you say, you need existance of your freerun mode to justify existence of
mode_set(). Could you please, please drop both for now so we can move on? I'm tired of this. Thanks!Reason for dpll subsystem is to control the dpll. So the
mode_setand different modes are there for the same reason.
Explained this multiple times already, we need a way to let the user switch to FREERUN, so all the activities on dpll are stopped.Quoted 150 lines
Quoted 150 lines
set_modewas there for a long time, now the callback is properly implemented
and you are trying to imply that this is not needed.
We require it, as there is no other other way to stop AUTOMATIC mode dpll to do its work.Quoted 142 lines
Quoted 38 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Another question, I asked the last time as well, but was not heard:
Consider example where you have 2 netdevices, eth0 and eth1, each connected with a single DPLL pin:
eth0 - DPLL pin 10 (DPLL device id 2)
eth1 - DPLL pin 11 (DPLL device id 2)You have a SyncE daemon running on top eth0 and eth1.
Could you please describe following 2 flows?
1) SyncE daemon selects eth0 as a source of clock
2) SyncE daemon selects eth1 as a source of clockFor mlx5 it goes like:
DPLL device mode is MANUAL.
1)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth0
->pin_id: 10
SenceE daemon will usePIN_GETwithpin_id10 to get DPLL device id
->device_id: 2Quoted 8 lines
Quoted 3 lines
Not sure if it needs to obtain the dpll id in this step, but it doesn't
relate to the dpll interface..Sure it has to. The
PIN_SETacceptspin_idanddevice_idattrs as input.
You need to set the state on a pin on a certain DPLL device.Quoted 7 lines
The thing is pin can be connected to multiple dplls and SyncE daemon shall
know already something about the dpll it is managing.
Not saying it is not needed, I am saying this is not a moment the SyncE
daemon
learns it.Moment or not, it is needed for the cmd, that is why I have it there.
Quoted 1 line
But let's park it, as this is not really relevant.
Agreed.
Quoted 73 lines
Quoted 69 lines
Quoted 29 lines
Quoted 7 lines
SynceE daemon does
PIN_SETcmd onpin_id10,device_id2 -> state =
CONNECTEDQuoted 13 lines
2)
SynceE daemon uses RTNetlink to obtain DPLL pin number of eth1
->pin_id: 11
SenceE daemon will usePIN_GETwithpin_id11 to get DPLL device id
->device_id: 2
SynceE daemon doesPIN_SETcmd onpin_id10,device_id2 -> state =
CONNECTED
(that will in HW disconnect previously connected pin 10, there will be
notification ofpin_id10,device_id-> state DISCONNECT)This flow is similar for ice, but there are some differences, although
they come from the fact, the ice is using AUTOMATIC mode and recovered
clock pins which are not directly connected to a dpll (connected through
the MUX pin).Quoted 13 lines
1)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 13
b) SyncE daemon usesPIN_GETto find a parent MUX type pin ->pin_id: 2
(in case ofdpll_idis needed, would be find in this response
also)
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id:
2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0,
while
all the
other pins shall be lower prio i.e. pin-prio:1)Yeah, for this you need
pin_id2 anddevice_id. Because you are setting
state on DPLL device.Quoted 4 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED
with
parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on
a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the
muxes and magic around it hidden from the user. Now every userspace app
working with this has to implement a logic of tracking pin and the mux
parents (possibly multiple levels) and configure everything. But it just
need a simple thing: "select this pin as a source" :/Quoted 3 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
Quoted 8 lines
Multiple level of muxes possibly could be hidden in the driver, but the fact
they exist is not possible to be hidden from the user if the DPLL is in AUTOMATIC mode.
For MANUAL mode dpll the muxes could be also hidden.
Yeah, we have in ice most complicated scenario of AUTOMATIC mode + MUXED type
pin.Sure, but does user care how complicated things are inside? The syncE daemon just cares for: "select netdev x as a source". However it is done internally is irrelevant to him. With the existing UAPI, the syncE daemon needs to learn individual device dpll/pin/mux topology and work with it.
Quoted 5 lines
Quoted 1 line
This is dpll subsystem not SyncE one.
SyncE is very legit use case of the UAPI. I would say perhaps the most important.
But it is still a dpll subsystem.
Thank you!
ArkadiuszQuoted 48 lines
Quoted 48 lines
Quoted 4 lines
Do we need a dpll library to do this magic?
IMHO rather SyncE library :)
Thank you!
ArkadiuszQuoted 38 lines
Quoted 38 lines
Thank you!
ArkadiuszQuoted 32 lines
Quoted 32 lines
2) (basically the same, only eth1 would get different
pin_id.)
a) SyncE daemon uses RTNetlink to obtain DPLL pin number of eth0 ->pin_id: 14
b) SyncE daemon usesPIN_GETto find parent MUX type pin ->pin_id: 2
c) SyncE daemon usesPIN_SETto set parent MUX type pin (pin_id:
2) to
pin-state: SELECTABLE and highest priority (i.e. pin-prio:0,
while
all the
other pins shall be lower prio i.e. pin-prio:1)
d) SyncE daemon usesPIN_SETto set state of pin_id:14 to CONNECTED
with
parent pin (pin-id:2)Where step c) is required due to AUTOMATIC mode, and step d) required
due to
phy recovery clock pin being connected through the MUX type pin.Thank you!
ArkadiuszQuoted 5 lines
Thanks!
[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 3 lines
From: Jiri Pirko <[email protected]>
Sent: Wednesday, July 26, 2023 8:38 AM
[...]
Quoted 124 lines
Quoted 55 lines
Quoted 30 lines
Quoted 22 lines
Quoted 22 lines
Quoted 10 lines
Just to make it clear:
AUTOMATIC:
- inputs monitored, validated, phase measurements available
- possible states: unlocked, locked, locked-ho-acq, holdoverFREERUN:
- inputs not monitored, not validated, no phase measurements available
- possible states: unlockedThis is your implementation of DPLL. Others may have it done differently. But the fact the input is monitored or not, does not make any difference from user perspective.
When he has automatic mode and does:
1) disconnect all pins
2) reset state (however you implement it in the driver is totaly up
to the device, you may go to your freerun dpll mode internally and to automatic back, up to you)
-> state will go to unlockedQuoted 7 lines
Quoted 1 line
The behaviour is exactly the same, without any special mode.
In this case there is special reset button, which doesn't exist in reality, actually your suggestion to go into FREERUN and back to AUTOMATIC to pretend the some kind of reset has happened, where in reality dpll went to
FREERUN and AUTOMATIC.Quoted 9 lines
There are 3 pin states:
disconnected
connected
selectableWhen the last source disconnects, go to your internal freerun. When some source gets selectable or connected, go to your internal automatic mode.
This would make the driver to check if all the sources are disconnected each time someone disconnects a source. Which in first place is not efficient, but also dpll design already allows different driver instances to
control separated sources, which in this case would force a driver to implement
additional communication between the instances just to allow such hidden FREERUN mode.
Which seems another argument not to do this in the way you are proposing:
inefficient and unnecessarily complicated.We know that you could also implement FREERUN mode by disconnecting all the
sources, even if HW doesn't support it explicitly.Quoted 5 lines
Quoted 2 lines
From user perspactive, the mode didn't change.
The user didn't change the mode, the mode shall not change. You wrote to do it silently, so user didn't change the mode but it would
have
Quoted 1 line
changed, and we would have pretended the different working mode of DPLL
doesn't
Quoted 61 lines
exist.
Quoted 2 lines
From user perepective, this is exacly the behaviour he requested.
IMHO this is wrong and comes from the definition of pin state DISCONNECTED, which is not sharp, for our HW means that the input will not be considered as valid input, but is not disconnecting anything, as input is still monitored and measured.
Shall we have additional mode likePIN_STATE_NOT_SELECTABLE? As it is not possible to actually disconnect a pin..Quoted 7 lines
Quoted 4 lines
For me it seems it seems like unnecessary complication of user's life. The idea of FREERUN mode is to run dpll on its system clock, so all the "external" dpll sources shall be disconnected when dpll is in FREERUN.
Yes, that is when you set all pins to disconnect. no mode change needed.
We don't disconnect anything, we used a pin state DISCONNECTED as this seemed
most appropriate.Quoted 6 lines
Quoted 3 lines
Let's assume your HW doesn't have a FREERUN, can't you just create it by disconnecting all the sources?
Yep, that's what we do.
No, you were saying that the mode doesn't exist and that your hardware doesn't
support it. At the same time it can be achieved by manually disconnecting all
the sources.Quoted 10 lines
Quoted 9 lines
BTW, what chip are you using on mlx5 for this?
I don't understand why the user would have to mangle state of all the pins just
to stop dpll's work if he could just go into FREERUN and voila. Also what if
user doesn't want change the configuration of the pins at all, and he just want
to desynchronize it's dpll for i.e. testing reason.Quoted 4 lines
I tried to explain multiple times. Let the user have clean an abstracted api, with clear semantics. Simple as that. Your internal freerun mode is just something to abstract out, it is not needed to expose it.
Our hardware can support in total 4 modes, and 2 are now supported in ice. I don't get the idea for abstraction of hardware switches, modes or capabilities, and having those somehow achievable through different functionalities.
I think we already discussed this long enough to make a decision.. Though I am not convinced by your arguments, and you are not convinced by mine.
Quoted 7 lines
Quoted 2 lines
Perhaps someone else could step in and cut the rope, so we could go further with this?
Or, even better, please drop this for the initial patchset and have this as a follow-up. Thanks!
On the responses from Jakub and Paolo, they supported the idea of having such mode.
Although Jakub have asked if there could be better name then FREERUN, also suggested DETACHED and STANDALONE.
For me DETACHED seems pretty good, STANDALONE a bit too far.. I am biased by the FREERUN from chip docs and don't have strong opinion on any of those..
Any suggestions?
Thank you!
Arkadiusz
[...]
Vadim Fedorenko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 141 lines · Arkadiusz
Quoted 3 lines
From: Jiri Pirko <[email protected]>
Sent: Wednesday, July 26, 2023 8:38 AM[...]
Quoted 124 lines
Quoted 55 lines
Quoted 30 lines
Quoted 22 lines
Quoted 22 lines
Quoted 10 lines
Just to make it clear:
AUTOMATIC:
- inputs monitored, validated, phase measurements available
- possible states: unlocked, locked, locked-ho-acq, holdoverFREERUN:
- inputs not monitored, not validated, no phase measurements available
- possible states: unlockedThis is your implementation of DPLL. Others may have it done differently. But the fact the input is monitored or not, does not make any difference from user perspective.
When he has automatic mode and does:
1) disconnect all pins
2) reset state (however you implement it in the driver is totaly up
to the device, you may go to your freerun dpll mode internally and to automatic back, up to you)
-> state will go to unlockedQuoted 7 lines
Quoted 1 line
The behaviour is exactly the same, without any special mode.
In this case there is special reset button, which doesn't exist in reality, actually your suggestion to go into FREERUN and back to AUTOMATIC to pretend the some kind of reset has happened, where in reality dpll went to
FREERUN and AUTOMATIC.Quoted 9 lines
There are 3 pin states:
disconnected
connected
selectableWhen the last source disconnects, go to your internal freerun. When some source gets selectable or connected, go to your internal automatic mode.
This would make the driver to check if all the sources are disconnected each time someone disconnects a source. Which in first place is not efficient, but also dpll design already allows different driver instances to
control separated sources, which in this case would force a driver to implement
additional communication between the instances just to allow such hidden FREERUN mode.
Which seems another argument not to do this in the way you are proposing:
inefficient and unnecessarily complicated.We know that you could also implement FREERUN mode by disconnecting all the
sources, even if HW doesn't support it explicitly.Quoted 5 lines
Quoted 2 lines
From user perspactive, the mode didn't change.
The user didn't change the mode, the mode shall not change. You wrote to do it silently, so user didn't change the mode but it would
have
Quoted 1 line
changed, and we would have pretended the different working mode of DPLL
doesn't
Quoted 61 lines
exist.
Quoted 2 lines
From user perepective, this is exacly the behaviour he requested.
IMHO this is wrong and comes from the definition of pin state DISCONNECTED, which is not sharp, for our HW means that the input will not be considered as valid input, but is not disconnecting anything, as input is still monitored and measured.
Shall we have additional mode likePIN_STATE_NOT_SELECTABLE? As it is not possible to actually disconnect a pin..Quoted 7 lines
Quoted 4 lines
For me it seems it seems like unnecessary complication of user's life. The idea of FREERUN mode is to run dpll on its system clock, so all the "external" dpll sources shall be disconnected when dpll is in FREERUN.
Yes, that is when you set all pins to disconnect. no mode change needed.
We don't disconnect anything, we used a pin state DISCONNECTED as this seemed
most appropriate.Quoted 6 lines
Quoted 3 lines
Let's assume your HW doesn't have a FREERUN, can't you just create it by disconnecting all the sources?
Yep, that's what we do.
No, you were saying that the mode doesn't exist and that your hardware doesn't
support it. At the same time it can be achieved by manually disconnecting all
the sources.Quoted 10 lines
Quoted 9 lines
BTW, what chip are you using on mlx5 for this?
I don't understand why the user would have to mangle state of all the pins just
to stop dpll's work if he could just go into FREERUN and voila. Also what if
user doesn't want change the configuration of the pins at all, and he just want
to desynchronize it's dpll for i.e. testing reason.Quoted 4 lines
I tried to explain multiple times. Let the user have clean an abstracted api, with clear semantics. Simple as that. Your internal freerun mode is just something to abstract out, it is not needed to expose it.
Our hardware can support in total 4 modes, and 2 are now supported in ice. I don't get the idea for abstraction of hardware switches, modes or capabilities, and having those somehow achievable through different functionalities.
I think we already discussed this long enough to make a decision.. Though I am not convinced by your arguments, and you are not convinced by mine.
Quoted 7 lines
Quoted 2 lines
Perhaps someone else could step in and cut the rope, so we could go further with this?
Or, even better, please drop this for the initial patchset and have this as a follow-up. Thanks!
On the responses from Jakub and Paolo, they supported the idea of having such mode.
Quoted 7 lines
Although Jakub have asked if there could be better name then FREERUN, also suggested DETACHED and STANDALONE.
For me DETACHED seems pretty good, STANDALONE a bit too far.. I am biased by the FREERUN from chip docs and don't have strong opinion on any of those..Any suggestions?
It looks like we have a kind of split-brain situation, and my thoughts are following:
Even though right now we don't have any hardware supporting freerun/standalone mode, I do really like the idea to have it. It will be used in monitoring implementations where we refer to internal oscillator (Rb/Cs) as a source of truth to compare with the signal on the other pins. We can name it DETACHED if it sounds better.
Quoted 5 lines
Thank you!
Arkadiusz[...]
Jakub Kicinski
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
In reply to Jiri PirkoQuoted 4 lines · On Fri, 21 Jul 2023 14:02:08 +0200 Jiri Pirko wrote:
So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
+1 for mixing the state machine and config. Maybe a compromise would be to rename the config mode? Detached? Standalone?
Quoted 5 lines
Please don't mix config and state. I think we untangled this in the past :/
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.
Paolo Abeni
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 9 lines · Jakub Kicinski
Quoted 4 lines · On Fri, 21 Jul 2023 14:02:08 +0200 Jiri Pirko wrote:
So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
+1 for mixing the state machine and config. Maybe a compromise would be to rename the config mode? Detached? Standalone?
For the records, I don't know the H/W details to any extents, but generally speaking it sounds reasonable to me that a mode change could cause a state change.
e.g. switching an ethernet device autoneg mode could cause the link state to flip.
So I'm ok with the existence of the freerun mode.
I think it should be clarified what happens if pins are manually enabled in such mode. I expect ~nothing will change, but stating it clearly would help.
Cheers,
Paolo
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 25 lines
From: Paolo Abeni <[email protected]>
Sent: Wednesday, July 26, 2023 5:20 PMQuoted 10 lines · Jakub Kicinski
Quoted 5 lines · On Fri, 21 Jul 2023 14:02:08 +0200 Jiri Pirko wrote:
So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked,
holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.+1 for mixing the state machine and config. Maybe a compromise would be to rename the config mode? Detached? Standalone?
For the records, I don't know the H/W details to any extents, but generally speaking it sounds reasonable to me that a mode change could cause a state change.
e.g. switching an ethernet device autoneg mode could cause the link state to flip.
So I'm ok with the existence of the freerun mode.
Quoted 8 lines
I think it should be clarified what happens if pins are manually enabled in such mode. I expect ~nothing will change, but stating it clearly would help.
Cheers,
Paolo
Thank you for the insights!
Arkadiusz
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
In reply to Paolo AbeniQuoted 7 lines · Wed, Jul 26, 2023 at 05:20:12PM CEST, [email protected] wrote:
Quoted 6 lines · Jakub Kicinski
Quoted 4 lines · On Fri, 21 Jul 2023 14:02:08 +0200 Jiri Pirko wrote:
So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Quoted 7 lines
Quoted 3 lines
+1 for mixing the state machine and config. Maybe a compromise would be to rename the config mode? Detached? Standalone?
For the records, I don't know the H/W details to any extents, but generally speaking it sounds reasonable to me that a mode change could cause a state change.
The thing is, you don't need an extra mode just to "reset state". There could be a command for it, staying under the same mode. That way, things would be cleaner and obvious for the user.
case a)
AUTOMATIC MODE
user changes to FREERUN to reset state
user changes back to AUTOMATIC to continue
case b)
AUTOMATIC MODE
user submits state reset command
Quoted 8 lines
e.g. switching an ethernet device autoneg mode could cause the link state to flip.
So I'm ok with the existence of the freerun mode.
I think it should be clarified what happens if pins are manually enabled in such mode. I expect ~nothing will change, but stating it
That is another very good point you touched. In the "freerun" mode, the pins does not have any meaning.
The same you achieve with automatic mode, setting all pins to disconnect.
If we have freerun mode, the core should sanitize all pins are disconnect and stay disconnect. But do you see how ridiculous this is becoming? :)
Quoted 6 lines
clearly would help.
Cheers,
Paolo
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
In reply to Jakub KicinskiQuoted 10 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, July 26, 2023 12:50 AMQuoted 5 lines · On Fri, 21 Jul 2023 14:02:08 +0200 Jiri Pirko wrote:
So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked,
holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
Quoted 4 lines
+1 for mixing the state machine and config. Maybe a compromise would be to rename the config mode? Detached? Standalone?
Well, those seems good although standalone a bit like the property of a device. I am biased by the FREERUN from chip docs and don't have strong opinion on any of those..
Thank you!
Arkadiusz
Quoted 5 lines
Quoted 5 lines
Please don't mix config and state. I think we untangled this in the past :/
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
In reply to Jakub KicinskiQuoted 9 lines · Wed, Jul 26, 2023 at 12:49:58AM CEST, [email protected] wrote:
Quoted 4 lines · On Fri, 21 Jul 2023 14:02:08 +0200 Jiri Pirko wrote:
So it is not a mode! Mode is either "automatic" or "manual". Then we have a state to indicate the state of the state machine (unlocked, locked, holdover, holdover-acq). So what you seek is a way for the user to expliticly set the state to "unlocked" and reset of the state machine.
+1 for mixing the state machine and config. Maybe a compromise would be to rename the config mode? Detached? Standalone?
But even with different name, you will still have the same mixture.
Why having automatic/manual mode with possibility to connect/disconnect pins with additional uapi extension to submit state reset command is not enough? Clear and simple, easy to document and understand.
There are too many uncertanties about "freerun" mode, very confusing, not clear behaviour (as this thread demonstrated). That is extually very good reason to don't have it. Could we please drop it?
Quoted 6 lines
Quoted 6 lines
Please don't mix config and state. I think we untangled this in the past :/
Perhaps you just need an extra cmd like
DPLL_CMD_DEVICE_STATE_RESETcmd to hit this button.
Jakub Kicinski
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
In reply to Jiri PirkoQuoted 14 lines · On Fri, 21 Jul 2023 09:33:14 +0200 Jiri Pirko wrote:
Quoted 2 lines
d) SyncE daemon uses
PIN_SETto set state of pin_id:13 to CONNECTED with parent pin (pin-id:2)For this you need
pin_idandpin_parent_idbecause you set the state on a parent pin.Yeah, this is exactly why I initially was in favour of hiding all the muxes and magic around it hidden from the user. Now every userspace app working with this has to implement a logic of tracking pin and the mux parents (possibly multiple levels) and configure everything. But it just need a simple thing: "select this pin as a source" :/
Quoted 2 lines
Jakub, isn't this sort of unnecessary HW-details complexicity exposure in UAPI you were against in the past? Am I missing something?
From just reading what I'm quoting - I don't think so. Muxes are meaningful because they limit valid configurations. We can implement "automatic mutex config" in the kernel if user wants it, centrally in the core, otherwise each driver will have to do it on its own.
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
In reply to Vadim FedorenkoQuoted 146 lines · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
Control over clock generation unit is required for further development of Synchronous Ethernet feature. Interface provides ability to obtain current state of a dpll, its sources and outputs which are pins, and allows their configuration.
Co-developed-by Milena Olech <[email protected]>Signed-off-by Milena Olech <[email protected]>Co-developed-by Michal Michalik <[email protected]>Signed-off-by Michal Michalik <[email protected]>Signed-off-by Arkadiusz Kubalewski <[email protected]>Signed-off-by Vadim Fedorenko <[email protected]>---
RFCv9->v0:
- add support forDPLL_MODE_FREERUNmode
- useDPLL_LOCK_STATUS, removeICE_DPLL_LOCK_STATUS
- fix mutex locking scheme
- remove rclk pin label
- fix/remmove struct fields descriptions
v8->v9:
- drop pointless 0 assignement
-ice_dpll_init(..)returns void instead of int
- fix context description of the functions
- fixice_dpll_init(..)traces
- fix usepackage_labelinstead pfboard_labelfor rclk pin
- be consistent on cgu presence naming
- remove indent inice_dpll_deinit(..)
- remove unused struct fieldlock_err_num
- fix kworker resched behavior
- remove debug log fromice_dpll_deinit_worker(..)
- reorder ice internal functions
- release resources directly on error path
- remove redundant NULL checks when releasing resources
- do not assign NULL to pointers after releasing resources
- simplify variable assignement
- fix 'int ret;' declarations across theice_dpll.c
- remove leftoverice_dpll_find(..)
- get pf pointer fromdpll_privwithout type cast
- improve error reporting
- fix documentation
- fixice_dpll_update_state(..)flow
- fix return in case out of range prio setdrivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 3 + drivers/net/ethernet/intel/ice/ice_dpll.c | 2053 +++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_dpll.h | 104 ++ drivers/net/ethernet/intel/ice/ice_main.c | 7 + 6 files changed, 2170 insertions(+), 1 deletion(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_dpll.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_dpll.hdrivers/net/ethernet/intel/Kconfig +1
-0@@ -284,6 +284,7 @@ config ICE select DIMLIB select NET_DEVLINK select PLDMFW + select DPLL help This driver supports Intel(R) Ethernet Connection E800 Series of devices. For more information on how to identify your adapter, godrivers/net/ethernet/intel/ice/Makefile +2
-1@@ -34,7 +34,8 @@ ice-y := ice_main.o \ ice_lag.o \ ice_ethtool.o \ ice_repr.o \ - ice_tc_lib.o + ice_tc_lib.o \ + ice_dpll.o ice-$(CONFIG_PCI_IOV) += \ ice_sriov.o \ ice_virtchnl.o \drivers/net/ethernet/intel/ice/ice.h +3
-0@@ -76,6 +76,7 @@#include "ice_vsi_vlan_ops.h" #include "ice_gnss.h" #include "ice_irq.h" +#include "ice_dpll.h" #define ICE_BAR0 0#define ICE_REQ_DESC_MULTIPLE 32@@ -507,6 +508,7 @@ enum ice_pf_flags {ICE_FLAG_UNPLUG_AUX_DEV ,ICE_FLAG_MTU_CHANGED ,ICE_FLAG_GNSS ,/* GNSS successfully initialized */ +ICE_FLAG_DPLL ,/* SyncE/PTP dplls initialized */ ICE_PF_FLAGS_NBITS /* must be last */ };@@ -636,6 +638,7 @@ struct ice_pf {#define ICE_VF_AGG_NODE_ID_START 65#define ICE_MAX_VF_AGG_NODES 32struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES ]; +struct ice_dplls dplls; };struct ice_netdev_priv {drivers/net/ethernet/intel/ice/ice_dpll.c new file +31
-0@@ -0,0 +1,2053 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) 2022, Intel Corporation. */ + +#include "ice.h" +#include "ice_lib.h" +#include "ice_trace.h" +#include <linux/dpll.h> + +#define ICE_CGU_STATE_ACQ_ERR_THRESHOLD 50 +#define ICE_DPLL_LOCK_TRIES 1000 +#define ICE_DPLL_PIN_IDX_INVALID 0xff +#define ICE_DPLL_RCLK_NUM_PER_PF 1 + +/** +* enum ice_dpll_pin_type - enumerate ice pin types: +* @ICE_DPLL_PIN_INVALID: invalid pin type +* @ICE_DPLL_PIN_TYPE_INPUT: input pin +* @ICE_DPLL_PIN_TYPE_OUTPUT: output pin +* @ICE_DPLL_PIN_TYPE_RCLK_INPUT: recovery clock input pin +*/ +enum ice_dpll_pin_type { +ICE_DPLL_PIN_INVALID , +ICE_DPLL_PIN_TYPE_INPUT , +ICE_DPLL_PIN_TYPE_OUTPUT , +ICE_DPLL_PIN_TYPE_RCLK_INPUT , +}; + +static const char *const pin_type_name[] = { + [ICE_DPLL_PIN_TYPE_INPUT ] ="input" , + [ICE_DPLL_PIN_TYPE_OUTPUT ] ="output" , + [ICE_DPLL_PIN_TYPE_RCLK_INPUT ] ="rclk-input" ,
drivers/net/ethernet/intel/ice/ice_dpll.c line 41
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+}; + +/** +* ice_dpll_cb_lock - lock dplls mutex in callback context +* @pf: private board structure +* @extack: error reporting +* +* Lock the mutex from the callback operations invoked by dpll subsystem. +* Prevent dead lock caused by `rmmod ice` when dpll callbacks are under stress +* tests.
I don't know, I will probably need to beg you here. Why exactly are you ignoring my comments? It's not nice, I thought we are way past it...
There is no "dead lock". Could you please describe how exactly the case you mention can happen? It can't.
Could you please remove the trylock iteration below? It's completely pointless.
drivers/net/ethernet/intel/ice/ice_dpll.c line 52
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +11
-0+* +* Return: +* 0 - if lock acquired +* negative - lock not acquired or dpll is not initialized +*/ +static int ice_dpll_cb_lock (struct ice_pf *pf,struct netlink_ext_ack *extack) +{ +int i; + +for (i =0 ; i <ICE_DPLL_LOCK_TRIES ; i++) { +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) {
And again, as I already told you, this flag checking is totally pointless. See below my comment to ice_dpll_init()/ice_dpll_deinit().
drivers/net/ethernet/intel/ice/ice_dpll.c line 62
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+if (extack) +NL_SET_ERR_MSG (extack, +"ice dpll not initialized" ); +return -EFAULT ; + } +if (mutex_trylock (&pf->dplls.lock)) +return 0 ; +usleep_range (100 ,150 ); + } +if (extack)
No need to check for NULL, but this code should be dropped anyway.
Quoted 1,222 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +1222
-0+NL_SET_ERR_MSG (extack,"was not able to acquire mutex" ); + +return -EBUSY ; +} + +/** +* ice_dpll_cb_unlock - unlock dplls mutex in callback context +* @pf: private board structure +* +* Unlock the mutex from the callback operations invoked by dpll subsystem. +*/ +static void ice_dpll_cb_unlock (struct ice_pf *pf) +{ +mutex_unlock (&pf->dplls.lock); +} + +/** +* ice_dpll_pin_freq_set - set pin's frequency +* @pf: private board structure +* @pin: pointer to a pin +* @pin_type: type of pin being configured +* @freq: frequency to be set +* @extack: error reporting +* +* Set requested frequency on a pin. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - error on AQ or wrong pin type given +*/ +static int +ice_dpll_pin_freq_set (struct ice_pf *pf,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type,const u32 freq, +struct netlink_ext_ack *extack) +{ +int ret; +u8 flags; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + flags =ICE_AQC_SET_CGU_IN_CFG_FLG1_UPDATE_FREQ ; + ret =ice_aq_set_input_pin_cfg (&pf->hw, pin->idx, flags, + pin->flags[0 ], freq,0 ); +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + flags =ICE_AQC_SET_CGU_OUT_CFG_UPDATE_FREQ ; + ret =ice_aq_set_output_pin_cfg (&pf->hw, pin->idx, flags, +0 , freq,0 ); +break ; +default : +return -EINVAL ; + } +if (ret) { +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to set pin freq:%u on pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + freq, pin->idx); +return ret; + } + pin->freq = freq; + +return 0 ; +} + +/** +* ice_dpll_frequency_set - wrapper for pin callback for set frequency +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: pointer to dpll +* @dpll_priv: private data pointer passed on dpll registration +* @frequency: frequency to be set +* @extack: error reporting +* @pin_type: type of pin being configured +* +* Wraps internal set frequency command on a pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - error pin not found or couldn't set in hw +*/ +static int +ice_dpll_frequency_set (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +const u32 frequency, +struct netlink_ext_ack *extack, +enum ice_dpll_pin_type pin_type) +{ +struct ice_dpll_pin *p = pin_priv; +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + ret =ice_dpll_pin_freq_set (pf, p, pin_type, frequency, extack); +ice_dpll_cb_unlock (pf); + +return ret; +} + +/** +* ice_dpll_input_frequency_set - input pin callback for set frequency +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: pointer to dpll +* @dpll_priv: private data pointer passed on dpll registration +* @frequency: frequency to be set +* @extack: error reporting +* +* Wraps internal set frequency command on a pin. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - error pin not found or couldn't set in hw +*/ +static int +ice_dpll_input_frequency_set (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +u64 frequency,struct netlink_ext_ack *extack) +{ +return ice_dpll_frequency_set (pin, pin_priv, dpll, dpll_priv, frequency, + extack,ICE_DPLL_PIN_TYPE_INPUT ); +} + +/** +* ice_dpll_output_frequency_set - output pin callback for set frequency +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: pointer to dpll +* @dpll_priv: private data pointer passed on dpll registration +* @frequency: frequency to be set +* @extack: error reporting +* +* Wraps internal set frequency command on a pin. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - error pin not found or couldn't set in hw +*/ +static int +ice_dpll_output_frequency_set (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +u64 frequency,struct netlink_ext_ack *extack) +{ +return ice_dpll_frequency_set (pin, pin_priv, dpll, dpll_priv, frequency, + extack,ICE_DPLL_PIN_TYPE_OUTPUT ); +} + +/** +* ice_dpll_frequency_get - wrapper for pin callback for get frequency +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: pointer to dpll +* @dpll_priv: private data pointer passed on dpll registration +* @frequency: on success holds pin's frequency +* @extack: error reporting +* @pin_type: type of pin being configured +* +* Wraps internal get frequency command of a pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - error pin not found or couldn't get from hw +*/ +static int +ice_dpll_frequency_get (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +u64 *frequency,struct netlink_ext_ack *extack, +enum ice_dpll_pin_type pin_type) +{ +struct ice_dpll_pin *p = pin_priv; +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + *frequency = p->freq; +ice_dpll_cb_unlock (pf); + +return 0 ; +} + +/** +* ice_dpll_input_frequency_get - input pin callback for get frequency +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: pointer to dpll +* @dpll_priv: private data pointer passed on dpll registration +* @frequency: on success holds pin's frequency +* @extack: error reporting +* +* Wraps internal get frequency command of a input pin. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - error pin not found or couldn't get from hw +*/ +static int +ice_dpll_input_frequency_get (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +u64 *frequency,struct netlink_ext_ack *extack) +{ +return ice_dpll_frequency_get (pin, pin_priv, dpll, dpll_priv, frequency, + extack,ICE_DPLL_PIN_TYPE_INPUT ); +} + +/** +* ice_dpll_output_frequency_get - output pin callback for get frequency +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: pointer to dpll +* @dpll_priv: private data pointer passed on dpll registration +* @frequency: on success holds pin's frequency +* @extack: error reporting +* +* Wraps internal get frequency command of a pin. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - error pin not found or couldn't get from hw +*/ +static int +ice_dpll_output_frequency_get (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +u64 *frequency,struct netlink_ext_ack *extack) +{ +return ice_dpll_frequency_get (pin, pin_priv, dpll, dpll_priv, frequency, + extack,ICE_DPLL_PIN_TYPE_OUTPUT ); +} + +/** +* ice_dpll_pin_enable - enable a pin on dplls +* @hw: board private hw structure +* @pin: pointer to a pin +* @pin_type: type of pin being enabled +* @extack: error reporting +* +* Enable a pin on both dplls. Store current state in pin->flags. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK +* * negative - error +*/ +static int +ice_dpll_pin_enable (struct ice_hw *hw,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{ +u8 flags =0 ; +int ret; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : +if (pin->flags[0 ] &ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN ) + flags |=ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN ; + flags |=ICE_AQC_SET_CGU_IN_CFG_FLG2_INPUT_EN ; + ret =ice_aq_set_input_pin_cfg (hw, pin->idx,0 , flags,0 ,0 ); +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : +if (pin->flags[0 ] &ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN ) + flags |=ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN ; + flags |=ICE_AQC_SET_CGU_OUT_CFG_OUT_EN ; + ret =ice_aq_set_output_pin_cfg (hw, pin->idx, flags,0 ,0 ,0 ); +break ; +default : +return -EINVAL ; + } +if (ret) +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to enable %s pin:%u\n" , + ret,ice_aq_str (hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + +return ret; +} + +/** +* ice_dpll_pin_disable - disable a pin on dplls +* @hw: board private hw structure +* @pin: pointer to a pin +* @pin_type: type of pin being disabled +* @extack: error reporting +* +* Disable a pin on both dplls. Store current state in pin->flags. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK +* * negative - error +*/ +static int +ice_dpll_pin_disable (struct ice_hw *hw,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{ +u8 flags =0 ; +int ret; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : +if (pin->flags[0 ] &ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN ) + flags |=ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN ; + ret =ice_aq_set_input_pin_cfg (hw, pin->idx,0 , flags,0 ,0 ); +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : +if (pin->flags[0 ] &ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN ) + flags |=ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN ; + ret =ice_aq_set_output_pin_cfg (hw, pin->idx, flags,0 ,0 ,0 ); +break ; +default : +return -EINVAL ; + } +if (ret) +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to disable %s pin:%u\n" , + ret,ice_aq_str (hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + +return ret; +} + +/** +* ice_dpll_pin_state_update - update pin's state +* @pf: private board struct +* @pin: structure with pin attributes to be updated +* @pin_type: type of pin being updated +* @extack: error reporting +* +* Determine pin current state and frequency, then update struct +* holding the pin info. For input pin states are separated for each +* dpll, for rclk pins states are separated for each parent. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - OK +* * negative - error +*/ +int +ice_dpll_pin_state_update (struct ice_pf *pf,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type, +struct netlink_ext_ack *extack) +{ +int ret; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + ret =ice_aq_get_input_pin_cfg (&pf->hw, pin->idx,NULL ,NULL , +NULL , &pin->flags[0 ], + &pin->freq,NULL ); +if (ret) + goto err; +if (ICE_AQC_GET_CGU_IN_CFG_FLG2_INPUT_EN & pin->flags[0 ]) { +if (pin->pin) { + pin->state[pf->dplls.eec.dpll_idx] = + pin->pin == pf->dplls.eec.active_input ? +DPLL_PIN_STATE_CONNECTED : +DPLL_PIN_STATE_SELECTABLE ; + pin->state[pf->dplls.pps.dpll_idx] = + pin->pin == pf->dplls.pps.active_input ? +DPLL_PIN_STATE_CONNECTED : +DPLL_PIN_STATE_SELECTABLE ; + }else { + pin->state[pf->dplls.eec.dpll_idx] = +DPLL_PIN_STATE_SELECTABLE ; + pin->state[pf->dplls.pps.dpll_idx] = +DPLL_PIN_STATE_SELECTABLE ; + } + }else { + pin->state[pf->dplls.eec.dpll_idx] = +DPLL_PIN_STATE_DISCONNECTED ; + pin->state[pf->dplls.pps.dpll_idx] = +DPLL_PIN_STATE_DISCONNECTED ; + } +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + ret =ice_aq_get_output_pin_cfg (&pf->hw, pin->idx, + &pin->flags[0 ],NULL , + &pin->freq,NULL ); +if (ret) + goto err; +if (ICE_AQC_SET_CGU_OUT_CFG_OUT_EN & pin->flags[0 ]) + pin->state[0 ] =DPLL_PIN_STATE_CONNECTED ; +else + pin->state[0 ] =DPLL_PIN_STATE_DISCONNECTED ; +break ; +case ICE_DPLL_PIN_TYPE_RCLK_INPUT : +u8 parent, port_num =ICE_AQC_SET_PHY_REC_CLK_OUT_CURR_PORT ; + +for (parent =0 ; parent < pf->dplls.rclk.num_parents; + parent++) { +u8 p = parent; + + ret =ice_aq_get_phy_rec_clk_out (&pf->hw, &p, + &port_num, + &pin->flags[parent], +NULL ); +if (ret) + goto err; +if (ICE_AQC_GET_PHY_REC_CLK_OUT_OUT_EN & + pin->flags[parent]) + pin->state[parent] =DPLL_PIN_STATE_CONNECTED ; +else + pin->state[parent] = +DPLL_PIN_STATE_DISCONNECTED ; + } +break ; +default : +return -EINVAL ; + } + +return 0 ; +err: +if (extack) +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to update %s pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); +else +dev_err_ratelimited (ice_pf_to_dev (pf), +"err:%d %s failed to update %s pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); +return ret; +} + +/** +* ice_dpll_hw_input_prio_set - set input priority value in hardware +* @pf: board private structure +* @dpll: ice dpll pointer +* @pin: ice pin pointer +* @prio: priority value being set on a dpll +* @extack: error reporting +* +* Internal wrapper for setting the priority in the hardware. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - failure +*/ +static int +ice_dpll_hw_input_prio_set (struct ice_pf *pf,struct ice_dpll *dpll, +struct ice_dpll_pin *pin,const u32 prio, +struct netlink_ext_ack *extack) +{ +int ret; + + ret =ice_aq_set_cgu_ref_prio (&pf->hw, dpll->dpll_idx, pin->idx, + (u8 )prio); +if (ret) +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to set pin prio:%u on pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + prio, pin->idx); +else + dpll->input_prio[pin->idx] = prio; + +return ret; +} + +/** +* ice_dpll_lock_status_get - get dpll lock status callback +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @status: on success holds dpll's lock status +* @extack: error reporting +* +* Dpll subsystem callback, provides dpll's lock status. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - failure +*/ +static int +ice_dpll_lock_status_get (const struct dpll_device *dpll,void *dpll_priv, +enum dpll_lock_status *status, +struct netlink_ext_ack *extack) +{ +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + *status = d->dpll_state; +ice_dpll_cb_unlock (pf); + +return ret; +} + +/** +* ice_dpll_mode_supported - check if dpll's working mode is supported +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @mode: mode to be checked for support +* @extack: error reporting +* +* Dpll subsystem callback. Provides information if working mode is supported +* by dpll. +* +* Return: +* * true - mode is supported +* * false - mode is not supported +*/ +static bool ice_dpll_mode_supported (const struct dpll_device *dpll, +void *dpll_priv, +enum dpll_mode mode, +struct netlink_ext_ack *extack) +{ +if (mode ==DPLL_MODE_AUTOMATIC || + mode ==DPLL_MODE_FREERUN ) +return true; + +return false; +} + +/** +* ice_dpll_mode_get - get dpll's working mode +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @mode: on success holds current working mode of dpll +* @extack: error reporting +* +* Dpll subsystem callback. Provides working mode of dpll. +* +* Return: +* * 0 - success +* * negative - failure +*/ +static int ice_dpll_mode_get (const struct dpll_device *dpll,void *dpll_priv, +enum dpll_mode *mode, +struct netlink_ext_ack *extack) +{ +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + *mode = d->mode; +ice_dpll_cb_unlock (pf); + +return 0 ; +} + +/** +* ice_dpll_mode_set - set dpll's working mode +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @mode: requested working mode of dpll +* @extack: error reporting +* +* Dpll subsystem callback. User requests working mode of dpll. +* +* Return: +* * 0 - success +* * negative - failure +*/ +static int ice_dpll_mode_set (const struct dpll_device *dpll,void *dpll_priv, +enum dpll_mode mode, +struct netlink_ext_ack *extack) +{ +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +u8 config; +int ret; + +switch (mode) { +case DPLL_MODE_AUTOMATIC : + config =ICE_AQC_SET_CGU_DPLL_CONFIG_MODE_AUTOMATIC ; +break ; +case DPLL_MODE_FREERUN : + config =ICE_AQC_SET_CGU_DPLL_CONFIG_MODE_FREERUN ; +break ; +default : +return -EINVAL ; + } + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + ret =ice_aq_set_cgu_dpll_config (&pf->hw, d->dpll_idx, d->ref_state, + config, d->eec_mode); +if (ret) +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to set mode:%u on dpll:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + mode, d->dpll_idx); +else + d->mode = mode; +ice_dpll_cb_unlock (pf); + +return ret; +} + +/** +* ice_dpll_pin_state_set - set pin's state on dpll +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @enable: if pin shalll be enabled +* @extack: error reporting +* @pin_type: type of a pin +* +* Set pin state on a pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - OK or no change required +* * negative - error +*/ +static int +ice_dpll_pin_state_set (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +bool enable,struct netlink_ext_ack *extack, +enum ice_dpll_pin_type pin_type) +{ +struct ice_dpll_pin *p = pin_priv; +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; +if (enable) + ret =ice_dpll_pin_enable (&pf->hw, p, pin_type, extack); +else + ret =ice_dpll_pin_disable (&pf->hw, p, pin_type, extack); +if (!ret) + ret =ice_dpll_pin_state_update (pf, p, pin_type, extack); +ice_dpll_cb_unlock (pf); + +return ret; +} + +/** +* ice_dpll_output_state_set - enable/disable output pin on dpll device +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: dpll being configured +* @dpll_priv: private data pointer passed on dpll registration +* @state: state of pin to be set +* @extack: error reporting +* +* Dpll subsystem callback. Set given state on output type pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - successfully enabled mode +* * negative - failed to enable mode +*/ +static int +ice_dpll_output_state_set (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +enum dpll_pin_state state, +struct netlink_ext_ack *extack) +{ +bool enable = state ==DPLL_PIN_STATE_CONNECTED ; + +return ice_dpll_pin_state_set (pin, pin_priv, dpll, dpll_priv, enable, + extack,ICE_DPLL_PIN_TYPE_OUTPUT ); +} + +/** +* ice_dpll_input_state_set - enable/disable input pin on dpll levice +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: dpll being configured +* @dpll_priv: private data pointer passed on dpll registration +* @state: state of pin to be set +* @extack: error reporting +* +* Dpll subsystem callback. Enables given mode on input type pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - successfully enabled mode +* * negative - failed to enable mode +*/ +static int +ice_dpll_input_state_set (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +enum dpll_pin_state state, +struct netlink_ext_ack *extack) +{ +bool enable = state ==DPLL_PIN_STATE_SELECTABLE ; + +return ice_dpll_pin_state_set (pin, pin_priv, dpll, dpll_priv, enable, + extack,ICE_DPLL_PIN_TYPE_INPUT ); +} + +/** +* ice_dpll_pin_state_get - set pin's state on dpll +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @state: on success holds state of the pin +* @extack: error reporting +* @pin_type: type of questioned pin +* +* Determine pin state set it on a pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - failed to get state +*/ +static int +ice_dpll_pin_state_get (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +enum dpll_pin_state *state, +struct netlink_ext_ack *extack, +enum ice_dpll_pin_type pin_type) +{ +struct ice_dpll_pin *p = pin_priv; +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + ret =ice_dpll_pin_state_update (pf, p, pin_type, extack); +if (ret) + goto unlock; +if (pin_type ==ICE_DPLL_PIN_TYPE_INPUT ) + *state = p->state[d->dpll_idx]; +else if (pin_type ==ICE_DPLL_PIN_TYPE_OUTPUT ) + *state = p->state[0 ]; + ret =0 ; +unlock: +ice_dpll_cb_unlock (pf); + +return ret; +} + +/** +* ice_dpll_output_state_get - get output pin state on dpll device +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @state: on success holds state of the pin +* @extack: error reporting +* +* Dpll subsystem callback. Check state of a pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - failed to get state +*/ +static int +ice_dpll_output_state_get (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +enum dpll_pin_state *state, +struct netlink_ext_ack *extack) +{ +return ice_dpll_pin_state_get (pin, pin_priv, dpll, dpll_priv, state, + extack,ICE_DPLL_PIN_TYPE_OUTPUT ); +} + +/** +* ice_dpll_input_state_get - get input pin state on dpll device +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @state: on success holds state of the pin +* @extack: error reporting +* +* Dpll subsystem callback. Check state of a input pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - failed to get state +*/ +static int +ice_dpll_input_state_get (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +enum dpll_pin_state *state, +struct netlink_ext_ack *extack) +{ +return ice_dpll_pin_state_get (pin, pin_priv, dpll, dpll_priv, state, + extack,ICE_DPLL_PIN_TYPE_INPUT ); +} + +/** +* ice_dpll_input_prio_get - get dpll's input prio +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @prio: on success - returns input priority on dpll +* @extack: error reporting +* +* Dpll subsystem callback. Handler for getting priority of a input pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - failure +*/ +static int +ice_dpll_input_prio_get (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +u32 *prio,struct netlink_ext_ack *extack) +{ +struct ice_dpll_pin *p = pin_priv; +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + *prio = d->input_prio[p->idx]; +ice_dpll_cb_unlock (pf); + +return 0 ; +} + +/** +* ice_dpll_input_prio_set - set dpll input prio +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @prio: input priority to be set on dpll +* @extack: error reporting +* +* Dpll subsystem callback. Handler for setting priority of a input pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - failure +*/ +static int +ice_dpll_input_prio_set (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +u32 prio,struct netlink_ext_ack *extack) +{ +struct ice_dpll_pin *p = pin_priv; +struct ice_dpll *d = dpll_priv; +struct ice_pf *pf = d->pf; +int ret; + +if (prio >ICE_DPLL_PRIO_MAX ) { +NL_SET_ERR_MSG_FMT (extack,"prio out of supported range 0-%d" , +ICE_DPLL_PRIO_MAX ); +return -EINVAL ; + } + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + ret =ice_dpll_hw_input_prio_set (pf, d, p, prio, extack); +ice_dpll_cb_unlock (pf); + +return ret; +} + +/** +* ice_dpll_input_direction - callback for get input pin direction +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @direction: holds input pin direction +* @extack: error reporting +* +* Dpll subsystem callback. Handler for getting direction of a input pin. +* +* Return: +* * 0 - success +*/ +static int +ice_dpll_input_direction (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +enum dpll_pin_direction *direction, +struct netlink_ext_ack *extack) +{ + *direction =DPLL_PIN_DIRECTION_INPUT ; + +return 0 ; +} + +/** +* ice_dpll_output_direction - callback for get output pin direction +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @dpll: registered dpll pointer +* @dpll_priv: private data pointer passed on dpll registration +* @direction: holds output pin direction +* @extack: error reporting +* +* Dpll subsystem callback. Handler for getting direction of an output pin. +* +* Return: +* * 0 - success +*/ +static int +ice_dpll_output_direction (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_device *dpll,void *dpll_priv, +enum dpll_pin_direction *direction, +struct netlink_ext_ack *extack) +{ + *direction =DPLL_PIN_DIRECTION_OUTPUT ; + +return 0 ; +} + +/** +* ice_dpll_rclk_state_on_pin_set - set a state on rclk pin +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @parent_pin: pin parent pointer +* @parent_pin_priv: parent private data pointer passed on pin registration +* @state: state to be set on pin +* @extack: error reporting +* +* Dpll subsystem callback, set a state of a rclk pin on a parent pin +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - failure +*/ +static int +ice_dpll_rclk_state_on_pin_set (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_pin *parent_pin, +void *parent_pin_priv, +enum dpll_pin_state state, +struct netlink_ext_ack *extack) +{ +struct ice_dpll_pin *p = pin_priv, *parent = parent_pin_priv; +bool enable = state ==DPLL_PIN_STATE_CONNECTED ; +struct ice_pf *pf = p->pf; +u32 hw_idx; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + hw_idx = parent->idx - pf->dplls.base_rclk_idx; +if (hw_idx >= pf->dplls.num_inputs) + goto unlock; + +if ((enable && p->state[hw_idx] ==DPLL_PIN_STATE_CONNECTED ) || + (!enable && p->state[hw_idx] ==DPLL_PIN_STATE_DISCONNECTED )) { +NL_SET_ERR_MSG_FMT (extack, +"pin:%u state:%u on parent:%u already set" , + p->idx, state, parent->idx); + ret = -EINVAL ; + goto unlock; + } + ret =ice_aq_set_phy_rec_clk_out (&pf->hw, hw_idx, enable, + &p->freq); +if (ret) +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to set pin state:%u for pin:%u on parent:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + state, p->idx, parent->idx); +unlock: +ice_dpll_cb_unlock (pf); + +return ret; +} + +/** +* ice_dpll_rclk_state_on_pin_get - get a state of rclk pin +* @pin: pointer to a pin +* @pin_priv: private data pointer passed on pin registration +* @parent_pin: pin parent pointer +* @parent_pin_priv: pin parent priv data pointer passed on pin registration +* @state: on success holds pin state on parent pin +* @extack: error reporting +* +* dpll subsystem callback, get a state of a recovered clock pin. +* +* Context: Acquires pf->dplls.lock +* Return: +* * 0 - success +* * negative - failure +*/ +static int +ice_dpll_rclk_state_on_pin_get (const struct dpll_pin *pin,void *pin_priv, +const struct dpll_pin *parent_pin, +void *parent_pin_priv, +enum dpll_pin_state *state, +struct netlink_ext_ack *extack) +{ +struct ice_dpll_pin *p = pin_priv, *parent = parent_pin_priv; +struct ice_pf *pf = p->pf; +u32 hw_idx; +int ret; + + ret =ice_dpll_cb_lock (pf, extack); +if (ret) +return ret; + hw_idx = parent->idx - pf->dplls.base_rclk_idx; +if (hw_idx >= pf->dplls.num_inputs) + goto unlock; + + ret =ice_dpll_pin_state_update (pf, p,ICE_DPLL_PIN_TYPE_RCLK_INPUT , + extack); +if (ret) + goto unlock; + + *state = p->state[hw_idx]; + ret =0 ; +unlock: +ice_dpll_cb_unlock (pf); + +return ret; +} + +static const struct dpll_pin_ops ice_dpll_rclk_ops = { + .state_on_pin_set = ice_dpll_rclk_state_on_pin_set, + .state_on_pin_get = ice_dpll_rclk_state_on_pin_get, + .direction_get = ice_dpll_input_direction, +}; + +static const struct dpll_pin_ops ice_dpll_input_ops = { + .frequency_get = ice_dpll_input_frequency_get, + .frequency_set = ice_dpll_input_frequency_set, + .state_on_dpll_get = ice_dpll_input_state_get, + .state_on_dpll_set = ice_dpll_input_state_set, + .prio_get = ice_dpll_input_prio_get, + .prio_set = ice_dpll_input_prio_set, + .direction_get = ice_dpll_input_direction, +}; + +static const struct dpll_pin_ops ice_dpll_output_ops = { + .frequency_get = ice_dpll_output_frequency_get, + .frequency_set = ice_dpll_output_frequency_set, + .state_on_dpll_get = ice_dpll_output_state_get, + .state_on_dpll_set = ice_dpll_output_state_set, + .direction_get = ice_dpll_output_direction, +}; + +static const struct dpll_device_ops ice_dpll_ops = { + .lock_status_get = ice_dpll_lock_status_get, + .mode_supported = ice_dpll_mode_supported, + .mode_get = ice_dpll_mode_get, + .mode_set = ice_dpll_mode_set, +}; + +/** +* ice_generate_clock_id - generates unique clock_id for registering dpll. +* @pf: board private structure +* +* Generates unique (per board) clock_id for allocation and search of dpll +* devices in Linux dpll subsystem. +* +* Return: generated clock id for the board +*/ +static u64 ice_generate_clock_id (struct ice_pf *pf) +{ +return pci_get_dsn (pf->pdev); +} + +/** +* ice_dpll_notify_changes - notify dpll subsystem about changes +* @d: pointer do dpll +* +* Once change detected appropriate event is submitted to the dpll subsystem. +*/ +static void ice_dpll_notify_changes (struct ice_dpll *d) +{ +if (d->prev_dpll_state != d->dpll_state) { + d->prev_dpll_state = d->dpll_state; +dpll_device_change_ntf (d->dpll); + } +if (d->prev_input != d->active_input) { +if (d->prev_input) +dpll_pin_change_ntf (d->prev_input); + d->prev_input = d->active_input; +if (d->active_input) +dpll_pin_change_ntf (d->active_input); + } +} + +/** +* ice_dpll_update_state - update dpll state +* @pf: pf private structure +* @d: pointer to queried dpll device +* @init: if function called on initialization of ice dpll +* +* Poll current state of dpll from hw and update ice_dpll struct. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - AQ failure +*/ +static int +ice_dpll_update_state (struct ice_pf *pf,struct ice_dpll *d,bool init) +{ +struct ice_dpll_pin *p =NULL ; +int ret; + + ret =ice_get_cgu_state (&pf->hw, d->dpll_idx, d->prev_dpll_state, + &d->input_idx, &d->ref_state, &d->eec_mode, + &d->phase_shift, &d->dpll_state, &d->mode); + +dev_dbg (ice_pf_to_dev (pf), +"update dpll=%d, prev_src_idx:%u, src_idx:%u, state:%d, prev:%d mode:%d\n" , + d->dpll_idx, d->prev_input_idx, d->input_idx, + d->dpll_state, d->prev_dpll_state, d->mode); +if (ret) { +dev_err (ice_pf_to_dev (pf), +"update dpll=%d state failed, ret=%d %s\n" , + d->dpll_idx, ret, +ice_aq_str (pf->hw.adminq.sq_last_status)); +return ret; + } +if (init) { +if (d->dpll_state ==DPLL_LOCK_STATUS_LOCKED && + d->dpll_state ==DPLL_LOCK_STATUS_LOCKED_HO_ACQ ) + d->active_input = pf->dplls.inputs[d->input_idx].pin; + p = &pf->dplls.inputs[d->input_idx]; +return ice_dpll_pin_state_update (pf, p, +ICE_DPLL_PIN_TYPE_INPUT ,NULL ); + } +if (d->dpll_state ==DPLL_LOCK_STATUS_HOLDOVER || + d->dpll_state ==DPLL_LOCK_STATUS_UNLOCKED ) { + d->active_input =NULL ; +if (d->input_idx !=ICE_DPLL_PIN_IDX_INVALID ) + p = &pf->dplls.inputs[d->input_idx]; + d->prev_input_idx =ICE_DPLL_PIN_IDX_INVALID ; + d->input_idx =ICE_DPLL_PIN_IDX_INVALID ; +if (!p) +return 0 ; + ret =ice_dpll_pin_state_update (pf, p, +ICE_DPLL_PIN_TYPE_INPUT ,NULL ); + }else if (d->input_idx != d->prev_input_idx) { +if (d->prev_input_idx !=ICE_DPLL_PIN_IDX_INVALID ) { + p = &pf->dplls.inputs[d->prev_input_idx]; +ice_dpll_pin_state_update (pf, p, +ICE_DPLL_PIN_TYPE_INPUT , +NULL ); + } +if (d->input_idx !=ICE_DPLL_PIN_IDX_INVALID ) { + p = &pf->dplls.inputs[d->input_idx]; + d->active_input = p->pin; +ice_dpll_pin_state_update (pf, p, +ICE_DPLL_PIN_TYPE_INPUT , +NULL ); + } + d->prev_input_idx = d->input_idx; + } + +return ret; +} + +/** +* ice_dpll_periodic_work - DPLLs periodic worker +* @work: pointer to kthread_work structure +* +* DPLLs periodic worker is responsible for polling state of dpll. +* Context: Holds pf->dplls.lock +*/ +static void ice_dpll_periodic_work (struct kthread_work *work) +{ + struct ice_dplls *d = container_of(work, struct ice_dplls, work.work); + struct ice_pf *pf = container_of(d, struct ice_pf, dplls); +struct ice_dpll *de = &pf->dplls.eec; +struct ice_dpll *dp = &pf->dplls.pps; +int ret; + + ret =ice_dpll_cb_lock (pf,NULL ); +if (ret == -EBUSY ) + goto resched; +else if (ret) +return ; + ret =ice_dpll_update_state (pf, de, false); +if (!ret) + ret =ice_dpll_update_state (pf, dp, false); +if (ret) { + d->cgu_state_acq_err_num++; +/* stop rescheduling this worker */ +if (d->cgu_state_acq_err_num > +ICE_CGU_STATE_ACQ_ERR_THRESHOLD ) { +dev_err (ice_pf_to_dev (pf), +"EEC/PPS DPLLs periodic work disabled\n" ); +return ; + } + } +ice_dpll_cb_unlock (pf); +ice_dpll_notify_changes (de); +ice_dpll_notify_changes (dp); + +resched: +/* Run twice a second or reschedule if update failed */ +kthread_queue_delayed_work (d->kworker, &d->work, + ret ?msecs_to_jiffies (10 ) : +msecs_to_jiffies (500 ));
drivers/net/ethernet/intel/ice/ice_dpll.c line 1294
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+} + +/** +* ice_dpll_release_pins - release pins resources from dpll subsystem +* @pins: pointer to pins array +* @count: number of pins +* +* Release resources of given pins array in the dpll subsystem. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +11
-0+*/ +static void ice_dpll_release_pins (struct ice_dpll_pin *pins,int count) +{ +int i; + +for (i =0 ; i < count; i++) +dpll_pin_put (pins[i].pin); +} + +/** +* ice_dpll_get_pins - get pins from dpll subsystem
drivers/net/ethernet/intel/ice/ice_dpll.c line 1315
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+* @pf: board private structure +* @pins: pointer to pins array +* @start_idx: get starts from this pin idx value +* @count: number of pins +* @clock_id: clock_id of dpll device +* +* Get pins - allocate - in dpll subsystem, store them in pin field of given +* pins array. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 28 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +28
-0+* Return: +* * 0 - success +* * negative - allocation failure reason +*/ +static int +ice_dpll_get_pins (struct ice_pf *pf,struct ice_dpll_pin *pins, +int start_idx,int count,u64 clock_id) +{ +int i, ret; + +for (i =0 ; i < count; i++) { + pins[i].pin =dpll_pin_get (clock_id, i + start_idx,THIS_MODULE , + &pins[i].prop); +if (IS_ERR (pins[i].pin)) { + ret =PTR_ERR (pins[i].pin); + goto release_pins; + } + } + +return 0 ; + +release_pins: +while (--i >=0 ) +dpll_pin_put (pins[i].pin); +return ret; +} + +/**
drivers/net/ethernet/intel/ice/ice_dpll.c line 1353
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+* ice_dpll_unregister_pins - unregister pins from a dpll +* @dpll: dpll device pointer +* @pins: pointer to pins array +* @ops: callback ops registered with the pins +* @count: number of pins +* +* Unregister pins of a given array of pins from given dpll device registered in +* dpll subsystem. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +11
-0+*/ +static void +ice_dpll_unregister_pins (struct dpll_device *dpll,struct ice_dpll_pin *pins, +const struct dpll_pin_ops *ops,int count) +{ +int i; + +for (i =0 ; i < count; i++) +dpll_pin_unregister (dpll, pins[i].pin, ops, &pins[i]); +} +
drivers/net/ethernet/intel/ice/ice_dpll.c line 1374
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+/** +* ice_dpll_register_pins - register pins with a dpll +* @dpll: dpll pointer to register pins with +* @pins: pointer to pins array +* @ops: callback ops registered with the pins +* @count: number of pins +* +* Register pins of a given array with given dpll in dpll subsystem. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 24 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +24
-0+* Return: +* * 0 - success +* * negative - registration failure reason +*/ +static int +ice_dpll_register_pins (struct dpll_device *dpll,struct ice_dpll_pin *pins, +const struct dpll_pin_ops *ops,int count) +{ +int ret, i; + +for (i =0 ; i < count; i++) { + ret =dpll_pin_register (dpll, pins[i].pin, ops, &pins[i]); +if (ret) + goto unregister_pins; + } + +return 0 ; + +unregister_pins: +while (--i >=0 ) +dpll_pin_unregister (dpll, pins[i].pin, ops, &pins[i]); +return ret; +} +
drivers/net/ethernet/intel/ice/ice_dpll.c line 1408
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+/** +* ice_dpll_deinit_direct_pins - deinitialize direct pins +* @cgu: if cgu is present and controlled by this NIC +* @pins: pointer to pins array +* @count: number of pins +* @ops: callback ops registered with the pins +* @first: dpll device pointer +* @second: dpll device pointer +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 21 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +21
-0+* If cgu is owned unregister pins from given dplls. +* Release pins resources to the dpll subsystem. +*/ +static void +ice_dpll_deinit_direct_pins (bool cgu,struct ice_dpll_pin *pins,int count, +const struct dpll_pin_ops *ops, +struct dpll_device *first, +struct dpll_device *second) +{ +if (cgu) { +ice_dpll_unregister_pins (first, pins, ops, count); +ice_dpll_unregister_pins (second, pins, ops, count); + } +ice_dpll_release_pins (pins, count); +} + +/** +* ice_dpll_init_direct_pins - initialize direct pins +* @pf: board private structure +* @cgu: if cgu is present and controlled by this NIC +* @pins: pointer to pins array
drivers/net/ethernet/intel/ice/ice_dpll.c line 1439
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+* @start_idx: on which index shall allocation start in dpll subsystem +* @count: number of pins +* @ops: callback ops registered with the pins +* @first: dpll device pointer +* @second: dpll device pointer +* +* Allocate directly connected pins of a given array in dpll subsystem. +* If cgu is owned register allocated pins with given dplls. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 30 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +30
-0+* Return: +* * 0 - success +* * negative - registration failure reason +*/ +static int +ice_dpll_init_direct_pins (struct ice_pf *pf,bool cgu, +struct ice_dpll_pin *pins,int start_idx,int count, +const struct dpll_pin_ops *ops, +struct dpll_device *first,struct dpll_device *second) +{ +int ret; + + ret =ice_dpll_get_pins (pf, pins, start_idx, count, pf->dplls.clock_id); +if (ret) +return ret; +if (cgu) { + ret =ice_dpll_register_pins (first, pins, ops, count); +if (ret) + goto release_pins; + ret =ice_dpll_register_pins (second, pins, ops, count); +if (ret) + goto unregister_first; + } + +return 0 ; + +unregister_first: +ice_dpll_unregister_pins (first, pins, ops, count); +release_pins: +ice_dpll_release_pins (pins, count);
drivers/net/ethernet/intel/ice/ice_dpll.c line 1479
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+return ret; +} + +/** +* ice_dpll_deinit_rclk_pin - release rclk pin resources +* @pf: board private structure +* +* Deregister rclk pin from parent pins and release resources in dpll subsystem. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 23 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +23
-0+*/ +static void ice_dpll_deinit_rclk_pin (struct ice_pf *pf) +{ +struct ice_dpll_pin *rclk = &pf->dplls.rclk; +struct ice_vsi *vsi =ice_get_main_vsi (pf); +struct dpll_pin *parent; +int i; + +for (i =0 ; i < rclk->num_parents; i++) { + parent = pf->dplls.inputs[rclk->parent_idx[i]].pin; +if (!parent) +continue ; +dpll_pin_on_pin_unregister (parent, rclk->pin, + &ice_dpll_rclk_ops, rclk); + } +if (WARN_ON_ONCE (!vsi || !vsi->netdev)) +return ; +netdev_dpll_pin_clear (vsi->netdev); +dpll_pin_put (rclk->pin); +} + +/** +* ice_dpll_init_rclk_pins - initialize recovered clock pin
drivers/net/ethernet/intel/ice/ice_dpll.c line 1512
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+* @pf: board private structure +* @pin: pin to register +* @start_idx: on which index shall allocation start in dpll subsystem +* @ops: callback ops registered with the pins +* +* Allocate resource for recovered clock pin in dpll subsystem. Register the +* pin with the parents it has in the info. Register pin with the pf's main vsi +* netdev. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 42 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +42
-0+* Return: +* * 0 - success +* * negative - registration failure reason +*/ +static int +ice_dpll_init_rclk_pins (struct ice_pf *pf,struct ice_dpll_pin *pin, +int start_idx,const struct dpll_pin_ops *ops) +{ +struct ice_vsi *vsi =ice_get_main_vsi (pf); +struct dpll_pin *parent; +int ret, i; + + ret =ice_dpll_get_pins (pf, pin, start_idx,ICE_DPLL_RCLK_NUM_PER_PF , + pf->dplls.clock_id); +if (ret) +return ret; +for (i =0 ; i < pf->dplls.rclk.num_parents; i++) { + parent = pf->dplls.inputs[pf->dplls.rclk.parent_idx[i]].pin; +if (!parent) { + ret = -ENODEV ; + goto unregister_pins; + } + ret =dpll_pin_on_pin_register (parent, pf->dplls.rclk.pin, + ops, &pf->dplls.rclk); +if (ret) + goto unregister_pins; + } +if (WARN_ON ((!vsi || !vsi->netdev))) +return -EINVAL ; +netdev_dpll_pin_set (vsi->netdev, pf->dplls.rclk.pin); + +return 0 ; + +unregister_pins: +while (i) { + parent = pf->dplls.inputs[pf->dplls.rclk.parent_idx[--i]].pin; +dpll_pin_on_pin_unregister (parent, pf->dplls.rclk.pin, + &ice_dpll_rclk_ops, &pf->dplls.rclk); + } +ice_dpll_release_pins (pin,ICE_DPLL_RCLK_NUM_PER_PF ); +return ret; +}
drivers/net/ethernet/intel/ice/ice_dpll.c line 1564
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ +/** +* ice_dpll_deinit_pins - deinitialize direct pins +* @pf: board private structure +* @cgu: if cgu is controlled by this pf +* +* If cgu is owned unregister directly connected pins from the dplls. +* Release resources of directly connected pins from the dpll subsystem. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +27
-0+*/ +static void ice_dpll_deinit_pins (struct ice_pf *pf,bool cgu) +{ +struct ice_dpll_pin *outputs = pf->dplls.outputs; +struct ice_dpll_pin *inputs = pf->dplls.inputs; +int num_outputs = pf->dplls.num_outputs; +int num_inputs = pf->dplls.num_inputs; +struct ice_dplls *d = &pf->dplls; +struct ice_dpll *de = &d->eec; +struct ice_dpll *dp = &d->pps; + +ice_dpll_deinit_rclk_pin (pf); +if (cgu) { +ice_dpll_unregister_pins (dp->dpll, inputs, &ice_dpll_input_ops, + num_inputs); +ice_dpll_unregister_pins (de->dpll, inputs, &ice_dpll_input_ops, + num_inputs); + } +ice_dpll_release_pins (inputs, num_inputs); +if (cgu) { +ice_dpll_unregister_pins (dp->dpll, outputs, + &ice_dpll_output_ops, num_outputs); +ice_dpll_unregister_pins (de->dpll, outputs, + &ice_dpll_output_ops, num_outputs); +ice_dpll_release_pins (outputs, num_outputs); + } +}
drivers/net/ethernet/intel/ice/ice_dpll.c line 1601
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ +/** +* ice_dpll_init_pins - init pins and register pins with a dplls +* @pf: board private structure +* @cgu: if cgu is present and controlled by this NIC +* +* Initialize directly connected pf's pins within pf's dplls in a Linux dpll +* subsystem. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 44 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +44
-0+* Return: +* * 0 - success +* * negative - initialization failure reason +*/ +static int ice_dpll_init_pins (struct ice_pf *pf,bool cgu) +{ +u32 rclk_idx; +int ret; + + ret =ice_dpll_init_direct_pins (pf, cgu, pf->dplls.inputs,0 , + pf->dplls.num_inputs, + &ice_dpll_input_ops, + pf->dplls.eec.dpll, pf->dplls.pps.dpll); +if (ret) +return ret; +if (cgu) { + ret =ice_dpll_init_direct_pins (pf, cgu, pf->dplls.outputs, + pf->dplls.num_inputs, + pf->dplls.num_outputs, + &ice_dpll_output_ops, + pf->dplls.eec.dpll, + pf->dplls.pps.dpll); +if (ret) + goto deinit_inputs; + } + rclk_idx = pf->dplls.num_inputs + pf->dplls.num_outputs + pf->hw.pf_id; + ret =ice_dpll_init_rclk_pins (pf, &pf->dplls.rclk, rclk_idx, + &ice_dpll_rclk_ops); +if (ret) + goto deinit_outputs; + +return 0 ; +deinit_outputs: +ice_dpll_deinit_direct_pins (cgu, pf->dplls.outputs, + pf->dplls.num_outputs, + &ice_dpll_output_ops, pf->dplls.pps.dpll, + pf->dplls.eec.dpll); +deinit_inputs: +ice_dpll_deinit_direct_pins (cgu, pf->dplls.inputs, pf->dplls.num_inputs, + &ice_dpll_input_ops, pf->dplls.pps.dpll, + pf->dplls.eec.dpll); +return ret; +} +
drivers/net/ethernet/intel/ice/ice_dpll.c line 1655
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+/** +* ice_dpll_deinit_dpll - deinitialize dpll device +* @pf: board private structure +* @d: pointer to ice_dpll +* @cgu: if cgu is present and controlled by this NIC +* +* If cgu is owned unregister the dpll from dpll subsystem. +* Release resources of dpll device from dpll subsystem. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+*/ +static void +ice_dpll_deinit_dpll (struct ice_pf *pf,struct ice_dpll *d,bool cgu) +{ +if (cgu) +dpll_device_unregister (d->dpll, &ice_dpll_ops, d); +dpll_device_put (d->dpll); +} + +/**
drivers/net/ethernet/intel/ice/ice_dpll.c line 1675
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+* ice_dpll_init_dpll - initialize dpll device in dpll subsystem +* @pf: board private structure +* @d: dpll to be initialized +* @cgu: if cgu is present and controlled by this NIC +* @type: type of dpll being initialized +* +* Allocate dpll instance for this board in dpll subsystem, if cgu is controlled +* by this NIC, register dpll with the callback ops. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +27
-0+* Return: +* * 0 - success +* * negative - initialization failure reason +*/ +static int +ice_dpll_init_dpll (struct ice_pf *pf,struct ice_dpll *d,bool cgu, +enum dpll_type type) +{ +u64 clock_id = pf->dplls.clock_id; +int ret; + + d->dpll =dpll_device_get (clock_id, d->dpll_idx,THIS_MODULE ); +if (IS_ERR (d->dpll)) { + ret =PTR_ERR (d->dpll); +dev_err (ice_pf_to_dev (pf), +"dpll_device_get failed (%p) err=%d\n" , d, ret); +return ret; + } + d->pf = pf; +if (cgu) { + ret =dpll_device_register (d->dpll, type, &ice_dpll_ops, d); +if (ret) { +dpll_device_put (d->dpll); +return ret; + } + } +
drivers/net/ethernet/intel/ice/ice_dpll.c line 1712
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+return 0 ; +} + +/** +* ice_dpll_deinit_worker - deinitialize dpll kworker +* @pf: board private structure +* +* Stop dpll's kworker, release it's resources. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +6
-0+*/ +static void ice_dpll_deinit_worker (struct ice_pf *pf) +{ +struct ice_dplls *d = &pf->dplls; + +kthread_cancel_delayed_work_sync (&d->work);
drivers/net/ethernet/intel/ice/ice_dpll.c line 1728
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+kthread_destroy_worker (d->kworker); +} + +/** +* ice_dpll_init_worker - Initialize DPLLs periodic worker +* @pf: board private structure +* +* Create and start DPLLs periodic worker. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 22 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +22
-0+* Return: +* * 0 - success +* * negative - create worker failure +*/ +static int ice_dpll_init_worker (struct ice_pf *pf) +{ +struct ice_dplls *d = &pf->dplls; +struct kthread_worker *kworker; + +ice_dpll_update_state (pf, &d->eec, true); +ice_dpll_update_state (pf, &d->pps, true); +kthread_init_delayed_work (&d->work, ice_dpll_periodic_work); + kworker =kthread_create_worker (0 ,"ice-dplls-%s" , +dev_name (ice_pf_to_dev (pf))); +if (IS_ERR (kworker)) +return PTR_ERR (kworker); + d->kworker = kworker; + d->cgu_state_acq_err_num =0 ; +kthread_queue_delayed_work (d->kworker, &d->work,0 ); + +return 0 ; +}
drivers/net/ethernet/intel/ice/ice_dpll.c line 1760
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ +/** +* ice_dpll_init_info_direct_pins - initializes direct pins info +* @pf: board private structure +* @pin_type: type of pins being initialized +* +* Init information for directly connected pins, cache them in pf's pins +* structures. +* +* Context: Called under pf->dplls.lock.
No, it is not.
Quoted 103 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +103
-0+* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int +ice_dpll_init_info_direct_pins (struct ice_pf *pf, +enum ice_dpll_pin_type pin_type) +{ +struct ice_dpll *de = &pf->dplls.eec, *dp = &pf->dplls.pps; +struct ice_hw *hw = &pf->hw; +struct ice_dpll_pin *pins; +int num_pins, i, ret; +u8 freq_supp_num; +bool input; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + pins = pf->dplls.inputs; + num_pins = pf->dplls.num_inputs; + input = true; +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + pins = pf->dplls.outputs; + num_pins = pf->dplls.num_outputs; + input = false; +break ; +default : +return -EINVAL ; + } + +for (i =0 ; i < num_pins; i++) { + pins[i].idx = i; + pins[i].prop.board_label =ice_cgu_get_pin_name (hw, i, input); + pins[i].prop.type =ice_cgu_get_pin_type (hw, i, input); +if (input) { + ret =ice_aq_get_cgu_ref_prio (hw, de->dpll_idx, i, + &de->input_prio[i]); +if (ret) +return ret; + ret =ice_aq_get_cgu_ref_prio (hw, dp->dpll_idx, i, + &dp->input_prio[i]); +if (ret) +return ret; + pins[i].prop.capabilities |= +DPLL_PIN_CAPS_PRIORITY_CAN_CHANGE ; + } + pins[i].prop.capabilities |=DPLL_PIN_CAPS_STATE_CAN_CHANGE ; + ret =ice_dpll_pin_state_update (pf, &pins[i], pin_type,NULL ); +if (ret) +return ret; + pins[i].prop.freq_supported = +ice_cgu_get_pin_freq_supp (hw, i, input, &freq_supp_num); + pins[i].prop.freq_supported_num = freq_supp_num; + pins[i].pf = pf; + } + +return ret; +} + +/** +* ice_dpll_init_info_rclk_pin - initializes rclk pin information +* @pf: board private structure +* +* Init information for rclk pin, cache them in pf->dplls.rclk. +* +* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int ice_dpll_init_info_rclk_pin (struct ice_pf *pf) +{ +struct ice_dpll_pin *pin = &pf->dplls.rclk; + + pin->prop.type =DPLL_PIN_TYPE_SYNCE_ETH_PORT ; + pin->prop.capabilities |=DPLL_PIN_CAPS_STATE_CAN_CHANGE ; + pin->pf = pf; + +return ice_dpll_pin_state_update (pf, pin, +ICE_DPLL_PIN_TYPE_RCLK_INPUT ,NULL ); +} + +/** +* ice_dpll_init_pins_info - init pins info wrapper +* @pf: board private structure +* @pin_type: type of pins being initialized +* +* Wraps functions for pin initialization. +* +* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int +ice_dpll_init_pins_info (struct ice_pf *pf,enum ice_dpll_pin_type pin_type) +{ +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : +case ICE_DPLL_PIN_TYPE_OUTPUT : +return ice_dpll_init_info_direct_pins (pf, pin_type); +case ICE_DPLL_PIN_TYPE_RCLK_INPUT : +return ice_dpll_init_info_rclk_pin (pf); +default : +return -EINVAL ;
drivers/net/ethernet/intel/ice/ice_dpll.c line 1873
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ } +} + +/** +* ice_dpll_deinit_info - release memory allocated for pins info +* @pf: board private structure +* +* Release memory allocated for pins by ice_dpll_init_info function. +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +7
-0+*/ +static void ice_dpll_deinit_info (struct ice_pf *pf) +{ +kfree (pf->dplls.inputs); +kfree (pf->dplls.outputs); +kfree (pf->dplls.eec.input_prio); +kfree (pf->dplls.pps.input_prio);
drivers/net/ethernet/intel/ice/ice_dpll.c line 1890
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+} + +/** +* ice_dpll_init_info - prepare pf's dpll information structure +* @pf: board private structure +* @cgu: if cgu is present and controlled by this NIC +* +* Acquire (from HW) and set basic dpll information (on pf->dplls struct). +* +* Context: Called under pf->dplls.lock
No, it is not.
Quoted 84 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +84
-0+* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int ice_dpll_init_info (struct ice_pf *pf,bool cgu) +{ +struct ice_aqc_get_cgu_abilities abilities; +struct ice_dpll *de = &pf->dplls.eec; +struct ice_dpll *dp = &pf->dplls.pps; +struct ice_dplls *d = &pf->dplls; +struct ice_hw *hw = &pf->hw; +int ret, alloc_size, i; + + d->clock_id =ice_generate_clock_id (pf); + ret =ice_aq_get_cgu_abilities (hw, &abilities); +if (ret) { +dev_err (ice_pf_to_dev (pf), +"err:%d %s failed to read cgu abilities\n" , + ret,ice_aq_str (hw->adminq.sq_last_status)); +return ret; + } + + de->dpll_idx = abilities.eec_dpll_idx; + dp->dpll_idx = abilities.pps_dpll_idx; + d->num_inputs = abilities.num_inputs; + d->num_outputs = abilities.num_outputs; + d->input_phase_adj_max =le32_to_cpu (abilities.max_in_phase_adj); + d->output_phase_adj_max =le32_to_cpu (abilities.max_out_phase_adj); + + alloc_size =sizeof (*d->inputs) * d->num_inputs; + d->inputs =kzalloc (alloc_size,GFP_KERNEL ); +if (!d->inputs) +return -ENOMEM ; + + alloc_size =sizeof (*de->input_prio) * d->num_inputs; + de->input_prio =kzalloc (alloc_size,GFP_KERNEL ); +if (!de->input_prio) +return -ENOMEM ; + + dp->input_prio =kzalloc (alloc_size,GFP_KERNEL ); +if (!dp->input_prio) +return -ENOMEM ; + + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_INPUT ); +if (ret) + goto deinit_info; + +if (cgu) { + alloc_size =sizeof (*d->outputs) * d->num_outputs; + d->outputs =kzalloc (alloc_size,GFP_KERNEL ); +if (!d->outputs) + goto deinit_info; + + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_OUTPUT ); +if (ret) + goto deinit_info; + } + + ret =ice_get_cgu_rclk_pin_info (&pf->hw, &d->base_rclk_idx, + &pf->dplls.rclk.num_parents); +if (ret) +return ret; +for (i =0 ; i < pf->dplls.rclk.num_parents; i++) + pf->dplls.rclk.parent_idx[i] = d->base_rclk_idx + i; + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_RCLK_INPUT ); +if (ret) +return ret; + de->mode =DPLL_MODE_AUTOMATIC ; + dp->mode =DPLL_MODE_AUTOMATIC ; + +dev_dbg (ice_pf_to_dev (pf), +"%s - success, inputs:%u, outputs:%u rclk-parents:%u\n" , + __func__, d->num_inputs, d->num_outputs, d->rclk.num_parents); + +return 0 ; + +deinit_info: +dev_err (ice_pf_to_dev (pf), +"%s - fail: d->inputs:%p, de->input_prio:%p, dp->input_prio:%p, d->outputs:%p\n" , + __func__, d->inputs, de->input_prio, + dp->input_prio, d->outputs); +ice_dpll_deinit_info (pf); +return ret; +}
drivers/net/ethernet/intel/ice/ice_dpll.c line 1984
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ +/** +* ice_dpll_deinit - Disable the driver/HW support for dpll subsystem +* the dpll device. +* @pf: board private structure +* +* Handles the cleanup work required after dpll initialization,freeing resources +* and unregistering the dpll, pin and all resources used for handling them. +* +* Context: Function holds pf->dplls.lock mutex.
No it does not. Update your comments. Or better, remove them, they are totally useless anyway :/
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +5
-0+*/ +void ice_dpll_deinit (struct ice_pf *pf) +{ +bool cgu =ice_is_feature_supported (pf,ICE_F_CGU ); +
drivers/net/ethernet/intel/ice/ice_dpll.c line 1999
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+if (!test_bit (ICE_FLAG_DPLL , pf->flags)) +return ; +clear_bit (ICE_FLAG_DPLL , pf->flags); + +ice_dpll_deinit_pins (pf, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.pps, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.eec, cgu); +ice_dpll_deinit_info (pf); +if (cgu) +ice_dpll_deinit_worker (pf);
Could you please order the ice_dpll_deinit() to be symmetrical to ice_dpll_init()? Then, you can drop ICE_FLAG_DPLL flag entirely, as the ice_dpll_periodic_work() function is the only reason why you need it currently.
drivers/net/ethernet/intel/ice/ice_dpll.c line 2011
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +12
-0+mutex_destroy (&pf->dplls.lock); +} + +/** +* ice_dpll_init - initialize support for dpll subsystem +* @pf: board private structure +* +* Set up the device dplls, register them and pins connected within Linux dpll +* subsystem. Allow userpsace to obtain state of DPLL and handling of DPLL +* configuration requests. +* +* Context: Function initializes and holds pf->dplls.lock mutex.
No, it does not hold it.
Quoted 29 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +29
-0+*/ +void ice_dpll_init (struct ice_pf *pf) +{ +bool cgu =ice_is_feature_supported (pf,ICE_F_CGU ); +struct ice_dplls *d = &pf->dplls; +int err =0 ; + + err =ice_dpll_init_info (pf, cgu); +if (err) + goto err_exit; + err =ice_dpll_init_dpll (pf, &pf->dplls.eec, cgu,DPLL_TYPE_EEC ); +if (err) + goto deinit_info; + err =ice_dpll_init_dpll (pf, &pf->dplls.pps, cgu,DPLL_TYPE_PPS ); +if (err) + goto deinit_eec; + err =ice_dpll_init_pins (pf, cgu); +if (err) + goto deinit_pps; +set_bit (ICE_FLAG_DPLL , pf->flags); +if (cgu) { + err =ice_dpll_init_worker (pf); +if (err) + goto deinit_pins; + } + +return ; + +deinit_pins:
drivers/net/ethernet/intel/ice/ice_dpll.c line 2050
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ice_dpll_deinit_pins (pf, cgu); +deinit_pps: +ice_dpll_deinit_dpll (pf, &pf->dplls.pps, cgu); +deinit_eec: +ice_dpll_deinit_dpll (pf, &pf->dplls.eec, cgu); +deinit_info: +ice_dpll_deinit_info (pf); +err_exit: +clear_bit (ICE_FLAG_DPLL , pf->flags); +mutex_unlock (&d->lock);
Leftover, please remove.
Quoted 141 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+mutex_destroy (&d->lock); +dev_warn (ice_pf_to_dev (pf),"DPLLs init failure err:%d\n" , err); +}drivers/net/ethernet/intel/ice/ice_dpll.h new file +104
-0@@ -0,0 +1,104 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2022, Intel Corporation. */ + +#ifndef _ICE_DPLL_H_ +#define _ICE_DPLL_H_ + +#include "ice.h" + +#define ICE_DPLL_PRIO_MAX 0xF +#define ICE_DPLL_RCLK_NUM_MAX 4 + +/** ice_dpll_pin - store info about pins +* @pin: dpll pin structure +* @pf: pointer to pf, which has registered the dpll_pin +* @idx: ice pin private idx +* @num_parents: hols number of parent pins +* @parent_idx: hold indexes of parent pins +* @flags: pin flags returned from HW +* @state: state of a pin +* @prop: pin properities +* @freq: current frequency of a pin +*/ +struct ice_dpll_pin { +struct dpll_pin *pin; +struct ice_pf *pf; +u8 idx; +u8 num_parents; +u8 parent_idx[ICE_DPLL_RCLK_NUM_MAX ]; +u8 flags[ICE_DPLL_RCLK_NUM_MAX ]; +u8 state[ICE_DPLL_RCLK_NUM_MAX ]; +struct dpll_pin_properties prop; +u32 freq; +}; + +/** ice_dpll - store info required for DPLL control +* @dpll: pointer to dpll dev +* @pf: pointer to pf, which has registered the dpll_device +* @dpll_idx: index of dpll on the NIC +* @input_idx: currently selected input index +* @prev_input_idx: previously selected input index +* @ref_state: state of dpll reference signals +* @eec_mode: eec_mode dpll is configured for +* @phase_shift: phase shift delay of a dpll +* @input_prio: priorities of each input +* @dpll_state: current dpll sync state +* @prev_dpll_state: last dpll sync state +* @active_input: pointer to active input pin +* @prev_input: pointer to previous active input pin +*/ +struct ice_dpll { +struct dpll_device *dpll; +struct ice_pf *pf; +u8 dpll_idx; +u8 input_idx; +u8 prev_input_idx; +u8 ref_state; +u8 eec_mode; +s64 phase_shift; +u8 *input_prio; +enum dpll_lock_status dpll_state; +enum dpll_lock_status prev_dpll_state; +enum dpll_mode mode; +struct dpll_pin *active_input; +struct dpll_pin *prev_input; +}; + +/** ice_dplls - store info required for CCU (clock controlling unit) +* @kworker: periodic worker +* @work: periodic work +* @lock: locks access to configuration of a dpll +* @eec: pointer to EEC dpll dev +* @pps: pointer to PPS dpll dev +* @inputs: input pins pointer +* @outputs: output pins pointer +* @rclk: recovered pins pointer +* @num_inputs: number of input pins available on dpll +* @num_outputs: number of output pins available on dpll +* @cgu_state_acq_err_num: number of errors returned during periodic work +* @base_rclk_idx: idx of first pin used for clock revocery pins +* @clock_id: clock_id of dplls +*/ +struct ice_dplls { +struct kthread_worker *kworker; +struct kthread_delayed_work work; +struct mutex lock; +struct ice_dpll eec; +struct ice_dpll pps; +struct ice_dpll_pin *inputs; +struct ice_dpll_pin *outputs; +struct ice_dpll_pin rclk; +u8 num_inputs; +u8 num_outputs; +int cgu_state_acq_err_num; +u8 base_rclk_idx; +u64 clock_id; +s32 input_phase_adj_max; +s32 output_phase_adj_max; +}; + +void ice_dpll_init (struct ice_pf *pf); + +void ice_dpll_deinit (struct ice_pf *pf); + +#endif drivers/net/ethernet/intel/ice/ice_main.c +7
-0@@ -4613,6 +4613,10 @@ static void ice_init_features(struct ice_pf *pf)if (ice_is_feature_supported (pf,ICE_F_GNSS ))ice_gnss_init (pf); +if (ice_is_feature_supported (pf,ICE_F_CGU ) || +ice_is_feature_supported (pf,ICE_F_PHY_RCLK )) +ice_dpll_init (pf); +/* Note: Flow director init failure is non-fatal to load */ if (ice_init_fdir (pf))dev_err (dev,"could not initialize flow director\n" );@@ -4639,6 +4643,9 @@ static void ice_deinit_features(struct ice_pf *pf)ice_gnss_exit (pf);if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags))ice_ptp_release (pf); +if (ice_is_feature_supported (pf,ICE_F_PHY_RCLK ) || +ice_is_feature_supported (pf,ICE_F_CGU )) +ice_dpll_deinit (pf); }static void ice_init_wakeup (struct ice_pf *pf)Signature · 1 line
2.27.0
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 5 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 1:39 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +8
-0+ +/** +* ice_dpll_cb_lock - lock dplls mutex in callback context +* @pf: private board structure +* @extack: error reporting +* +* Lock the mutex from the callback operations invoked by dpll subsystem. +* Prevent dead lock caused by `rmmod ice` when dpll callbacks are under stress
Quoted 1 line
+ * tests.
Quoted 8 lines
I don't know, I will probably need to beg you here. Why exactly are you ignoring my comments? It's not nice, I thought we are way past it...
There is no "dead lock". Could you please describe how exactly the case you mention can happen? It can't.
Could you please remove the trylock iteration below? It's completely pointless.
Yep, dead lock cannot happen now, will fix docs.
Will remove trylock.
Quoted 18 lines
Quoted 9 lines
+ *
+ * Return:
+ * 0 - if lock acquired
+ * negative - lock not acquired or dpll is not initialized
+ */
+static intice_dpll_cb_lock(struct ice_pf *pf, struct netlink_ext_ack *extack)drivers/net/ethernet/intel/ice/ice_dpll.c line 52
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +5
-0+{ +int i; + +for (i =0 ; i <ICE_DPLL_LOCK_TRIES ; i++) { +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) {And again, as I already told you, this flag checking is totally pointless. See below my comment to ice_dpll_init()/ice_dpll_deinit().
This is not pointless, will explain below.
Quoted 2 lines
[...]
Quoted 11 lines
Quoted 8 lines
+/**
+ *ice_dpll_release_pins- release pins resources from dpll subsystem
+ * @pins: pointer to pins array
+ * @count: number of pins
+ *
+ * Release resources of given pins array in the dpll subsystem.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 17 lines
Quoted 17 lines
+ */
drivers/net/ethernet/intel/ice/ice_dpll.c new file +15
-0+static void ice_dpll_release_pins (struct ice_dpll_pin *pins,int count) +{ +int i; + +for (i =0 ; i < count; i++) +dpll_pin_put (pins[i].pin); +} + +/** +* ice_dpll_get_pins - get pins from dpll subsystem +* @pf: board private structure +* @pins: pointer to pins array +* @start_idx: get starts from this pin idx value +* @count: number of pins +* @clock_id: clock_id of dpll device
Quoted 9 lines
Quoted 6 lines
+ *
+ * Get pins - allocate - in dpll subsystem, store them in pin field of given
+ * pins array.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 35 lines
Quoted 35 lines
+ * Return:
+ * * 0 - success
+ * * negative - allocation failure reason
+ */drivers/net/ethernet/intel/ice/ice_dpll.c new file +8
-0+static int +ice_dpll_get_pins (struct ice_pf *pf,struct ice_dpll_pin *pins, +int start_idx,int count,u64 clock_id) +{ +int i, ret; + +for (i =0 ; i < count; i++) { + pins[i].pin = dpll_pin_get(clock_id, i + start_idx,
THIS_MODULE,drivers/net/ethernet/intel/ice/ice_dpll.c new file +21
-0+ &pins[i].prop); +if (IS_ERR (pins[i].pin)) { + ret =PTR_ERR (pins[i].pin); + goto release_pins; + } + } + +return 0 ; + +release_pins: +while (--i >=0 ) +dpll_pin_put (pins[i].pin); +return ret; +} + +/** +* ice_dpll_unregister_pins - unregister pins from a dpll +* @dpll: dpll device pointer +* @pins: pointer to pins array +* @ops: callback ops registered with the pins +* @count: number of pins
Quoted 9 lines
Quoted 6 lines
+ *
+ * Unregister pins of a given array of pins from given dpll device registered in
+ * dpll subsystem.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 17 lines
Quoted 17 lines
+ */
(quoted diff) +2
-0+static void +ice_dpll_unregister_pins(struct dpll_device *dpll, struct ice_dpll_pin*pins,
drivers/net/ethernet/intel/ice/ice_dpll.c new file +12
-0+ const struct dpll_pin_ops *ops, int count) +{ + int i; + +for (i =0 ; i < count; i++) +dpll_pin_unregister (dpll, pins[i].pin, ops, &pins[i]); +} + +/** +* ice_dpll_register_pins - register pins with a dpll +* @dpll: dpll pointer to register pins with +* @pins: pointer to pins array
Quoted 9 lines
Quoted 6 lines
+ * @ops: callback ops registered with the pins
+ * @count: number of pins
+ *
+ * Register pins of a given array with given dpll in dpll subsystem.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 30 lines
Quoted 30 lines
+ * Return:
+ * * 0 - success
+ * * negative - registration failure reason
+ */(quoted diff) +2
-0+static int +ice_dpll_register_pins(struct dpll_device *dpll, struct ice_dpll_pin*pins,
drivers/net/ethernet/intel/ice/ice_dpll.c new file +22
-0+ const struct dpll_pin_ops *ops, int count) +{ + int ret, i; + +for (i =0 ; i < count; i++) { + ret =dpll_pin_register (dpll, pins[i].pin, ops, &pins[i]); +if (ret) + goto unregister_pins; + } + +return 0 ; + +unregister_pins: +while (--i >=0 ) +dpll_pin_unregister (dpll, pins[i].pin, ops, &pins[i]); +return ret; +} + +/** +* ice_dpll_deinit_direct_pins - deinitialize direct pins +* @cgu: if cgu is present and controlled by this NIC +* @pins: pointer to pins array
Quoted 9 lines
Quoted 6 lines
+ * @count: number of pins
+ * @ops: callback ops registered with the pins
+ * @first: dpll device pointer
+ * @second: dpll device pointer
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 27 lines
Quoted 27 lines
+ * If cgu is owned unregister pins from given dplls.
+ * Release pins resources to the dpll subsystem.
+ */(quoted diff) +2
-0+static void +ice_dpll_deinit_direct_pins(bool cgu, struct ice_dpll_pin *pins, intcount,
drivers/net/ethernet/intel/ice/ice_dpll.c new file +20
-0+const struct dpll_pin_ops *ops, + struct dpll_device *first, + struct dpll_device *second) +{ + if (cgu) { +ice_dpll_unregister_pins (first ,pins ,ops ,count ); +ice_dpll_unregister_pins (second, pins, ops, count); + } +ice_dpll_release_pins (pins, count); +} + +/** +* ice_dpll_init_direct_pins - initialize direct pins +* @pf: board private structure +* @cgu: if cgu is present and controlled by this NIC +* @pins: pointer to pins array +* @start_idx: on which index shall allocation start in dpll subsystem +* @count: number of pins +* @ops: callback ops registered with the pins +* @first: dpll device pointer
Quoted 9 lines
Quoted 6 lines
+ * @second: dpll device pointer
+ *
+ * Allocate directly connected pins of a given array in dpll subsystem.
+ * If cgu is owned register allocated pins with given dplls.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 37 lines
Quoted 37 lines
+ * Return:
+ * * 0 - success
+ * * negative - registration failure reason
+ */drivers/net/ethernet/intel/ice/ice_dpll.c new file +9
-0+static int +ice_dpll_init_direct_pins (struct ice_pf *pf,bool cgu, +struct ice_dpll_pin *pins,int start_idx,int count, +const struct dpll_pin_ops *ops, +struct dpll_device *first,struct dpll_device *second) +{ +int ret; + + ret = ice_dpll_get_pins(pf, pins, start_idx, count, pf-dplls.clock_id);
drivers/net/ethernet/intel/ice/ice_dpll.c new file +22
-0+if (ret) +return ret; +if (cgu) { + ret =ice_dpll_register_pins (first, pins, ops, count); +if (ret) + goto release_pins; + ret =ice_dpll_register_pins (second, pins, ops, count); +if (ret) + goto unregister_first; + } + +return 0 ; + +unregister_first: +ice_dpll_unregister_pins (first, pins, ops, count); +release_pins: +ice_dpll_release_pins (pins, count); +return ret; +} + +/** +* ice_dpll_deinit_rclk_pin - release rclk pin resources
Quoted 9 lines
Quoted 6 lines
+ * @pf: board private structure
+ *
+ * Deregister rclk pin from parent pins and release resources in dpll subsystem.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 30 lines
Quoted 30 lines
+ */
drivers/net/ethernet/intel/ice/ice_dpll.c new file +28
-0+static void ice_dpll_deinit_rclk_pin (struct ice_pf *pf) +{ +struct ice_dpll_pin *rclk = &pf->dplls.rclk; +struct ice_vsi *vsi =ice_get_main_vsi (pf); +struct dpll_pin *parent; +int i; + +for (i =0 ; i < rclk->num_parents; i++) { + parent = pf->dplls.inputs[rclk->parent_idx[i]].pin; +if (!parent) +continue ; +dpll_pin_on_pin_unregister (parent, rclk->pin, + &ice_dpll_rclk_ops, rclk); + } +if (WARN_ON_ONCE (!vsi || !vsi->netdev)) +return ; +netdev_dpll_pin_clear (vsi->netdev); +dpll_pin_put (rclk->pin); +} + +/** +* ice_dpll_init_rclk_pins - initialize recovered clock pin +* @pf: board private structure +* @pin: pin to register +* @start_idx: on which index shall allocation start in dpll subsystem +* @ops: callback ops registered with the pins +* +* Allocate resource for recovered clock pin in dpll subsystem. Register
Quoted 9 lines
Quoted 6 lines
the
+ * pin with the parents it has in the info. Register pin with the pf's main vsi
+ * netdev.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 47 lines
Quoted 47 lines
+ * Return:
+ * * 0 - success
+ * * negative - registration failure reason
+ */drivers/net/ethernet/intel/ice/ice_dpll.c new file +42
-0+static int +ice_dpll_init_rclk_pins (struct ice_pf *pf,struct ice_dpll_pin *pin, +int start_idx,const struct dpll_pin_ops *ops) +{ +struct ice_vsi *vsi =ice_get_main_vsi (pf); +struct dpll_pin *parent; +int ret, i; + + ret =ice_dpll_get_pins (pf, pin, start_idx,ICE_DPLL_RCLK_NUM_PER_PF , + pf->dplls.clock_id); +if (ret) +return ret; +for (i =0 ; i < pf->dplls.rclk.num_parents; i++) { + parent = pf->dplls.inputs[pf->dplls.rclk.parent_idx[i]].pin; +if (!parent) { + ret = -ENODEV ; + goto unregister_pins; + } + ret =dpll_pin_on_pin_register (parent, pf->dplls.rclk.pin, + ops, &pf->dplls.rclk); +if (ret) + goto unregister_pins; + } +if (WARN_ON ((!vsi || !vsi->netdev))) +return -EINVAL ; +netdev_dpll_pin_set (vsi->netdev, pf->dplls.rclk.pin); + +return 0 ; + +unregister_pins: +while (i) { + parent = pf->dplls.inputs[pf->dplls.rclk.parent_idx[--i]].pin; +dpll_pin_on_pin_unregister (parent, pf->dplls.rclk.pin, + &ice_dpll_rclk_ops, &pf->dplls.rclk); + } +ice_dpll_release_pins (pin,ICE_DPLL_RCLK_NUM_PER_PF ); +return ret; +} + +/** +* ice_dpll_deinit_pins - deinitialize direct pins +* @pf: board private structure
Quoted 9 lines
Quoted 6 lines
+ * @cgu: if cgu is controlled by this pf
+ *
+ * If cgu is owned unregister directly connected pins from the dplls.
+ * Release resources of directly connected pins from the dpll subsystem.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 33 lines
Quoted 33 lines
+ */
drivers/net/ethernet/intel/ice/ice_dpll.c new file +31
-0+static void ice_dpll_deinit_pins (struct ice_pf *pf,bool cgu) +{ +struct ice_dpll_pin *outputs = pf->dplls.outputs; +struct ice_dpll_pin *inputs = pf->dplls.inputs; +int num_outputs = pf->dplls.num_outputs; +int num_inputs = pf->dplls.num_inputs; +struct ice_dplls *d = &pf->dplls; +struct ice_dpll *de = &d->eec; +struct ice_dpll *dp = &d->pps; + +ice_dpll_deinit_rclk_pin (pf); +if (cgu) { +ice_dpll_unregister_pins (dp->dpll, inputs, &ice_dpll_input_ops, + num_inputs); +ice_dpll_unregister_pins (de->dpll, inputs, &ice_dpll_input_ops, + num_inputs); + } +ice_dpll_release_pins (inputs, num_inputs); +if (cgu) { +ice_dpll_unregister_pins (dp->dpll, outputs, + &ice_dpll_output_ops, num_outputs); +ice_dpll_unregister_pins (de->dpll, outputs, + &ice_dpll_output_ops, num_outputs); +ice_dpll_release_pins (outputs, num_outputs); + } +} + +/** +* ice_dpll_init_pins - init pins and register pins with a dplls +* @pf: board private structure +* @cgu: if cgu is present and controlled by this NIC
Quoted 9 lines
Quoted 6 lines
+ *
+ * Initialize directly connected pf's pins within pf's dplls in a Linux dpll
+ * subsystem.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 51 lines
Quoted 51 lines
+ * Return:
+ * * 0 - success
+ * * negative - initialization failure reason
+ */drivers/net/ethernet/intel/ice/ice_dpll.c new file +22
-0+static int ice_dpll_init_pins (struct ice_pf *pf,bool cgu) +{ +u32 rclk_idx; +int ret; + + ret =ice_dpll_init_direct_pins (pf, cgu, pf->dplls.inputs,0 , + pf->dplls.num_inputs, + &ice_dpll_input_ops, + pf->dplls.eec.dpll, pf->dplls.pps.dpll); +if (ret) +return ret; +if (cgu) { + ret =ice_dpll_init_direct_pins (pf, cgu, pf->dplls.outputs, + pf->dplls.num_inputs, + pf->dplls.num_outputs, + &ice_dpll_output_ops, + pf->dplls.eec.dpll, + pf->dplls.pps.dpll); +if (ret) + goto deinit_inputs; + } + rclk_idx = pf->dplls.num_inputs + pf->dplls.num_outputs + pf-hw.pf_id;
drivers/net/ethernet/intel/ice/ice_dpll.c new file +13
-0+ ret =ice_dpll_init_rclk_pins (pf, &pf->dplls.rclk, rclk_idx, + &ice_dpll_rclk_ops); +if (ret) + goto deinit_outputs; + +return 0 ; +deinit_outputs: +ice_dpll_deinit_direct_pins (cgu, pf->dplls.outputs, + pf->dplls.num_outputs, + &ice_dpll_output_ops, pf->dplls.pps.dpll, + pf->dplls.eec.dpll); +deinit_inputs: + ice_dpll_deinit_direct_pins(cgu, pf->dplls.inputs, pf-dplls.num_inputs,
drivers/net/ethernet/intel/ice/ice_dpll.c new file +9
-0+ &ice_dpll_input_ops, pf->dplls.pps.dpll, + pf->dplls.eec.dpll); +return ret; +} + +/** +* ice_dpll_deinit_dpll - deinitialize dpll device +* @pf: board private structure +* @d: pointer to ice_dpll
Quoted 9 lines
Quoted 6 lines
+ * @cgu: if cgu is present and controlled by this NIC
+ *
+ * If cgu is owned unregister the dpll from dpll subsystem.
+ * Release resources of dpll device from dpll subsystem.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 16 lines
Quoted 16 lines
+ */
drivers/net/ethernet/intel/ice/ice_dpll.c new file +14
-0+static void +ice_dpll_deinit_dpll (struct ice_pf *pf,struct ice_dpll *d,bool cgu) +{ +if (cgu) +dpll_device_unregister (d->dpll, &ice_dpll_ops, d); +dpll_device_put (d->dpll); +} + +/** +* ice_dpll_init_dpll - initialize dpll device in dpll subsystem +* @pf: board private structure +* @d: dpll to be initialized +* @cgu: if cgu is present and controlled by this NIC +* @type: type of dpll being initialized
Quoted 9 lines
Quoted 6 lines
+ *
+ * Allocate dpll instance for this board in dpll subsystem, if cgu is controlled
+ * by this NIC, register dpll with the callback ops.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 32 lines
Quoted 32 lines
+ * Return:
+ * * 0 - success
+ * * negative - initialization failure reason
+ */drivers/net/ethernet/intel/ice/ice_dpll.c new file +27
-0+static int +ice_dpll_init_dpll (struct ice_pf *pf,struct ice_dpll *d,bool cgu, +enum dpll_type type) +{ +u64 clock_id = pf->dplls.clock_id; +int ret; + + d->dpll =dpll_device_get (clock_id, d->dpll_idx,THIS_MODULE ); +if (IS_ERR (d->dpll)) { + ret =PTR_ERR (d->dpll); +dev_err (ice_pf_to_dev (pf), +"dpll_device_get failed (%p) err=%d\n" , d, ret); +return ret; + } + d->pf = pf; +if (cgu) { + ret =dpll_device_register (d->dpll, type, &ice_dpll_ops, d); +if (ret) { +dpll_device_put (d->dpll); +return ret; + } + } + +return 0 ; +} + +/**
Quoted 9 lines
Quoted 6 lines
+ *
ice_dpll_deinit_worker- deinitialize dpll kworker
+ * @pf: board private structure
+ *
+ * Stop dpll's kworker, release it's resources.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 11 lines
Quoted 11 lines
+ */
drivers/net/ethernet/intel/ice/ice_dpll.c new file +9
-0+static void ice_dpll_deinit_worker (struct ice_pf *pf) +{ +struct ice_dplls *d = &pf->dplls; + +kthread_cancel_delayed_work_sync (&d->work); +kthread_destroy_worker (d->kworker); +} + +/**
Quoted 9 lines
Quoted 6 lines
+ *
ice_dpll_init_worker- Initialize DPLLs periodic worker
+ * @pf: board private structure
+ *
+ * Create and start DPLLs periodic worker.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 27 lines
Quoted 27 lines
+ * Return:
+ * * 0 - success
+ * * negative - create worker failure
+ */drivers/net/ethernet/intel/ice/ice_dpll.c new file +22
-0+static int ice_dpll_init_worker (struct ice_pf *pf) +{ +struct ice_dplls *d = &pf->dplls; +struct kthread_worker *kworker; + +ice_dpll_update_state (pf, &d->eec, true); +ice_dpll_update_state (pf, &d->pps, true); +kthread_init_delayed_work (&d->work, ice_dpll_periodic_work); + kworker =kthread_create_worker (0 ,"ice-dplls-%s" , +dev_name (ice_pf_to_dev (pf))); +if (IS_ERR (kworker)) +return PTR_ERR (kworker); + d->kworker = kworker; + d->cgu_state_acq_err_num =0 ; +kthread_queue_delayed_work (d->kworker, &d->work,0 ); + +return 0 ; +} + +/** +* ice_dpll_init_info_direct_pins - initializes direct pins info +* @pf: board private structure
Quoted 9 lines
Quoted 6 lines
+ * @pin_type: type of pins being initialized
+ *
+ * Init information for directly connected pins, cache them in pf's pins
+ * structures.
+ *
+ * Context: Called underpf->dplls.lock.No, it is not.
Yes, will fix.
Quoted 109 lines
Quoted 109 lines
+ * Return:
+ * * 0 - success
+ * * negative - init failure reason
+ */drivers/net/ethernet/intel/ice/ice_dpll.c new file +90
-0+static int +ice_dpll_init_info_direct_pins (struct ice_pf *pf, +enum ice_dpll_pin_type pin_type) +{ +struct ice_dpll *de = &pf->dplls.eec, *dp = &pf->dplls.pps; +struct ice_hw *hw = &pf->hw; +struct ice_dpll_pin *pins; +int num_pins, i, ret; +u8 freq_supp_num; +bool input; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + pins = pf->dplls.inputs; + num_pins = pf->dplls.num_inputs; + input = true; +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + pins = pf->dplls.outputs; + num_pins = pf->dplls.num_outputs; + input = false; +break ; +default : +return -EINVAL ; + } + +for (i =0 ; i < num_pins; i++) { + pins[i].idx = i; + pins[i].prop.board_label =ice_cgu_get_pin_name (hw, i, input); + pins[i].prop.type =ice_cgu_get_pin_type (hw, i, input); +if (input) { + ret =ice_aq_get_cgu_ref_prio (hw, de->dpll_idx, i, + &de->input_prio[i]); +if (ret) +return ret; + ret =ice_aq_get_cgu_ref_prio (hw, dp->dpll_idx, i, + &dp->input_prio[i]); +if (ret) +return ret; + pins[i].prop.capabilities |= +DPLL_PIN_CAPS_PRIORITY_CAN_CHANGE ; + } + pins[i].prop.capabilities |=DPLL_PIN_CAPS_STATE_CAN_CHANGE ; + ret =ice_dpll_pin_state_update (pf, &pins[i], pin_type,NULL ); +if (ret) +return ret; + pins[i].prop.freq_supported = +ice_cgu_get_pin_freq_supp (hw, i, input, &freq_supp_num); + pins[i].prop.freq_supported_num = freq_supp_num; + pins[i].pf = pf; + } + +return ret; +} + +/** +* ice_dpll_init_info_rclk_pin - initializes rclk pin information +* @pf: board private structure +* +* Init information for rclk pin, cache them in pf->dplls.rclk. +* +* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int ice_dpll_init_info_rclk_pin (struct ice_pf *pf) +{ +struct ice_dpll_pin *pin = &pf->dplls.rclk; + + pin->prop.type =DPLL_PIN_TYPE_SYNCE_ETH_PORT ; + pin->prop.capabilities |=DPLL_PIN_CAPS_STATE_CAN_CHANGE ; + pin->pf = pf; + +return ice_dpll_pin_state_update (pf, pin, +ICE_DPLL_PIN_TYPE_RCLK_INPUT ,NULL ); +} + +/** +* ice_dpll_init_pins_info - init pins info wrapper +* @pf: board private structure +* @pin_type: type of pins being initialized +* +* Wraps functions for pin initialization. +* +* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int +ice_dpll_init_pins_info(struct ice_pf *pf, enum ice_dpll_pin_type
pin_type)drivers/net/ethernet/intel/ice/ice_dpll.c new file +13
-0+{ +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : +case ICE_DPLL_PIN_TYPE_OUTPUT : +return ice_dpll_init_info_direct_pins (pf, pin_type); +case ICE_DPLL_PIN_TYPE_RCLK_INPUT : +return ice_dpll_init_info_rclk_pin (pf); +default : +return -EINVAL ; + } +} + +/**
Quoted 9 lines
Quoted 6 lines
+ *
ice_dpll_deinit_info- release memory allocated for pins info
+ * @pf: board private structure
+ *
+ * Release memory allocated for pins byice_dpll_init_infofunction.
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 17 lines
Quoted 6 lines
+ */
drivers/net/ethernet/intel/ice/ice_dpll.c new file +4
-0+static void ice_dpll_deinit_info (struct ice_pf *pf) +{ +kfree (pf->dplls.inputs); +kfree (pf->dplls.outputs);drivers/net/ethernet/intel/ice/ice_dpll.c
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+kfree (pf->dplls.eec.input_prio); +kfree (pf->dplls.pps.input_prio); +} + +/** +* ice_dpll_init_info - prepare pf's dpll information structure +* @pf: board private structure +* @cgu: if cgu is present and controlled by this NIC +* +* Acquire (from HW) and set basic dpll information (on pf->dplls struct).
Quoted 5 lines
Quoted 2 lines
+ *
+ * Context: Called underpf->dplls.lockNo, it is not.
Yes, will fix.
Quoted 93 lines
Quoted 93 lines
+ * Return:
+ * * 0 - success
+ * * negative - init failure reason
+ */drivers/net/ethernet/intel/ice/ice_dpll.c new file +75
-0+static int ice_dpll_init_info (struct ice_pf *pf,bool cgu) +{ +struct ice_aqc_get_cgu_abilities abilities; +struct ice_dpll *de = &pf->dplls.eec; +struct ice_dpll *dp = &pf->dplls.pps; +struct ice_dplls *d = &pf->dplls; +struct ice_hw *hw = &pf->hw; +int ret, alloc_size, i; + + d->clock_id =ice_generate_clock_id (pf); + ret =ice_aq_get_cgu_abilities (hw, &abilities); +if (ret) { +dev_err (ice_pf_to_dev (pf), +"err:%d %s failed to read cgu abilities\n" , + ret,ice_aq_str (hw->adminq.sq_last_status)); +return ret; + } + + de->dpll_idx = abilities.eec_dpll_idx; + dp->dpll_idx = abilities.pps_dpll_idx; + d->num_inputs = abilities.num_inputs; + d->num_outputs = abilities.num_outputs; + d->input_phase_adj_max =le32_to_cpu (abilities.max_in_phase_adj); + d->output_phase_adj_max =le32_to_cpu (abilities.max_out_phase_adj); + + alloc_size =sizeof (*d->inputs) * d->num_inputs; + d->inputs =kzalloc (alloc_size,GFP_KERNEL ); +if (!d->inputs) +return -ENOMEM ; + + alloc_size =sizeof (*de->input_prio) * d->num_inputs; + de->input_prio =kzalloc (alloc_size,GFP_KERNEL ); +if (!de->input_prio) +return -ENOMEM ; + + dp->input_prio =kzalloc (alloc_size,GFP_KERNEL ); +if (!dp->input_prio) +return -ENOMEM ; + + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_INPUT ); +if (ret) + goto deinit_info; + +if (cgu) { + alloc_size =sizeof (*d->outputs) * d->num_outputs; + d->outputs =kzalloc (alloc_size,GFP_KERNEL ); +if (!d->outputs) + goto deinit_info; + + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_OUTPUT ); +if (ret) + goto deinit_info; + } + + ret =ice_get_cgu_rclk_pin_info (&pf->hw, &d->base_rclk_idx, + &pf->dplls.rclk.num_parents); +if (ret) +return ret; +for (i =0 ; i < pf->dplls.rclk.num_parents; i++) + pf->dplls.rclk.parent_idx[i] = d->base_rclk_idx + i; + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_RCLK_INPUT ); +if (ret) +return ret; + de->mode =DPLL_MODE_AUTOMATIC ; + dp->mode =DPLL_MODE_AUTOMATIC ; + +dev_dbg (ice_pf_to_dev (pf), +"%s - success, inputs:%u, outputs:%u rclk-parents:%u\n" , + __func__, d->num_inputs, d->num_outputs, d->rclk.num_parents); + +return 0 ; + +deinit_info: + dev_err(ice_pf_to_dev(pf), + "%s - fail: d->inputs:%p, de->input_prio:%p, dp->input_prio:%p,d->outputs:%p\n",
drivers/net/ethernet/intel/ice/ice_dpll.c new file +12
-0+ __func__, d->inputs, de->input_prio, + dp->input_prio, d->outputs); +ice_dpll_deinit_info (pf); +return ret; +} + +/** +* ice_dpll_deinit - Disable the driver/HW support for dpll subsystem +* the dpll device. +* @pf: board private structure +* +* Handles the cleanup work required after dpll initialization,freeing
Quoted 9 lines
Quoted 5 lines
resources
+ * and unregistering the dpll, pin and all resources used for handling them.
+ *
+ * Context: Function holdspf->dplls.lockmutex.No it does not. Update your comments. Or better, remove them, they are totally useless anyway :/
Yes, will fix.
Quoted 13 lines
Quoted 13 lines
+ */
drivers/net/ethernet/intel/ice/ice_dpll.c new file +11
-0+void ice_dpll_deinit (struct ice_pf *pf) +{ +bool cgu =ice_is_feature_supported (pf,ICE_F_CGU ); + +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) +return ; +clear_bit (ICE_FLAG_DPLL , pf->flags); + +ice_dpll_deinit_pins (pf, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.pps, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.eec, cgu);
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 1999
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+ice_dpll_deinit_info (pf); +if (cgu) +ice_dpll_deinit_worker (pf);Could you please order the
ice_dpll_deinit()to be symmetrical toice_dpll_init()? Then, you can dropICE_FLAG_DPLLflag entirely, as theice_dpll_periodic_work()function is the only reason why you need it currently.
Not true.
The feature flag is common approach in ice. If the feature was successfully initialized the flag is set. It allows to determine if deinit of the feature is required on driver unload.
Right now the check for the flag is not only in kworker but also in each callback, if the flag were cleared the data shall be not accessed by callbacks. I know this is not required, but it helps on loading and unloading the driver, thanks to that, spam of pin-get dump is not slowing the driver load/unload.
Quoted 18 lines
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +8
-0+mutex_destroy (&pf->dplls.lock); +} + +/** +* ice_dpll_init - initialize support for dpll subsystem +* @pf: board private structure +* +* Set up the device dplls, register them and pins connected within Linux Quoted 6 lines
dpll
+ * subsystem. Allow userpsace to obtain state of DPLL and handling of DPLL
+ * configuration requests.
+ *
+ * Context: Function initializes and holdspf->dplls.lockmutex.No, it does not hold it.
Yes, will fix.
Quoted 34 lines
Quoted 34 lines
+ */
drivers/net/ethernet/intel/ice/ice_dpll.c new file +32
-0+void ice_dpll_init (struct ice_pf *pf) +{ +bool cgu =ice_is_feature_supported (pf,ICE_F_CGU ); +struct ice_dplls *d = &pf->dplls; +int err =0 ; + + err =ice_dpll_init_info (pf, cgu); +if (err) + goto err_exit; + err =ice_dpll_init_dpll (pf, &pf->dplls.eec, cgu,DPLL_TYPE_EEC ); +if (err) + goto deinit_info; + err =ice_dpll_init_dpll (pf, &pf->dplls.pps, cgu,DPLL_TYPE_PPS ); +if (err) + goto deinit_eec; + err =ice_dpll_init_pins (pf, cgu); +if (err) + goto deinit_pps; +set_bit (ICE_FLAG_DPLL , pf->flags); +if (cgu) { + err =ice_dpll_init_worker (pf); +if (err) + goto deinit_pins; + } + +return ; + +deinit_pins: +ice_dpll_deinit_pins (pf, cgu); +deinit_pps: +ice_dpll_deinit_dpll (pf, &pf->dplls.pps, cgu); +deinit_eec:
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 2050
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +6
-0+ice_dpll_deinit_dpll (pf, &pf->dplls.eec, cgu); +deinit_info: +ice_dpll_deinit_info (pf); +err_exit: +clear_bit (ICE_FLAG_DPLL , pf->flags); +mutex_unlock (&d->lock);Leftover, please remove.
Yes, will fix.
Quoted 144 lines
Review
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+mutex_destroy (&d->lock); +dev_warn (ice_pf_to_dev (pf),"DPLLs init failure err:%d\n" , err); +}(quoted diff) +0
-0
b/drivers/net/ethernet/intel/ice/ice_dpll.hQuoted 138 lines
new file mode 100644
index 000000000000..975066b71c5edrivers/net/ethernet/intel/ice/ice_dpll.h new file +104
-0@@ -0,0 +1,104 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2022, Intel Corporation. */ + +#ifndef _ICE_DPLL_H_ +#define _ICE_DPLL_H_ + +#include "ice.h" + +#define ICE_DPLL_PRIO_MAX 0xF +#define ICE_DPLL_RCLK_NUM_MAX 4 + +/** ice_dpll_pin - store info about pins +* @pin: dpll pin structure +* @pf: pointer to pf, which has registered the dpll_pin +* @idx: ice pin private idx +* @num_parents: hols number of parent pins +* @parent_idx: hold indexes of parent pins +* @flags: pin flags returned from HW +* @state: state of a pin +* @prop: pin properities +* @freq: current frequency of a pin +*/ +struct ice_dpll_pin { +struct dpll_pin *pin; +struct ice_pf *pf; +u8 idx; +u8 num_parents; +u8 parent_idx[ICE_DPLL_RCLK_NUM_MAX ]; +u8 flags[ICE_DPLL_RCLK_NUM_MAX ]; +u8 state[ICE_DPLL_RCLK_NUM_MAX ]; +struct dpll_pin_properties prop; +u32 freq; +}; + +/** ice_dpll - store info required for DPLL control +* @dpll: pointer to dpll dev +* @pf: pointer to pf, which has registered the dpll_device +* @dpll_idx: index of dpll on the NIC +* @input_idx: currently selected input index +* @prev_input_idx: previously selected input index +* @ref_state: state of dpll reference signals +* @eec_mode: eec_mode dpll is configured for +* @phase_shift: phase shift delay of a dpll +* @input_prio: priorities of each input +* @dpll_state: current dpll sync state +* @prev_dpll_state: last dpll sync state +* @active_input: pointer to active input pin +* @prev_input: pointer to previous active input pin +*/ +struct ice_dpll { +struct dpll_device *dpll; +struct ice_pf *pf; +u8 dpll_idx; +u8 input_idx; +u8 prev_input_idx; +u8 ref_state; +u8 eec_mode; +s64 phase_shift; +u8 *input_prio; +enum dpll_lock_status dpll_state; +enum dpll_lock_status prev_dpll_state; +enum dpll_mode mode; +struct dpll_pin *active_input; +struct dpll_pin *prev_input; +}; + +/** ice_dplls - store info required for CCU (clock controlling unit) +* @kworker: periodic worker +* @work: periodic work +* @lock: locks access to configuration of a dpll +* @eec: pointer to EEC dpll dev +* @pps: pointer to PPS dpll dev +* @inputs: input pins pointer +* @outputs: output pins pointer +* @rclk: recovered pins pointer +* @num_inputs: number of input pins available on dpll +* @num_outputs: number of output pins available on dpll +* @cgu_state_acq_err_num: number of errors returned during periodic work +* @base_rclk_idx: idx of first pin used for clock revocery pins +* @clock_id: clock_id of dplls +*/ +struct ice_dplls { +struct kthread_worker *kworker; +struct kthread_delayed_work work; +struct mutex lock; +struct ice_dpll eec; +struct ice_dpll pps; +struct ice_dpll_pin *inputs; +struct ice_dpll_pin *outputs; +struct ice_dpll_pin rclk; +u8 num_inputs; +u8 num_outputs; +int cgu_state_acq_err_num; +u8 base_rclk_idx; +u64 clock_id; +s32 input_phase_adj_max; +s32 output_phase_adj_max; +}; + +void ice_dpll_init (struct ice_pf *pf); + +void ice_dpll_deinit (struct ice_pf *pf); + +#endif drivers/net/ethernet/intel/ice/ice_main.c +7
-1@@ -4613,6 +4613,10 @@ static void ice_init_features(struct ice_pf *pf)if (ice_is_feature_supported (pf,ICE_F_GNSS ))ice_gnss_init (pf); +if (ice_is_feature_supported (pf,ICE_F_CGU ) || +ice_is_feature_supported (pf,ICE_F_PHY_RCLK )) +ice_dpll_init (pf); +/* Note: Flow director init failure is non-fatal to load */ if (ice_init_fdir (pf))dev_err (dev,"could not initialize flow director\n" );@@ -4639,6 +4643,9 @@ static void ice_deinit_features(struct ice_pf *pf)ice_gnss_exit (pf);if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags))ice_ptp_release (pf); +if (ice_is_feature_supported (pf,ICE_F_PHY_RCLK ) || +ice_is_feature_supported (pf,ICE_F_CGU )) +ice_dpll_deinit (pf); }static void ice_init_wakeup (struct ice_pf *pf) --2.27.0
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 6 lines · Sat, Jul 29, 2023 at 01:03:59AM CEST, [email protected] wrote:
Quoted 5 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 1:39 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 52
Quoted 7 lines
+static int
ice_dpll_cb_lock(struct ice_pf *pf, struct netlink_ext_ack *extack)drivers/net/ethernet/intel/ice/ice_dpll.c new file +5
-0+{ +int i; + +for (i =0 ; i <ICE_DPLL_LOCK_TRIES ; i++) { +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) {And again, as I already told you, this flag checking is totally pointless. See below my comment to ice_dpll_init()/ice_dpll_deinit().
This is not pointless, will explain below.
Quoted 2 lines
[...]
[...]
Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +11
-0+void ice_dpll_deinit (struct ice_pf *pf) +{ +bool cgu =ice_is_feature_supported (pf,ICE_F_CGU ); + +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) +return ; +clear_bit (ICE_FLAG_DPLL , pf->flags); + +ice_dpll_deinit_pins (pf, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.pps, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.eec, cgu);Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 1999
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+ice_dpll_deinit_info (pf); +if (cgu) +ice_dpll_deinit_worker (pf);Could you please order the
ice_dpll_deinit()to be symmetrical toice_dpll_init()? Then, you can dropICE_FLAG_DPLLflag entirely, as theice_dpll_periodic_work()function is the only reason why you need it currently.
Quoted 2 lines
Not true.
The feature flag is common approach in ice. If the feature was successfully
The fact that something is common does not necessarily mean it is correct. 0 value argument.
Quoted 5 lines
initialized the flag is set. It allows to determine if deinit of the feature is required on driver unload.
Right now the check for the flag is not only in kworker but also in each callback, if the flag were cleared the data shall be not accessed by callbacks.
Could you please draw me a scenario when this could actually happen? It is just a matter of ordering. Unregister dpll device/pins before you cleanup the related resources and you don't need this ridiculous flag.
Quoted 2 lines
I know this is not required, but it helps on loading and unloading the driver, thanks to that, spam of pin-get dump is not slowing the driver load/unload.
? Could you plese draw me a scenario how such thing may actually happen?
Thanks!
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +2
-0+mutex_destroy (&pf->dplls.lock); +}
[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 58 lines
From: Jiri Pirko <[email protected]>
Sent: Monday, July 31, 2023 2:20 PMQuoted 6 lines · Sat, Jul 29, 2023 at 01:03:59AM CEST, [email protected] wrote:
Quoted 5 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 1:39 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 52
Quoted 7 lines
+static int
ice_dpll_cb_lock(struct ice_pf *pf, struct netlink_ext_ack *extack)drivers/net/ethernet/intel/ice/ice_dpll.c new file +5
-0+{ +int i; + +for (i =0 ; i <ICE_DPLL_LOCK_TRIES ; i++) { +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) {And again, as I already told you, this flag checking is totally pointless. See below my comment to ice_dpll_init()/ice_dpll_deinit().
This is not pointless, will explain below.
Quoted 2 lines
[...]
[...]
Quoted 21 lines
Quoted 20 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +4
-0+void ice_dpll_deinit (struct ice_pf *pf) +{ +bool cgu =ice_is_feature_supported (pf,ICE_F_CGU ); +drivers/net/ethernet/intel/ice/ice_dpll.c line 1999
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+if (!test_bit (ICE_FLAG_DPLL , pf->flags)) +return ; +clear_bit (ICE_FLAG_DPLL , pf->flags); + +ice_dpll_deinit_pins (pf, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.pps, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.eec, cgu); +ice_dpll_deinit_info (pf); +if (cgu) +ice_dpll_deinit_worker (pf);Could you please order the
ice_dpll_deinit()to be symmetrical toice_dpll_init()? Then, you can dropICE_FLAG_DPLLflag entirely, as theice_dpll_periodic_work()function is the only reason why you need it currently.
Quoted 6 lines
Quoted 2 lines
Not true.
The feature flag is common approach in ice. If the feature was successfullyThe fact that something is common does not necessarily mean it is correct. 0 value argument.
Like using functions that unwrap netlink attributes as unsigned when they are in fact enums with possibility of being signed?
This is about consistent approach in ice driver.
Quoted 4 lines
Quoted 4 lines
initialized the flag is set. It allows to determine if deinit of the feature is required on driver unload.
Quoted 8 lines
Quoted 3 lines
Right now the check for the flag is not only in kworker but also in each callback, if the flag were cleared the data shall be not accessed by callbacks.
Could you please draw me a scenario when this could actually happen? It is just a matter of ordering. Unregister dpll device/pins before you cleanup the related resources and you don't need this ridiculous flag.
Flag allows to determine if dpll was successfully initialized and do proper deinit on rmmod only if it was initialized. That's all.
Quoted 7 lines
Quoted 5 lines
I know this is not required, but it helps on loading and unloading the driver,
thanks to that, spam of pin-get dump is not slowing the driver load/unload.? Could you plese draw me a scenario how such thing may actually happen?
First of all I said it is not required.
I already draw you this with above sentence.
You need spam pin-get asynchronously and unload driver, what is not clear? Basically mutex in dpll is a bottleneck, with multiple requests waiting for mutex there is low change of driver getting mutex when doing unregisters.
We actually need to redesign the mutex in dpll core/netlink, but I guess after initial submission.
Thank you!
Arkadiusz
Quoted 11 lines
Thanks!
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +2
-0+mutex_destroy (&pf->dplls.lock); +}[...]
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 61 lines · Tue, Aug 01, 2023 at 04:50:44PM CEST, [email protected] wrote:
Quoted 61 lines
From: Jiri Pirko <[email protected]>
Sent: Monday, July 31, 2023 2:20 PMQuoted 6 lines · Sat, Jul 29, 2023 at 01:03:59AM CEST, [email protected] wrote:
Quoted 5 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 1:39 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 52
Quoted 7 lines
+static int
ice_dpll_cb_lock(struct ice_pf *pf, struct netlink_ext_ack *extack)drivers/net/ethernet/intel/ice/ice_dpll.c new file +5
-0+{ +int i; + +for (i =0 ; i <ICE_DPLL_LOCK_TRIES ; i++) { +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) {And again, as I already told you, this flag checking is totally pointless. See below my comment to ice_dpll_init()/ice_dpll_deinit().
This is not pointless, will explain below.
Quoted 2 lines
[...]
[...]
Quoted 23 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +11
-0+void ice_dpll_deinit (struct ice_pf *pf) +{ +bool cgu =ice_is_feature_supported (pf,ICE_F_CGU ); + +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) +return ; +clear_bit (ICE_FLAG_DPLL , pf->flags); + +ice_dpll_deinit_pins (pf, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.pps, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.eec, cgu);Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 1999
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+ice_dpll_deinit_info (pf); +if (cgu) +ice_dpll_deinit_worker (pf);Could you please order the
ice_dpll_deinit()to be symmetrical toice_dpll_init()? Then, you can dropICE_FLAG_DPLLflag entirely, as theice_dpll_periodic_work()function is the only reason why you need it currently.Not true.
The feature flag is common approach in ice. If the feature was successfully
Quoted 6 lines
Quoted 3 lines
The fact that something is common does not necessarily mean it is correct. 0 value argument.
Like using functions that unwrap netlink attributes as unsigned when they are in fact enums with possibility of being signed?
Looks this is bothering you, sorry about that.
Quoted 11 lines
This is about consistent approach in ice driver.
Quoted 8 lines
Quoted 7 lines
initialized the flag is set. It allows to determine if deinit of the feature is required on driver unload.
Right now the check for the flag is not only in kworker but also in each callback, if the flag were cleared the data shall be not accessed by callbacks.
Quoted 7 lines
Quoted 4 lines
Could you please draw me a scenario when this could actually happen? It is just a matter of ordering. Unregister dpll device/pins before you cleanup the related resources and you don't need this ridiculous flag.
Flag allows to determine if dpll was successfully initialized and do proper deinit on rmmod only if it was initialized. That's all.
You are not answering my question. I asked about how the flag helps is you do unregister dpll devices/pins and you free related resources in the correct order. Because that is why you claim you need this flag.
I'm tired of this. Keep your driver tangled for all I care, I'm trying to help you, obviously you are not interested.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
I know this is not required, but it helps on loading and unloading the driver,
thanks to that, spam of pin-get dump is not slowing the driver load/unload.
Quoted 8 lines
Quoted 1 line
? Could you plese draw me a scenario how such thing may actually happen?
First of all I said it is not required.
I already draw you this with above sentence.
You need spam pin-get asynchronously and unload driver, what is not clear? Basically mutex in dpll is a bottleneck, with multiple requests waiting for mutex there is low change of driver getting mutex when doing unregisters.
How exactly your flag helps you in this scenario? It does not.
Quoted 3 lines
We actually need to redesign the mutex in dpll core/netlink, but I guess after initial submission.
Why?
Quoted 15 lines
Thank you!
ArkadiuszQuoted 11 lines
Thanks!
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +2
-0+mutex_destroy (&pf->dplls.lock); +}[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 67 lines
From: Jiri Pirko <[email protected]>
Sent: Wednesday, August 2, 2023 8:57 AMQuoted 63 lines · Tue, Aug 01, 2023 at 04:50:44PM CEST, [email protected] wrote:
Quoted 63 lines
From: Jiri Pirko <[email protected]>
Sent: Monday, July 31, 2023 2:20 PMSat, Jul 29, 2023 at 01:03:59AM CEST, [email protected]
Quoted 6 lines · wrote:
Quoted 5 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 1:39 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 52
Quoted 7 lines
+static int
ice_dpll_cb_lock(struct ice_pf *pf, struct netlink_ext_ack *extack)drivers/net/ethernet/intel/ice/ice_dpll.c new file +5
-0+{ +int i; + +for (i =0 ; i <ICE_DPLL_LOCK_TRIES ; i++) { +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) {And again, as I already told you, this flag checking is totally pointless. See below my comment to ice_dpll_init()/ice_dpll_deinit().
This is not pointless, will explain below.
Quoted 2 lines
[...]
[...]
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +11
-0+void ice_dpll_deinit (struct ice_pf *pf) +{ +bool cgu =ice_is_feature_supported (pf,ICE_F_CGU ); + +if (!test_bit (ICE_FLAG_DPLL , pf->flags)) +return ; +clear_bit (ICE_FLAG_DPLL , pf->flags); + +ice_dpll_deinit_pins (pf, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.pps, cgu); +ice_dpll_deinit_dpll (pf, &pf->dplls.eec, cgu);Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_dpll.c line 1999
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +3
-0+ice_dpll_deinit_info (pf); +if (cgu) +ice_dpll_deinit_worker (pf);Could you please order the
ice_dpll_deinit()to be symmetrical toice_dpll_init()? Then, you can dropICE_FLAG_DPLLflag entirely, as theice_dpll_periodic_work()function is the only reason why you need it currently.Not true.
The feature flag is common approach in ice. If the feature was successfully
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
The fact that something is common does not necessarily mean it is correct. 0 value argument.
Like using functions that unwrap netlink attributes as unsigned when they are in fact enums with possibility of being signed?
Looks this is bothering you, sorry about that.
Just poining out.
Quoted 18 lines
Quoted 18 lines
This is about consistent approach in ice driver.
Quoted 13 lines
Quoted 8 lines
initialized the flag is set. It allows to determine if deinit of the feature
is required on driver unload.Right now the check for the flag is not only in kworker but also in each callback, if the flag were cleared the data shall be not accessed by callbacks.
Could you please draw me a scenario when this could actually happen? It is just a matter of ordering. Unregister dpll device/pins before you cleanup the related resources and you don't need this ridiculous flag.
Quoted 8 lines
Quoted 3 lines
Flag allows to determine if dpll was successfully initialized and do proper
deinit on rmmod only if it was initialized. That's all.You are not answering my question. I asked about how the flag helps is you do unregister dpll devices/pins and you free related resources in the correct order. Because that is why you claim you need this flag.
I do not claim such thing, actually opposite, I said it helps a bit but the reason for existence is different, yet you are still trying to imply me this.
Quoted 3 lines
I'm tired of this. Keep your driver tangled for all I care, I'm trying to help you, obviously you are not interested.
With review you are doing great job and many thanks for that.
Already said it multiple times, the main reason of flag existence is not a use in the callback but to determine successful dpll initialization. As there is no need to call unregister on anything if it was not successfully registered.
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 7 lines
I know this is not required, but it helps on loading and unloading the driver,
thanks to that, spam of pin-get dump is not slowing the driver load/unload.? Could you plese draw me a scenario how such thing may actually happen?
First of all I said it is not required.
Quoted 8 lines
Quoted 5 lines
I already draw you this with above sentence.
You need spam pin-get asynchronously and unload driver, what is not clear? Basically mutex in dpll is a bottleneck, with multiple requests waiting for
mutex there is low change of driver getting mutex when doing unregisters.How exactly your flag helps you in this scenario? It does not.
In this scenario it helps because it fails the callbacks when dpll subsystem was partially initialized and callbacks can be already invoked, but in fact the dpll initialization is not yet finished in the driver, and there will always be the time between first and second dpll registration where we might wait for the mutex to become available on dpll core part.
Quoted 8 lines
Quoted 5 lines
We actually need to redesign the mutex in dpll core/netlink, but I guess after
initial submission.Why?
The global mutex for accessing the data works just fine, but it is slow. Maybe we could improve this by using rwlock instead.
Thank you!
Arkadiusz
Quoted 16 lines
Quoted 16 lines
Thank you!
ArkadiuszQuoted 11 lines
Thanks!
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +2
-0+mutex_destroy (&pf->dplls.lock); +}[...]
Jiri Pirko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 110 lines · Wed, Aug 02, 2023 at 05:48:43PM CEST, [email protected] wrote:
Quoted 67 lines
From: Jiri Pirko <[email protected]>
Sent: Wednesday, August 2, 2023 8:57 AMQuoted 63 lines · Tue, Aug 01, 2023 at 04:50:44PM CEST, [email protected] wrote:
Quoted 63 lines
From: Jiri Pirko <[email protected]>
Sent: Monday, July 31, 2023 2:20 PMSat, Jul 29, 2023 at 01:03:59AM CEST, [email protected]
Quoted 6 lines · wrote:
Quoted 5 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 1:39 PMQuoted 1 line · Thu, Jul 20, 2023 at 11:19:01AM CEST, [email protected] wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 19 lines
Quoted 11 lines
Review
Quoted 7 lines
+static int
ice_dpll_cb_lock(struct ice_pf *pf, struct netlink_ext_ack *extack)(quoted diff) +5
-0+{ + int i; + + for (i = 0; i < ICE_DPLL_LOCK_TRIES; i++) { + if (!test_bit(ICE_FLAG_DPLL, pf->flags)) {And again, as I already told you, this flag checking is totally pointless. See below my comment to ice_dpll_init()/ice_dpll_deinit().
This is not pointless, will explain below.
Quoted 2 lines
[...]
[...]
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +11
-0+void ice_dpll_deinit(struct ice_pf *pf) +{ + bool cgu = ice_is_feature_supported(pf, ICE_F_CGU); + + if (!test_bit(ICE_FLAG_DPLL, pf->flags)) + return; + clear_bit(ICE_FLAG_DPLL, pf->flags); + + ice_dpll_deinit_pins(pf, cgu); + ice_dpll_deinit_dpll(pf, &pf->dplls.pps, cgu); + ice_dpll_deinit_dpll(pf, &pf->dplls.eec, cgu);Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ ice_dpll_deinit_info(pf); + if (cgu) + ice_dpll_deinit_worker(pf);Could you please order the
ice_dpll_deinit()to be symmetrical toice_dpll_init()? Then, you can dropICE_FLAG_DPLLflag entirely, as theice_dpll_periodic_work()function is the only reason why you need it currently.Not true.
The feature flag is common approach in ice. If the feature was successfullyQuoted 9 lines
Quoted 6 lines
Quoted 3 lines
The fact that something is common does not necessarily mean it is correct. 0 value argument.
Like using functions that unwrap netlink attributes as unsigned when they are in fact enums with possibility of being signed?
Looks this is bothering you, sorry about that.
Just poining out.
Quoted 18 lines
Quoted 18 lines
This is about consistent approach in ice driver.
Quoted 13 lines
Quoted 8 lines
initialized the flag is set. It allows to determine if deinit of the feature
is required on driver unload.Right now the check for the flag is not only in kworker but also in each callback, if the flag were cleared the data shall be not accessed by callbacks.
Could you please draw me a scenario when this could actually happen? It is just a matter of ordering. Unregister dpll device/pins before you cleanup the related resources and you don't need this ridiculous flag.
Quoted 8 lines
Quoted 3 lines
Flag allows to determine if dpll was successfully initialized and do proper
deinit on rmmod only if it was initialized. That's all.You are not answering my question. I asked about how the flag helps is you do unregister dpll devices/pins and you free related resources in the correct order. Because that is why you claim you need this flag.
I do not claim such thing, actually opposite, I said it helps a bit but the reason for existence is different, yet you are still trying to imply me this.
Quoted 8 lines
Quoted 3 lines
I'm tired of this. Keep your driver tangled for all I care, I'm trying to help you, obviously you are not interested.
With review you are doing great job and many thanks for that.
Already said it multiple times, the main reason of flag existence is not a use in the callback but to determine successful dpll initialization.
So use it only for this, nothing else. Use it only to check during cleanup that you need to do the cleanup as init was previously done.
Quoted 21 lines
As there is no need to call unregister on anything if it was not successfully registered.
Quoted 18 lines
Quoted 17 lines
Quoted 9 lines
Quoted 7 lines
I know this is not required, but it helps on loading and unloading the driver,
thanks to that, spam of pin-get dump is not slowing the driver load/unload.? Could you plese draw me a scenario how such thing may actually happen?
First of all I said it is not required.
I already draw you this with above sentence.
You need spam pin-get asynchronously and unload driver, what is not clear? Basically mutex in dpll is a bottleneck, with multiple requests waiting for
mutex there is low change of driver getting mutex when doing unregisters.
Quoted 8 lines
Quoted 2 lines
How exactly your flag helps you in this scenario? It does not.
In this scenario it helps because it fails the callbacks when dpll subsystem was partially initialized and callbacks can be already invoked, but in fact the dpll initialization is not yet finished in the driver, and there will always be the time between first and second dpll registration where we might wait for the mutex to become available on dpll core part.
Draw it to me, please, where exatly there is a problem. I'm still convinced that with the proper ordering of init/cleanup flows, you'll get all you need, without any flag use.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
We actually need to redesign the mutex in dpll core/netlink, but I guess after
initial submission.
Quoted 5 lines
Quoted 2 lines
Why?
The global mutex for accessing the data works just fine, but it is slow. Maybe we could improve this by using rwlock instead.
"it is slow" is quite vague description of what's wrong with the locking.
Quoted 20 lines
Thank you!
ArkadiuszQuoted 16 lines
Quoted 16 lines
Thank you!
ArkadiuszQuoted 11 lines
Thanks!
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +2
-0+ mutex_destroy(&pf->dplls.lock); +}[...]
Kubalewski, Arkadiusz
maintainerRE: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 123 lines
From: Jiri Pirko <[email protected]>
Sent: Thursday, August 3, 2023 10:03 AMQuoted 119 lines · Wed, Aug 02, 2023 at 05:48:43PM CEST, [email protected] wrote:
Quoted 71 lines
From: Jiri Pirko <[email protected]>
Sent: Wednesday, August 2, 2023 8:57 AMTue, Aug 01, 2023 at 04:50:44PM CEST, [email protected]
Quoted 66 lines · wrote:
Quoted 66 lines
From: Jiri Pirko <[email protected]>
Sent: Monday, July 31, 2023 2:20 PMSat, Jul 29, 2023 at 01:03:59AM CEST, [email protected]
Quoted 7 lines · wrote:
Quoted 6 lines
From: Jiri Pirko <[email protected]>
Sent: Friday, July 21, 2023 1:39 PMThu, Jul 20, 2023 at 11:19:01AM CEST, [email protected]
Quoted 1 line · wrote:
From: Arkadiusz Kubalewski <[email protected]>
[...]
Quoted 20 lines
Quoted 12 lines
Review
Quoted 8 lines
+static int ice_dpll_cb_lock(struct
ice_pf*pf, structnetlink_ext_ack
*extack)(quoted diff) +5
-0+{ + int i; + + for (i = 0; i < ICE_DPLL_LOCK_TRIES; i++) { + if (!test_bit(ICE_FLAG_DPLL, pf->flags)) {And again, as I already told you, this flag checking is totally pointless. See below my comment to ice_dpll_init()/ice_dpll_deinit().
This is not pointless, will explain below.
Quoted 2 lines
[...]
[...]
Quoted 25 lines
Quoted 12 lines
Quoted 12 lines
(quoted diff) +12
-0+void ice_dpll_deinit(struct ice_pf *pf) +{ + bool cgu = ice_is_feature_supported(pf, ICE_F_CGU); + + if (!test_bit(ICE_FLAG_DPLL, pf->flags)) + return; + clear_bit(ICE_FLAG_DPLL, pf->flags); + + ice_dpll_deinit_pins(pf, cgu); + ice_dpll_deinit_dpll(pf, &pf->dplls.pps, cgu); + ice_dpll_deinit_dpll(pf, &pf->dplls.eec, cgu); + ice_dpll_deinit_info(pf);Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (cgu) + ice_dpll_deinit_worker(pf);Could you please order the
ice_dpll_deinit()to be symmetrical toice_dpll_init()? Then, you can dropICE_FLAG_DPLLflag entirely, as theice_dpll_periodic_work()function is the only reason why you need it currently.Not true.
The feature flag is common approach in ice. If the feature was successfullyQuoted 9 lines
Quoted 6 lines
Quoted 3 lines
The fact that something is common does not necessarily mean it is correct. 0 value argument.
Like using functions that unwrap netlink attributes as unsigned when they are in fact enums with possibility of being signed?
Looks this is bothering you, sorry about that.
Just poining out.
Quoted 19 lines
Quoted 19 lines
This is about consistent approach in ice driver.
Quoted 14 lines
Quoted 9 lines
initialized the flag is set. It allows to determine if deinit of the feature
is required on driver unload.Right now the check for the flag is not only in kworker but also in each
callback, if the flag were cleared the data shall be not accessed by callbacks.Could you please draw me a scenario when this could actually happen? It is just a matter of ordering. Unregister dpll device/pins before you cleanup the related resources and you don't need this ridiculous flag.
Quoted 8 lines
Quoted 3 lines
Flag allows to determine if dpll was successfully initialized and do proper
deinit on rmmod only if it was initialized. That's all.You are not answering my question. I asked about how the flag helps is you do unregister dpll devices/pins and you free related resources in the correct order. Because that is why you claim you need this flag.
I do not claim such thing, actually opposite, I said it helps a bit but the reason for existence is different, yet you are still trying to imply me this.
Quoted 3 lines
I'm tired of this. Keep your driver tangled for all I care, I'm trying to help you, obviously you are not interested.
Quoted 8 lines
Quoted 4 lines
With review you are doing great job and many thanks for that.
Already said it multiple times, the main reason of flag existence is not a use in the callback but to determine successful dpll initialization.
So use it only for this, nothing else. Use it only to check during cleanup that you need to do the cleanup as init was previously done.
Ok, will do.
Quoted 39 lines
Quoted 2 lines
As there is no need to call unregister on anything if it was not
successfully
Quoted 26 lines
registered.
Quoted 21 lines
Quoted 13 lines
Quoted 10 lines
Quoted 7 lines
I know this is not required, but it helps on loading and unloading the driver,
thanks to that, spam of pin-get dump is not slowing the driver load/unload.? Could you plese draw me a scenario how such thing may actually happen?
First of all I said it is not required.
Quoted 7 lines
I already draw you this with above sentence.
You need spam pin-get asynchronously and unload driver, what is not clear?
Basically mutex in dpll is a bottleneck, with multiple requests waiting for
mutex there is low change of driver getting mutex when doing unregisters.Quoted 2 lines
How exactly your flag helps you in this scenario? It does not.
Quoted 9 lines
In this scenario it helps because it fails the callbacks when dpll subsystem
was partially initialized and callbacks can be already invoked, but in fact
the dpll initialization is not yet finished in the driver, and there will always
be the time between first and second dpll registration where we might wait for
the mutex to become available on dpll core part.
Quoted 4 lines
Draw it to me, please, where exatly there is a problem. I'm still convinced that with the proper ordering of init/cleanup flows, you'll get all you need, without any flag use.
But I never said there is some issue, was saying from the beginning "helping a bit" and "not required". Sorry I don't know how to draw this other than above.
As agreed, will fix and use it only to deinit, let's move on, it is not required :)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
We actually need to redesign the mutex in dpll core/netlink, but I guess after
initial submission.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Why?
The global mutex for accessing the data works just fine, but it is slow. Maybe we could improve this by using rwlock instead.
"it is slow" is quite vague description of what's wrong with the locking.
I mean serialized access to dpll is something that might be the issue in the OS with multiple pins/devices and tools monitoring them, no hard data so far.
Thank you!
Arkadiusz
Quoted 21 lines
Quoted 21 lines
Thank you!
ArkadiuszQuoted 16 lines
Quoted 16 lines
Thank you!
ArkadiuszQuoted 11 lines
Thanks!
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +2
-0+ mutex_destroy(&pf->dplls.lock); +}[...]
Re: [PATCH 09/11] ice: implement dpll interface to control cgu
In reply to Vadim FedorenkoOn Thu, Jul 20, 2023 at 10:19:01AM +0100, Vadim Fedorenko wrote:
...
Hi Vadim,
Quoted 23 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +23
-0+/** +* ice_dpll_cb_unlock - unlock dplls mutex in callback context +* @pf: private board structure +* +* Unlock the mutex from the callback operations invoked by dpll subsystem. +*/ +static void ice_dpll_cb_unlock (struct ice_pf *pf) +{ +mutex_unlock (&pf->dplls.lock); +} + +/** +* ice_dpll_pin_freq_set - set pin's frequency +* @pf: private board structure +* @pin: pointer to a pin +* @pin_type: type of pin being configured +* @freq: frequency to be set +* @extack: error reporting +* +* Set requested frequency on a pin. +* +* Context: Called under pf->dplls.lock +* Return:
drivers/net/ethernet/intel/ice/ice_dpll.c line 100
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+* * 0 - success +* * negative - error on AQ or wrong pin type given +*/ +static int +ice_dpll_pin_freq_set (struct ice_pf *pf,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type,const u32 freq, +struct netlink_ext_ack *extack) +{ +int ret; +u8 flags;
Please arrange local variable declarations for new Networking code in reverse xmas tree order - longest line to shortest.
Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +27
-0+ +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + flags =ICE_AQC_SET_CGU_IN_CFG_FLG1_UPDATE_FREQ ; + ret =ice_aq_set_input_pin_cfg (&pf->hw, pin->idx, flags, + pin->flags[0 ], freq,0 ); +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + flags =ICE_AQC_SET_CGU_OUT_CFG_UPDATE_FREQ ; + ret =ice_aq_set_output_pin_cfg (&pf->hw, pin->idx, flags, +0 , freq,0 ); +break ; +default : +return -EINVAL ; + } +if (ret) { +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to set pin freq:%u on pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + freq, pin->idx); +return ret; + } + pin->freq = freq; + +return 0 ; +}
...
Quoted 544 lines
(quoted diff) +542
-0+/** + * ice_dpll_pin_state_update - update pin's state + * @pf: private board struct + * @pin: structure with pin attributes to be updated + * @pin_type: type of pin being updated + * @extack: error reporting + * + * Determine pin current state and frequency, then update struct + * holding the pin info. For input pin states are separated for each + * dpll, for rclk pins states are separated for each parent. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +int +ice_dpll_pin_state_update(struct ice_pf *pf, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +/** + * ice_dpll_frequency_set - wrapper for pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * @pin_type: type of pin being configured + * + * Wraps internal set frequency command on a pin. + * + * Context: Acquires pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + const u32 frequency, + struct netlink_ext_ack *extack, + enum ice_dpll_pin_type pin_type) +{ + struct ice_dpll_pin *p = pin_priv; + struct ice_dpll *d = dpll_priv; + struct ice_pf *pf = d->pf; + int ret; + + ret = ice_dpll_cb_lock(pf, extack); + if (ret) + return ret; + ret = ice_dpll_pin_freq_set(pf, p, pin_type, frequency, extack); + ice_dpll_cb_unlock(pf); + + return ret; +} + +/** + * ice_dpll_input_frequency_set - input pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * + * Wraps internal set frequency command on a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_input_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_set(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_INPUT); +} + +/** + * ice_dpll_output_frequency_set - output pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * + * Wraps internal set frequency command on a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_output_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_set(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_OUTPUT); +} + +/** + * ice_dpll_frequency_get - wrapper for pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * @pin_type: type of pin being configured + * + * Wraps internal get frequency command of a pin. + * + * Context: Acquires pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack, + enum ice_dpll_pin_type pin_type) +{ + struct ice_dpll_pin *p = pin_priv; + struct ice_dpll *d = dpll_priv; + struct ice_pf *pf = d->pf; + int ret; + + ret = ice_dpll_cb_lock(pf, extack); + if (ret) + return ret; + *frequency = p->freq; + ice_dpll_cb_unlock(pf); + + return 0; +} + +/** + * ice_dpll_input_frequency_get - input pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * + * Wraps internal get frequency command of a input pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_input_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_get(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_INPUT); +} + +/** + * ice_dpll_output_frequency_get - output pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * + * Wraps internal get frequency command of a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_output_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_get(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_OUTPUT); +} + +/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0; + int ret; + + switch (pin_type) { + case ICE_DPLL_PIN_TYPE_INPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN; + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_INPUT_EN; + ret = ice_aq_set_input_pin_cfg(hw, pin->idx, 0, flags, 0, 0); + break; + case ICE_DPLL_PIN_TYPE_OUTPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN; + flags |= ICE_AQC_SET_CGU_OUT_CFG_OUT_EN; + ret = ice_aq_set_output_pin_cfg(hw, pin->idx, flags, 0, 0, 0); + break; + default: + return -EINVAL; + } + if (ret) + NL_SET_ERR_MSG_FMT(extack, + "err:%d %s failed to enable %s pin:%u\n", + ret, ice_aq_str(hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + + return ret; +} + +/** + * ice_dpll_pin_disable - disable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being disabled + * @extack: error reporting + * + * Disable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_disable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0; + int ret; + + switch (pin_type) { + case ICE_DPLL_PIN_TYPE_INPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN; + ret = ice_aq_set_input_pin_cfg(hw, pin->idx, 0, flags, 0, 0); + break; + case ICE_DPLL_PIN_TYPE_OUTPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN; + ret = ice_aq_set_output_pin_cfg(hw, pin->idx, flags, 0, 0, 0); + break; + default: + return -EINVAL; + } + if (ret) + NL_SET_ERR_MSG_FMT(extack, + "err:%d %s failed to disable %s pin:%u\n", + ret, ice_aq_str(hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + + return ret; +} +/** + * ice_dpll_frequency_set - wrapper for pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * @pin_type: type of pin being configured + * + * Wraps internal set frequency command on a pin. + * + * Context: Acquires pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + const u32 frequency, + struct netlink_ext_ack *extack, + enum ice_dpll_pin_type pin_type) +{ + struct ice_dpll_pin *p = pin_priv; + struct ice_dpll *d = dpll_priv; + struct ice_pf *pf = d->pf; + int ret; + + ret = ice_dpll_cb_lock(pf, extack); + if (ret) + return ret; + ret = ice_dpll_pin_freq_set(pf, p, pin_type, frequency, extack); + ice_dpll_cb_unlock(pf); + + return ret; +} + +/** + * ice_dpll_input_frequency_set - input pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * + * Wraps internal set frequency command on a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_input_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_set(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_INPUT); +} + +/** + * ice_dpll_output_frequency_set - output pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * + * Wraps internal set frequency command on a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_output_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_set(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_OUTPUT); +} + +/** + * ice_dpll_frequency_get - wrapper for pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * @pin_type: type of pin being configured + * + * Wraps internal get frequency command of a pin. + * + * Context: Acquires pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack, + enum ice_dpll_pin_type pin_type) +{ + struct ice_dpll_pin *p = pin_priv; + struct ice_dpll *d = dpll_priv; + struct ice_pf *pf = d->pf; + int ret; + + ret = ice_dpll_cb_lock(pf, extack); + if (ret) + return ret; + *frequency = p->freq; + ice_dpll_cb_unlock(pf); + + return 0; +} + +/** + * ice_dpll_input_frequency_get - input pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * + * Wraps internal get frequency command of a input pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_input_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_get(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_INPUT); +} + +/** + * ice_dpll_output_frequency_get - output pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * + * Wraps internal get frequency command of a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_output_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_get(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_OUTPUT); +} + +/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0; + int ret; + + switch (pin_type) { + case ICE_DPLL_PIN_TYPE_INPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN; + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_INPUT_EN; + ret = ice_aq_set_input_pin_cfg(hw, pin->idx, 0, flags, 0, 0); + break; + case ICE_DPLL_PIN_TYPE_OUTPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN; + flags |= ICE_AQC_SET_CGU_OUT_CFG_OUT_EN; + ret = ice_aq_set_output_pin_cfg(hw, pin->idx, flags, 0, 0, 0); + break; + default: + return -EINVAL; + } + if (ret) + NL_SET_ERR_MSG_FMT(extack, + "err:%d %s failed to enable %s pin:%u\n", + ret, ice_aq_str(hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + + return ret; +} + +/** + * ice_dpll_pin_disable - disable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being disabled + * @extack: error reporting + * + * Disable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_disable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0; + int ret; + + switch (pin_type) { + case ICE_DPLL_PIN_TYPE_INPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN; + ret = ice_aq_set_input_pin_cfg(hw, pin->idx, 0, flags, 0, 0); + break; + case ICE_DPLL_PIN_TYPE_OUTPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN; + ret = ice_aq_set_output_pin_cfg(hw, pin->idx, flags, 0, 0, 0); + break; + default:
Review
Quoted 10 lines
(quoted diff) +10
-0+ return -EINVAL; + } + if (ret) + NL_SET_ERR_MSG_FMT(extack, + "err:%d %s failed to disable %s pin:%u\n", + ret, ice_aq_str(hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + + return ret; +}
Should this function be static?
Quoted 35 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +35
-0+{ +int ret; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + ret =ice_aq_get_input_pin_cfg (&pf->hw, pin->idx,NULL ,NULL , +NULL , &pin->flags[0 ], + &pin->freq,NULL ); +if (ret) + goto err; +if (ICE_AQC_GET_CGU_IN_CFG_FLG2_INPUT_EN & pin->flags[0 ]) { +if (pin->pin) { + pin->state[pf->dplls.eec.dpll_idx] = + pin->pin == pf->dplls.eec.active_input ? +DPLL_PIN_STATE_CONNECTED : +DPLL_PIN_STATE_SELECTABLE ; + pin->state[pf->dplls.pps.dpll_idx] = + pin->pin == pf->dplls.pps.active_input ? +DPLL_PIN_STATE_CONNECTED : +DPLL_PIN_STATE_SELECTABLE ; + }else { + pin->state[pf->dplls.eec.dpll_idx] = +DPLL_PIN_STATE_SELECTABLE ; + pin->state[pf->dplls.pps.dpll_idx] = +DPLL_PIN_STATE_SELECTABLE ; + } + }else { + pin->state[pf->dplls.eec.dpll_idx] = +DPLL_PIN_STATE_DISCONNECTED ; + pin->state[pf->dplls.pps.dpll_idx] = +DPLL_PIN_STATE_DISCONNECTED ; + } +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + ret = ice_aq_get_output_pin_cfg(&pf->hw, pin->idx,
drivers/net/ethernet/intel/ice/ice_dpll.c line 460
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ &pin->flags[0 ],NULL , + &pin->freq, NULL); +if (ret) + goto err; +if (ICE_AQC_SET_CGU_OUT_CFG_OUT_EN & pin->flags[0 ]) + pin->state[0 ] =DPLL_PIN_STATE_CONNECTED ; +else + pin->state[0 ] =DPLL_PIN_STATE_DISCONNECTED ; +break ; +case ICE_DPLL_PIN_TYPE_RCLK_INPUT :
clang-16 complains that:
drivers/net/ethernet/intel/ice/ice_dpll.c:461:3: error: expected expression
u8 parent, port_num = ICE_AQC_SET_PHY_REC_CLK_OUT_CURR_PORT;Which, I think means, it wants this case to be enclosed in { }
Quoted 40 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +40
-0+u8 parent, port_num =ICE_AQC_SET_PHY_REC_CLK_OUT_CURR_PORT ; + +for (parent =0 ; parent < pf->dplls.rclk.num_parents; + parent++) { +u8 p = parent; + + ret =ice_aq_get_phy_rec_clk_out (&pf->hw, &p, + &port_num, + &pin->flags[parent], +NULL ); +if (ret) + goto err; +if (ICE_AQC_GET_PHY_REC_CLK_OUT_OUT_EN & + pin->flags[parent]) + pin->state[parent] =DPLL_PIN_STATE_CONNECTED ; +else + pin->state[parent] = +DPLL_PIN_STATE_DISCONNECTED ; + } +break ; +default : +return -EINVAL ; + } + +return 0 ; +err: +if (extack) +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to update %s pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); +else +dev_err_ratelimited (ice_pf_to_dev (pf), +"err:%d %s failed to update %s pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); +return ret; +}
...
Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +27
-0+/** +* ice_dpll_update_state - update dpll state +* @pf: pf private structure +* @d: pointer to queried dpll device +* @init: if function called on initialization of ice dpll +* +* Poll current state of dpll from hw and update ice_dpll struct. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - AQ failure +*/ +static int +ice_dpll_update_state (struct ice_pf *pf,struct ice_dpll *d,bool init) +{ +struct ice_dpll_pin *p =NULL ; +int ret; + + ret =ice_get_cgu_state (&pf->hw, d->dpll_idx, d->prev_dpll_state, + &d->input_idx, &d->ref_state, &d->eec_mode, + &d->phase_shift, &d->dpll_state, &d->mode); + +dev_dbg (ice_pf_to_dev (pf), +"update dpll=%d, prev_src_idx:%u, src_idx:%u, state:%d, prev:%d mode:%d\n" , + d->dpll_idx, d->prev_input_idx, d->input_idx, + d->dpll_state, d->prev_dpll_state, d->mode);
drivers/net/ethernet/intel/ice/ice_dpll.c line 1206
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+if (ret) { +dev_err (ice_pf_to_dev (pf), +"update dpll=%d state failed, ret=%d %s\n" , + d->dpll_idx, ret, +ice_aq_str (pf->hw.adminq.sq_last_status)); +return ret; + } +if (init) { +if (d->dpll_state ==DPLL_LOCK_STATUS_LOCKED && + d->dpll_state ==DPLL_LOCK_STATUS_LOCKED_HO_ACQ )
Should this be '||' rather than '&&' ?
Flagged by a clang-16 W=1 build, Sparse and Smatch.
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +5
-0+ d->active_input = pf->dplls.inputs[d->input_idx].pin; + p = &pf->dplls.inputs[d->input_idx]; +return ice_dpll_pin_state_update (pf, p, +ICE_DPLL_PIN_TYPE_INPUT ,NULL ); + }
...
Quoted 55 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +55
-0+/** +* ice_dpll_init_info_direct_pins - initializes direct pins info +* @pf: board private structure +* @pin_type: type of pins being initialized +* +* Init information for directly connected pins, cache them in pf's pins +* structures. +* +* Context: Called under pf->dplls.lock. +* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int +ice_dpll_init_info_direct_pins (struct ice_pf *pf, +enum ice_dpll_pin_type pin_type) +{ +struct ice_dpll *de = &pf->dplls.eec, *dp = &pf->dplls.pps; +struct ice_hw *hw = &pf->hw; +struct ice_dpll_pin *pins; +int num_pins, i, ret; +u8 freq_supp_num; +bool input; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + pins = pf->dplls.inputs; + num_pins = pf->dplls.num_inputs; + input = true; +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + pins = pf->dplls.outputs; + num_pins = pf->dplls.num_outputs; + input = false; +break ; +default : +return -EINVAL ; + } + +for (i =0 ; i < num_pins; i++) { + pins[i].idx = i; + pins[i].prop.board_label =ice_cgu_get_pin_name (hw, i, input); + pins[i].prop.type =ice_cgu_get_pin_type (hw, i, input); +if (input) { + ret =ice_aq_get_cgu_ref_prio (hw, de->dpll_idx, i, + &de->input_prio[i]); +if (ret) +return ret; + ret =ice_aq_get_cgu_ref_prio (hw, dp->dpll_idx, i, + &dp->input_prio[i]); +if (ret) +return ret; + pins[i].prop.capabilities |= +DPLL_PIN_CAPS_PRIORITY_CAN_CHANGE ; + }
drivers/net/ethernet/intel/ice/ice_dpll.c line 1816
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ pins[i].prop.capabilities |=DPLL_PIN_CAPS_STATE_CAN_CHANGE ; + ret =ice_dpll_pin_state_update (pf, &pins[i], pin_type,NULL ); +if (ret) +return ret; + pins[i].prop.freq_supported = +ice_cgu_get_pin_freq_supp (hw, i, input, &freq_supp_num); + pins[i].prop.freq_supported_num = freq_supp_num; + pins[i].pf = pf; + } +
I'm unsure if this can happen,
but if the for loop above iterates zero times
then ret will be null here.
Use of uninitialised variable flagged by Smatch.
Quoted 2 lines
(quoted diff) +2
-0+ return ret; +}
...
Quoted 49 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +49
-0+/** +* ice_dpll_init_info - prepare pf's dpll information structure +* @pf: board private structure +* @cgu: if cgu is present and controlled by this NIC +* +* Acquire (from HW) and set basic dpll information (on pf->dplls struct). +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int ice_dpll_init_info (struct ice_pf *pf,bool cgu) +{ +struct ice_aqc_get_cgu_abilities abilities; +struct ice_dpll *de = &pf->dplls.eec; +struct ice_dpll *dp = &pf->dplls.pps; +struct ice_dplls *d = &pf->dplls; +struct ice_hw *hw = &pf->hw; +int ret, alloc_size, i; + + d->clock_id =ice_generate_clock_id (pf); + ret =ice_aq_get_cgu_abilities (hw, &abilities); +if (ret) { +dev_err (ice_pf_to_dev (pf), +"err:%d %s failed to read cgu abilities\n" , + ret,ice_aq_str (hw->adminq.sq_last_status)); +return ret; + } + + de->dpll_idx = abilities.eec_dpll_idx; + dp->dpll_idx = abilities.pps_dpll_idx; + d->num_inputs = abilities.num_inputs; + d->num_outputs = abilities.num_outputs; + d->input_phase_adj_max =le32_to_cpu (abilities.max_in_phase_adj); + d->output_phase_adj_max =le32_to_cpu (abilities.max_out_phase_adj); + + alloc_size =sizeof (*d->inputs) * d->num_inputs; + d->inputs =kzalloc (alloc_size,GFP_KERNEL ); +if (!d->inputs) +return -ENOMEM ; + + alloc_size =sizeof (*de->input_prio) * d->num_inputs; + de->input_prio =kzalloc (alloc_size,GFP_KERNEL ); +if (!de->input_prio) +return -ENOMEM ; + + dp->input_prio =kzalloc (alloc_size,GFP_KERNEL ); +if (!dp->input_prio)
drivers/net/ethernet/intel/ice/ice_dpll.c line 1941
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+return -ENOMEM ; + + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_INPUT ); +if (ret) + goto deinit_info; + +if (cgu) { + alloc_size =sizeof (*d->outputs) * d->num_outputs; + d->outputs =kzalloc (alloc_size,GFP_KERNEL ); +if (!d->outputs)
Should ret be set to -ENOMEM here?
Flagged by Smatch.
Quoted 33 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +33
-0+ goto deinit_info; + + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_OUTPUT ); +if (ret) + goto deinit_info; + } + + ret =ice_get_cgu_rclk_pin_info (&pf->hw, &d->base_rclk_idx, + &pf->dplls.rclk.num_parents); +if (ret) +return ret; +for (i =0 ; i < pf->dplls.rclk.num_parents; i++) + pf->dplls.rclk.parent_idx[i] = d->base_rclk_idx + i; + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_RCLK_INPUT ); +if (ret) +return ret; + de->mode =DPLL_MODE_AUTOMATIC ; + dp->mode =DPLL_MODE_AUTOMATIC ; + +dev_dbg (ice_pf_to_dev (pf), +"%s - success, inputs:%u, outputs:%u rclk-parents:%u\n" , + __func__, d->num_inputs, d->num_outputs, d->rclk.num_parents); + +return 0 ; + +deinit_info: +dev_err (ice_pf_to_dev (pf), +"%s - fail: d->inputs:%p, de->input_prio:%p, dp->input_prio:%p, d->outputs:%p\n" , + __func__, d->inputs, de->input_prio, + dp->input_prio, d->outputs); +ice_dpll_deinit_info (pf); +return ret; +}
...
Quoted 6 lines
+/**
+ *ice_dpll_init- initialize support for dpll subsystem
+ * @pf: board private structure
+ *
+ * Set up the device dplls, register them and pins connected within Linux dpll
+ * subsystem. Allow userpsace to obtain state of DPLL and handling of DPLL
nit: userpsace -> userspace
Quoted 4 lines
+ * configuration requests.
+ *
+ * Context: Function initializes and holdspf->dplls.lockmutex.
+ */
...
Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_dpll.h new file +10
-0@@ -0,0 +1,104 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2022, Intel Corporation. */ + +#ifndef _ICE_DPLL_H_ +#define _ICE_DPLL_H_ + +#include "ice.h" + +#define ICE_DPLL_PRIO_MAX 0xF +#define ICE_DPLL_RCLK_NUM_MAX 4
drivers/net/ethernet/intel/ice/ice_dpll.h line 20
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.h new file +10
-0+ +/** ice_dpll_pin - store info about pins +* @pin: dpll pin structure +* @pf: pointer to pf, which has registered the dpll_pin +* @idx: ice pin private idx +* @num_parents: hols number of parent pins +* @parent_idx: hold indexes of parent pins +* @flags: pin flags returned from HW +* @state: state of a pin +* @prop: pin properities
nit: properities -> properties
Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_dpll.h new file +13
-0+* @freq: current frequency of a pin +*/ +struct ice_dpll_pin { +struct dpll_pin *pin; +struct ice_pf *pf; +u8 idx; +u8 num_parents; +u8 parent_idx[ICE_DPLL_RCLK_NUM_MAX ]; +u8 flags[ICE_DPLL_RCLK_NUM_MAX ]; +u8 state[ICE_DPLL_RCLK_NUM_MAX ]; +struct dpll_pin_properties prop; +u32 freq; +};
...
Vadim Fedorenko
maintainerRe: [PATCH 09/11] ice: implement dpll interface to control cgu
Quoted 6 lines · Simon Horman
On Thu, Jul 20, 2023 at 10:19:01AM +0100, Vadim Fedorenko wrote:
...
Hi Vadim,
Hi Simon!
Thanks for the review. I believe Arkadiusz as the author of the patch will adjust the code accordingly
Quoted 1,007 lines
Quoted 23 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +23
-0+/** +* ice_dpll_cb_unlock - unlock dplls mutex in callback context +* @pf: private board structure +* +* Unlock the mutex from the callback operations invoked by dpll subsystem. +*/ +static void ice_dpll_cb_unlock (struct ice_pf *pf) +{ +mutex_unlock (&pf->dplls.lock); +} + +/** +* ice_dpll_pin_freq_set - set pin's frequency +* @pf: private board structure +* @pin: pointer to a pin +* @pin_type: type of pin being configured +* @freq: frequency to be set +* @extack: error reporting +* +* Set requested frequency on a pin. +* +* Context: Called under pf->dplls.lock +* Return: drivers/net/ethernet/intel/ice/ice_dpll.c line 100
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+* * 0 - success +* * negative - error on AQ or wrong pin type given +*/ +static int +ice_dpll_pin_freq_set (struct ice_pf *pf,struct ice_dpll_pin *pin, +enum ice_dpll_pin_type pin_type,const u32 freq, +struct netlink_ext_ack *extack) +{ +int ret; +u8 flags;Please arrange local variable declarations for new Networking code in reverse xmas tree order - longest line to shortest.
Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +27
-0+ +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + flags =ICE_AQC_SET_CGU_IN_CFG_FLG1_UPDATE_FREQ ; + ret =ice_aq_set_input_pin_cfg (&pf->hw, pin->idx, flags, + pin->flags[0 ], freq,0 ); +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + flags =ICE_AQC_SET_CGU_OUT_CFG_UPDATE_FREQ ; + ret =ice_aq_set_output_pin_cfg (&pf->hw, pin->idx, flags, +0 , freq,0 ); +break ; +default : +return -EINVAL ; + } +if (ret) { +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to set pin freq:%u on pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + freq, pin->idx); +return ret; + } + pin->freq = freq; + +return 0 ; +}...
Quoted 544 lines
(quoted diff) +542
-0+/** + * ice_dpll_pin_state_update - update pin's state + * @pf: private board struct + * @pin: structure with pin attributes to be updated + * @pin_type: type of pin being updated + * @extack: error reporting + * + * Determine pin current state and frequency, then update struct + * holding the pin info. For input pin states are separated for each + * dpll, for rclk pins states are separated for each parent. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +int +ice_dpll_pin_state_update(struct ice_pf *pf, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +/** + * ice_dpll_frequency_set - wrapper for pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * @pin_type: type of pin being configured + * + * Wraps internal set frequency command on a pin. + * + * Context: Acquires pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + const u32 frequency, + struct netlink_ext_ack *extack, + enum ice_dpll_pin_type pin_type) +{ + struct ice_dpll_pin *p = pin_priv; + struct ice_dpll *d = dpll_priv; + struct ice_pf *pf = d->pf; + int ret; + + ret = ice_dpll_cb_lock(pf, extack); + if (ret) + return ret; + ret = ice_dpll_pin_freq_set(pf, p, pin_type, frequency, extack); + ice_dpll_cb_unlock(pf); + + return ret; +} + +/** + * ice_dpll_input_frequency_set - input pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * + * Wraps internal set frequency command on a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_input_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_set(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_INPUT); +} + +/** + * ice_dpll_output_frequency_set - output pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * + * Wraps internal set frequency command on a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_output_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_set(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_OUTPUT); +} + +/** + * ice_dpll_frequency_get - wrapper for pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * @pin_type: type of pin being configured + * + * Wraps internal get frequency command of a pin. + * + * Context: Acquires pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack, + enum ice_dpll_pin_type pin_type) +{ + struct ice_dpll_pin *p = pin_priv; + struct ice_dpll *d = dpll_priv; + struct ice_pf *pf = d->pf; + int ret; + + ret = ice_dpll_cb_lock(pf, extack); + if (ret) + return ret; + *frequency = p->freq; + ice_dpll_cb_unlock(pf); + + return 0; +} + +/** + * ice_dpll_input_frequency_get - input pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * + * Wraps internal get frequency command of a input pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_input_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_get(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_INPUT); +} + +/** + * ice_dpll_output_frequency_get - output pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * + * Wraps internal get frequency command of a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_output_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_get(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_OUTPUT); +} + +/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0; + int ret; + + switch (pin_type) { + case ICE_DPLL_PIN_TYPE_INPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN; + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_INPUT_EN; + ret = ice_aq_set_input_pin_cfg(hw, pin->idx, 0, flags, 0, 0); + break; + case ICE_DPLL_PIN_TYPE_OUTPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN; + flags |= ICE_AQC_SET_CGU_OUT_CFG_OUT_EN; + ret = ice_aq_set_output_pin_cfg(hw, pin->idx, flags, 0, 0, 0); + break; + default: + return -EINVAL; + } + if (ret) + NL_SET_ERR_MSG_FMT(extack, + "err:%d %s failed to enable %s pin:%u\n", + ret, ice_aq_str(hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + + return ret; +} + +/** + * ice_dpll_pin_disable - disable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being disabled + * @extack: error reporting + * + * Disable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_disable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0; + int ret; + + switch (pin_type) { + case ICE_DPLL_PIN_TYPE_INPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN; + ret = ice_aq_set_input_pin_cfg(hw, pin->idx, 0, flags, 0, 0); + break; + case ICE_DPLL_PIN_TYPE_OUTPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN; + ret = ice_aq_set_output_pin_cfg(hw, pin->idx, flags, 0, 0, 0); + break; + default: + return -EINVAL; + } + if (ret) + NL_SET_ERR_MSG_FMT(extack, + "err:%d %s failed to disable %s pin:%u\n", + ret, ice_aq_str(hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + + return ret; +} +/** + * ice_dpll_frequency_set - wrapper for pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * @pin_type: type of pin being configured + * + * Wraps internal set frequency command on a pin. + * + * Context: Acquires pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + const u32 frequency, + struct netlink_ext_ack *extack, + enum ice_dpll_pin_type pin_type) +{ + struct ice_dpll_pin *p = pin_priv; + struct ice_dpll *d = dpll_priv; + struct ice_pf *pf = d->pf; + int ret; + + ret = ice_dpll_cb_lock(pf, extack); + if (ret) + return ret; + ret = ice_dpll_pin_freq_set(pf, p, pin_type, frequency, extack); + ice_dpll_cb_unlock(pf); + + return ret; +} + +/** + * ice_dpll_input_frequency_set - input pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * + * Wraps internal set frequency command on a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_input_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_set(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_INPUT); +} + +/** + * ice_dpll_output_frequency_set - output pin callback for set frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: frequency to be set + * @extack: error reporting + * + * Wraps internal set frequency command on a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't set in hw + */ +static int +ice_dpll_output_frequency_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_set(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_OUTPUT); +} + +/** + * ice_dpll_frequency_get - wrapper for pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * @pin_type: type of pin being configured + * + * Wraps internal get frequency command of a pin. + * + * Context: Acquires pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack, + enum ice_dpll_pin_type pin_type) +{ + struct ice_dpll_pin *p = pin_priv; + struct ice_dpll *d = dpll_priv; + struct ice_pf *pf = d->pf; + int ret; + + ret = ice_dpll_cb_lock(pf, extack); + if (ret) + return ret; + *frequency = p->freq; + ice_dpll_cb_unlock(pf); + + return 0; +} + +/** + * ice_dpll_input_frequency_get - input pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * + * Wraps internal get frequency command of a input pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_input_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_get(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_INPUT); +} + +/** + * ice_dpll_output_frequency_get - output pin callback for get frequency + * @pin: pointer to a pin + * @pin_priv: private data pointer passed on pin registration + * @dpll: pointer to dpll + * @dpll_priv: private data pointer passed on dpll registration + * @frequency: on success holds pin's frequency + * @extack: error reporting + * + * Wraps internal get frequency command of a pin. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - success + * * negative - error pin not found or couldn't get from hw + */ +static int +ice_dpll_output_frequency_get(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, void *dpll_priv, + u64 *frequency, struct netlink_ext_ack *extack) +{ + return ice_dpll_frequency_get(pin, pin_priv, dpll, dpll_priv, frequency, + extack, ICE_DPLL_PIN_TYPE_OUTPUT); +} + +/** + * ice_dpll_pin_enable - enable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being enabled + * @extack: error reporting + * + * Enable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_enable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0; + int ret; + + switch (pin_type) { + case ICE_DPLL_PIN_TYPE_INPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN; + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_INPUT_EN; + ret = ice_aq_set_input_pin_cfg(hw, pin->idx, 0, flags, 0, 0); + break; + case ICE_DPLL_PIN_TYPE_OUTPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN; + flags |= ICE_AQC_SET_CGU_OUT_CFG_OUT_EN; + ret = ice_aq_set_output_pin_cfg(hw, pin->idx, flags, 0, 0, 0); + break; + default: + return -EINVAL; + } + if (ret) + NL_SET_ERR_MSG_FMT(extack, + "err:%d %s failed to enable %s pin:%u\n", + ret, ice_aq_str(hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + + return ret; +} + +/** + * ice_dpll_pin_disable - disable a pin on dplls + * @hw: board private hw structure + * @pin: pointer to a pin + * @pin_type: type of pin being disabled + * @extack: error reporting + * + * Disable a pin on both dplls. Store current state in pin->flags. + * + * Context: Called under pf->dplls.lock + * Return: + * * 0 - OK + * * negative - error + */ +static int +ice_dpll_pin_disable(struct ice_hw *hw, struct ice_dpll_pin *pin, + enum ice_dpll_pin_type pin_type, + struct netlink_ext_ack *extack) +{ + u8 flags = 0; + int ret; + + switch (pin_type) { + case ICE_DPLL_PIN_TYPE_INPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_IN_CFG_FLG2_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_IN_CFG_FLG2_ESYNC_EN; + ret = ice_aq_set_input_pin_cfg(hw, pin->idx, 0, flags, 0, 0); + break; + case ICE_DPLL_PIN_TYPE_OUTPUT: + if (pin->flags[0] & ICE_AQC_GET_CGU_OUT_CFG_ESYNC_EN) + flags |= ICE_AQC_SET_CGU_OUT_CFG_ESYNC_EN; + ret = ice_aq_set_output_pin_cfg(hw, pin->idx, flags, 0, 0, 0); + break; + default:Review
Quoted 10 lines
(quoted diff) +10
-0+ return -EINVAL; + } + if (ret) + NL_SET_ERR_MSG_FMT(extack, + "err:%d %s failed to disable %s pin:%u\n", + ret, ice_aq_str(hw->adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); + + return ret; +}Should this function be static?
Quoted 35 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +35
-0+{ +int ret; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + ret =ice_aq_get_input_pin_cfg (&pf->hw, pin->idx,NULL ,NULL , +NULL , &pin->flags[0 ], + &pin->freq,NULL ); +if (ret) + goto err; +if (ICE_AQC_GET_CGU_IN_CFG_FLG2_INPUT_EN & pin->flags[0 ]) { +if (pin->pin) { + pin->state[pf->dplls.eec.dpll_idx] = + pin->pin == pf->dplls.eec.active_input ? +DPLL_PIN_STATE_CONNECTED : +DPLL_PIN_STATE_SELECTABLE ; + pin->state[pf->dplls.pps.dpll_idx] = + pin->pin == pf->dplls.pps.active_input ? +DPLL_PIN_STATE_CONNECTED : +DPLL_PIN_STATE_SELECTABLE ; + }else { + pin->state[pf->dplls.eec.dpll_idx] = +DPLL_PIN_STATE_SELECTABLE ; + pin->state[pf->dplls.pps.dpll_idx] = +DPLL_PIN_STATE_SELECTABLE ; + } + }else { + pin->state[pf->dplls.eec.dpll_idx] = +DPLL_PIN_STATE_DISCONNECTED ; + pin->state[pf->dplls.pps.dpll_idx] = +DPLL_PIN_STATE_DISCONNECTED ; + } +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + ret = ice_aq_get_output_pin_cfg(&pf->hw, pin->idx,drivers/net/ethernet/intel/ice/ice_dpll.c line 460
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ &pin->flags[0 ],NULL , + &pin->freq, NULL); +if (ret) + goto err; +if (ICE_AQC_SET_CGU_OUT_CFG_OUT_EN & pin->flags[0 ]) + pin->state[0 ] =DPLL_PIN_STATE_CONNECTED ; +else + pin->state[0 ] =DPLL_PIN_STATE_DISCONNECTED ; +break ; +case ICE_DPLL_PIN_TYPE_RCLK_INPUT :clang-16 complains that:
drivers/net/ethernet/intel/ice/ice_dpll.c:461:3: error: expected expression u8 parent, port_num = ICE_AQC_SET_PHY_REC_CLK_OUT_CURR_PORT;Which, I think means, it wants this case to be enclosed in { }
Quoted 40 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +40
-0+u8 parent, port_num =ICE_AQC_SET_PHY_REC_CLK_OUT_CURR_PORT ; + +for (parent =0 ; parent < pf->dplls.rclk.num_parents; + parent++) { +u8 p = parent; + + ret =ice_aq_get_phy_rec_clk_out (&pf->hw, &p, + &port_num, + &pin->flags[parent], +NULL ); +if (ret) + goto err; +if (ICE_AQC_GET_PHY_REC_CLK_OUT_OUT_EN & + pin->flags[parent]) + pin->state[parent] =DPLL_PIN_STATE_CONNECTED ; +else + pin->state[parent] = +DPLL_PIN_STATE_DISCONNECTED ; + } +break ; +default : +return -EINVAL ; + } + +return 0 ; +err: +if (extack) +NL_SET_ERR_MSG_FMT (extack, +"err:%d %s failed to update %s pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); +else +dev_err_ratelimited (ice_pf_to_dev (pf), +"err:%d %s failed to update %s pin:%u\n" , + ret, +ice_aq_str (pf->hw.adminq.sq_last_status), + pin_type_name[pin_type], pin->idx); +return ret; +}...
Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +27
-0+/** +* ice_dpll_update_state - update dpll state +* @pf: pf private structure +* @d: pointer to queried dpll device +* @init: if function called on initialization of ice dpll +* +* Poll current state of dpll from hw and update ice_dpll struct. +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - AQ failure +*/ +static int +ice_dpll_update_state (struct ice_pf *pf,struct ice_dpll *d,bool init) +{ +struct ice_dpll_pin *p =NULL ; +int ret; + + ret =ice_get_cgu_state (&pf->hw, d->dpll_idx, d->prev_dpll_state, + &d->input_idx, &d->ref_state, &d->eec_mode, + &d->phase_shift, &d->dpll_state, &d->mode); + +dev_dbg (ice_pf_to_dev (pf), +"update dpll=%d, prev_src_idx:%u, src_idx:%u, state:%d, prev:%d mode:%d\n" , + d->dpll_idx, d->prev_input_idx, d->input_idx, + d->dpll_state, d->prev_dpll_state, d->mode);drivers/net/ethernet/intel/ice/ice_dpll.c line 1206
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+if (ret) { +dev_err (ice_pf_to_dev (pf), +"update dpll=%d state failed, ret=%d %s\n" , + d->dpll_idx, ret, +ice_aq_str (pf->hw.adminq.sq_last_status)); +return ret; + } +if (init) { +if (d->dpll_state ==DPLL_LOCK_STATUS_LOCKED && + d->dpll_state ==DPLL_LOCK_STATUS_LOCKED_HO_ACQ )Should this be '||' rather than '&&' ?
Flagged by a clang-16 W=1 build, Sparse and Smatch.
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +5
-0+ d->active_input = pf->dplls.inputs[d->input_idx].pin; + p = &pf->dplls.inputs[d->input_idx]; +return ice_dpll_pin_state_update (pf, p, +ICE_DPLL_PIN_TYPE_INPUT ,NULL ); + }...
Quoted 55 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +55
-0+/** +* ice_dpll_init_info_direct_pins - initializes direct pins info +* @pf: board private structure +* @pin_type: type of pins being initialized +* +* Init information for directly connected pins, cache them in pf's pins +* structures. +* +* Context: Called under pf->dplls.lock. +* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int +ice_dpll_init_info_direct_pins (struct ice_pf *pf, +enum ice_dpll_pin_type pin_type) +{ +struct ice_dpll *de = &pf->dplls.eec, *dp = &pf->dplls.pps; +struct ice_hw *hw = &pf->hw; +struct ice_dpll_pin *pins; +int num_pins, i, ret; +u8 freq_supp_num; +bool input; + +switch (pin_type) { +case ICE_DPLL_PIN_TYPE_INPUT : + pins = pf->dplls.inputs; + num_pins = pf->dplls.num_inputs; + input = true; +break ; +case ICE_DPLL_PIN_TYPE_OUTPUT : + pins = pf->dplls.outputs; + num_pins = pf->dplls.num_outputs; + input = false; +break ; +default : +return -EINVAL ; + } + +for (i =0 ; i < num_pins; i++) { + pins[i].idx = i; + pins[i].prop.board_label =ice_cgu_get_pin_name (hw, i, input); + pins[i].prop.type =ice_cgu_get_pin_type (hw, i, input); +if (input) { + ret =ice_aq_get_cgu_ref_prio (hw, de->dpll_idx, i, + &de->input_prio[i]); +if (ret) +return ret; + ret =ice_aq_get_cgu_ref_prio (hw, dp->dpll_idx, i, + &dp->input_prio[i]); +if (ret) +return ret; + pins[i].prop.capabilities |= +DPLL_PIN_CAPS_PRIORITY_CAN_CHANGE ; + }drivers/net/ethernet/intel/ice/ice_dpll.c line 1816
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+ pins[i].prop.capabilities |=DPLL_PIN_CAPS_STATE_CAN_CHANGE ; + ret =ice_dpll_pin_state_update (pf, &pins[i], pin_type,NULL ); +if (ret) +return ret; + pins[i].prop.freq_supported = +ice_cgu_get_pin_freq_supp (hw, i, input, &freq_supp_num); + pins[i].prop.freq_supported_num = freq_supp_num; + pins[i].pf = pf; + } +I'm unsure if this can happen,
but if the for loop above iterates zero times
then ret will be null here.Use of uninitialised variable flagged by Smatch.
Quoted 2 lines
(quoted diff) +2
-0+ return ret; +}...
Quoted 49 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +49
-0+/** +* ice_dpll_init_info - prepare pf's dpll information structure +* @pf: board private structure +* @cgu: if cgu is present and controlled by this NIC +* +* Acquire (from HW) and set basic dpll information (on pf->dplls struct). +* +* Context: Called under pf->dplls.lock +* Return: +* * 0 - success +* * negative - init failure reason +*/ +static int ice_dpll_init_info (struct ice_pf *pf,bool cgu) +{ +struct ice_aqc_get_cgu_abilities abilities; +struct ice_dpll *de = &pf->dplls.eec; +struct ice_dpll *dp = &pf->dplls.pps; +struct ice_dplls *d = &pf->dplls; +struct ice_hw *hw = &pf->hw; +int ret, alloc_size, i; + + d->clock_id =ice_generate_clock_id (pf); + ret =ice_aq_get_cgu_abilities (hw, &abilities); +if (ret) { +dev_err (ice_pf_to_dev (pf), +"err:%d %s failed to read cgu abilities\n" , + ret,ice_aq_str (hw->adminq.sq_last_status)); +return ret; + } + + de->dpll_idx = abilities.eec_dpll_idx; + dp->dpll_idx = abilities.pps_dpll_idx; + d->num_inputs = abilities.num_inputs; + d->num_outputs = abilities.num_outputs; + d->input_phase_adj_max =le32_to_cpu (abilities.max_in_phase_adj); + d->output_phase_adj_max =le32_to_cpu (abilities.max_out_phase_adj); + + alloc_size =sizeof (*d->inputs) * d->num_inputs; + d->inputs =kzalloc (alloc_size,GFP_KERNEL ); +if (!d->inputs) +return -ENOMEM ; + + alloc_size =sizeof (*de->input_prio) * d->num_inputs; + de->input_prio =kzalloc (alloc_size,GFP_KERNEL ); +if (!de->input_prio) +return -ENOMEM ; + + dp->input_prio =kzalloc (alloc_size,GFP_KERNEL ); +if (!dp->input_prio)drivers/net/ethernet/intel/ice/ice_dpll.c line 1941
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +10
-0+return -ENOMEM ; + + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_INPUT ); +if (ret) + goto deinit_info; + +if (cgu) { + alloc_size =sizeof (*d->outputs) * d->num_outputs; + d->outputs =kzalloc (alloc_size,GFP_KERNEL ); +if (!d->outputs)Should ret be set to
-ENOMEMhere?Flagged by Smatch.
Quoted 33 lines
drivers/net/ethernet/intel/ice/ice_dpll.c new file +33
-0+ goto deinit_info; + + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_OUTPUT ); +if (ret) + goto deinit_info; + } + + ret =ice_get_cgu_rclk_pin_info (&pf->hw, &d->base_rclk_idx, + &pf->dplls.rclk.num_parents); +if (ret) +return ret; +for (i =0 ; i < pf->dplls.rclk.num_parents; i++) + pf->dplls.rclk.parent_idx[i] = d->base_rclk_idx + i; + ret =ice_dpll_init_pins_info (pf,ICE_DPLL_PIN_TYPE_RCLK_INPUT ); +if (ret) +return ret; + de->mode =DPLL_MODE_AUTOMATIC ; + dp->mode =DPLL_MODE_AUTOMATIC ; + +dev_dbg (ice_pf_to_dev (pf), +"%s - success, inputs:%u, outputs:%u rclk-parents:%u\n" , + __func__, d->num_inputs, d->num_outputs, d->rclk.num_parents); + +return 0 ; + +deinit_info: +dev_err (ice_pf_to_dev (pf), +"%s - fail: d->inputs:%p, de->input_prio:%p, dp->input_prio:%p, d->outputs:%p\n" , + __func__, d->inputs, de->input_prio, + dp->input_prio, d->outputs); +ice_dpll_deinit_info (pf); +return ret; +}...
Quoted 6 lines
+/**
+ *ice_dpll_init- initialize support for dpll subsystem
+ * @pf: board private structure
+ *
+ * Set up the device dplls, register them and pins connected within Linux dpll
+ * subsystem. Allow userpsace to obtain state of DPLL and handling of DPLLnit: userpsace -> userspace
Quoted 4 lines
+ * configuration requests.
+ *
+ * Context: Function initializes and holdspf->dplls.lockmutex.
+ */...
Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_dpll.h new file +10
-0@@ -0,0 +1,104 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2022, Intel Corporation. */ + +#ifndef _ICE_DPLL_H_ +#define _ICE_DPLL_H_ + +#include "ice.h" + +#define ICE_DPLL_PRIO_MAX 0xF +#define ICE_DPLL_RCLK_NUM_MAX 4drivers/net/ethernet/intel/ice/ice_dpll.h line 20
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dpll.h new file +10
-0+ +/** ice_dpll_pin - store info about pins +* @pin: dpll pin structure +* @pf: pointer to pf, which has registered the dpll_pin +* @idx: ice pin private idx +* @num_parents: hols number of parent pins +* @parent_idx: hold indexes of parent pins +* @flags: pin flags returned from HW +* @state: state of a pin +* @prop: pin properities nit: properities -> properties
Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_dpll.h new file +13
-0+* @freq: current frequency of a pin +*/ +struct ice_dpll_pin { +struct dpll_pin *pin; +struct ice_pf *pf; +u8 idx; +u8 num_parents; +u8 parent_idx[ICE_DPLL_RCLK_NUM_MAX ]; +u8 flags[ICE_DPLL_RCLK_NUM_MAX ]; +u8 state[ICE_DPLL_RCLK_NUM_MAX ]; +struct dpll_pin_properties prop; +u32 freq; +};...