public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next] dpll: add direction and state filtering for pin show
@ 2026-03-31 13:59 Petr Oros
  2026-03-31 14:07 ` Ivan Vecera
  2026-04-05 16:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Petr Oros @ 2026-03-31 13:59 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, stephen, ivecera, Petr Oros

Allow filtering pins by direction (input/output) and state
(connected/disconnected/selectable) in the pin show command.
These filters match against parent-device nested attributes and
can be combined with the parent-device filter to check a specific
parent-device relationship.

Example: dpll pin show parent-device 0 direction input state connected
Signed-off-by: Petr Oros <poros@redhat.com>
---
 bash-completion/dpll | 11 ++++++-
 dpll/dpll.c          | 71 ++++++++++++++++++++++++++++++++++++++++++--
 man/man8/dpll.8      | 23 +++++++++++++-
 3 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/bash-completion/dpll b/bash-completion/dpll
index 5913c894dda96e..981c3edbf367b0 100644
--- a/bash-completion/dpll
+++ b/bash-completion/dpll
@@ -185,10 +185,19 @@ _dpll_pin()
                         int-oscillator gnss" -- "$cur" ) )
                     return 0
                     ;;
+                direction)
+                    COMPREPLY=( $( compgen -W "input output" -- "$cur" ) )
+                    return 0
+                    ;;
+                state)
+                    COMPREPLY=( $( compgen -W \
+                        "connected disconnected selectable" -- "$cur" ) )
+                    return 0
+                    ;;
                 *)
                     COMPREPLY=( $( compgen -W "id parent-device parent-pin \
                         module-name clock-id board-label panel-label \
-                        package-label type" \
+                        package-label type direction state" \
                         -- "$cur" ) )
                     return 0
                     ;;
diff --git a/dpll/dpll.c b/dpll/dpll.c
index 634b8fd1976ffd..0afc2b4213180d 100644
--- a/dpll/dpll.c
+++ b/dpll/dpll.c
@@ -162,6 +162,17 @@ static int str_to_dpll_pin_state(const char *state_str, __u32 *state)
 	return 0;
 }
 
+static int str_to_dpll_pin_direction(const char *dir_str, __u32 *direction)
+{
+	int num;
+
+	num = str_map_lookup_str(pin_direction_map, dir_str);
+	if (num < 0)
+		return num;
+	*direction = num;
+	return 0;
+}
+
 static int str_to_dpll_pin_type(const char *type_str, __u32 *type)
 {
 	int num;
@@ -921,6 +932,8 @@ static bool dpll_device_dump_filter(struct dpll_device_filter *filter,
 #define DPLL_FILTER_PIN_TYPE		BIT(5)
 #define DPLL_FILTER_PIN_PARENT_DEVICE	BIT(6)
 #define DPLL_FILTER_PIN_PARENT_PIN	BIT(7)
+#define DPLL_FILTER_PIN_DIRECTION	BIT(8)
+#define DPLL_FILTER_PIN_STATE		BIT(9)
 
 struct dpll_pin_filter {
 	uint64_t present;
@@ -932,6 +945,8 @@ struct dpll_pin_filter {
 	__u32 type;
 	__u32 parent_device_id;
 	__u32 parent_pin_id;
+	__u32 direction;
+	__u32 state;
 };
 
 static bool filter_match_nested_id(const struct nlmsghdr *nlh,
@@ -953,6 +968,39 @@ static bool filter_match_nested_id(const struct nlmsghdr *nlh,
 	return false;
 }
 
+static bool filter_match_nested_parent_device(const struct nlmsghdr *nlh,
+					      struct dpll_pin_filter *filter)
+{
+	const struct nlattr *attr;
+
+	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
+		struct nlattr *tb_nest[DPLL_A_PIN_MAX + 1] = {};
+
+		if (mnl_attr_get_type(attr) != DPLL_A_PIN_PARENT_DEVICE)
+			continue;
+
+		mnl_attr_parse_nested(attr, attr_pin_cb, tb_nest);
+
+		if ((filter->present & DPLL_FILTER_PIN_PARENT_DEVICE) &&
+		    !filter_match_u32(tb_nest[DPLL_A_PIN_PARENT_ID],
+				      filter->parent_device_id))
+			continue;
+
+		if ((filter->present & DPLL_FILTER_PIN_DIRECTION) &&
+		    !filter_match_u32(tb_nest[DPLL_A_PIN_DIRECTION],
+				      filter->direction))
+			continue;
+
+		if ((filter->present & DPLL_FILTER_PIN_STATE) &&
+		    !filter_match_u32(tb_nest[DPLL_A_PIN_STATE],
+				      filter->state))
+			continue;
+
+		return true;
+	}
+	return false;
+}
+
 static bool dpll_pin_dump_filter(struct dpll_pin_filter *filter,
 				 const struct nlmsghdr *nlh,
 				 struct nlattr **tb)
@@ -979,9 +1027,10 @@ static bool dpll_pin_dump_filter(struct dpll_pin_filter *filter,
 	if ((filter->present & DPLL_FILTER_PIN_TYPE) &&
 	    !filter_match_u32(tb[DPLL_A_PIN_TYPE], filter->type))
 		return false;
-	if ((filter->present & DPLL_FILTER_PIN_PARENT_DEVICE) &&
-	    !filter_match_nested_id(nlh, DPLL_A_PIN_PARENT_DEVICE,
-				    filter->parent_device_id))
+	if ((filter->present & (DPLL_FILTER_PIN_PARENT_DEVICE |
+				DPLL_FILTER_PIN_DIRECTION |
+				DPLL_FILTER_PIN_STATE)) &&
+	    !filter_match_nested_parent_device(nlh, filter))
 		return false;
 	if ((filter->present & DPLL_FILTER_PIN_PARENT_PIN) &&
 	    !filter_match_nested_id(nlh, DPLL_A_PIN_PARENT_PIN,
@@ -1892,6 +1941,22 @@ static int cmd_pin_show(struct dpll *dpll)
 						   str_to_dpll_pin_type,
 						   "mux/ext/synce-eth-port/int-oscillator/gnss"))
 				return -EINVAL;
+		} else if (dpll_argv_match(dpll, "direction")) {
+			if (dpll_filter_parse_enum(dpll, "direction",
+						   &filter.direction,
+						   &filter.present,
+						   DPLL_FILTER_PIN_DIRECTION,
+						   str_to_dpll_pin_direction,
+						   "input/output"))
+				return -EINVAL;
+		} else if (dpll_argv_match(dpll, "state")) {
+			if (dpll_filter_parse_enum(dpll, "state",
+						   &filter.state,
+						   &filter.present,
+						   DPLL_FILTER_PIN_STATE,
+						   str_to_dpll_pin_state,
+						   "connected/disconnected/selectable"))
+				return -EINVAL;
 		} else {
 			pr_err("unknown option: %s\n", dpll_argv(dpll));
 			return -EINVAL;
diff --git a/man/man8/dpll.8 b/man/man8/dpll.8
index 479e5ed9871eeb..4213ae7a494fb8 100644
--- a/man/man8/dpll.8
+++ b/man/man8/dpll.8
@@ -169,7 +169,7 @@ Device type:
 
 .SH PIN COMMANDS
 
-.SS dpll pin show [ id ID ] [ parent-device DEVICE_ID ] [ parent-pin PIN_ID ] [ module-name NAME ] [ clock-id ID ] [ board-label LABEL ] [ panel-label LABEL ] [ package-label LABEL ] [ type TYPE ]
+.SS dpll pin show [ id ID ] [ parent-device DEVICE_ID ] [ parent-pin PIN_ID ] [ module-name NAME ] [ clock-id ID ] [ board-label LABEL ] [ panel-label LABEL ] [ package-label LABEL ] [ type TYPE ] [ direction DIR ] [ state STATE ]
 
 Display information about DPLL pins. If no arguments are specified,
 shows all pins in the system.
@@ -211,6 +211,22 @@ Show only pins with the specified package label.
 Show only pins of the specified type:
 .BR mux ", " ext ", " synce-eth-port ", " int-oscillator ", " gnss .
 
+.TP
+.BI direction " DIR"
+Show only pins that have a parent-device relationship with the specified direction:
+.BR input ", " output .
+When combined with
+.BR parent-device ,
+only the specified parent-device relationship is checked.
+
+.TP
+.BI state " STATE"
+Show only pins that have a parent-device relationship with the specified state:
+.BR connected ", " disconnected ", " selectable .
+When combined with
+.BR parent-device ,
+only the specified parent-device relationship is checked.
+
 .PP
 Output includes:
 .RS
@@ -401,6 +417,11 @@ Press Ctrl+C to stop monitoring.
 .B dpll -jp pin show id 5
 .fi
 
+.SS Show connected input pins on device 0
+.nf
+.B dpll pin show parent-device 0 direction input state connected
+.fi
+
 .SS Set pin frequency to 10 MHz
 .nf
 .B dpll pin set id 0 frequency 10000000
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2-next] dpll: add direction and state filtering for pin show
  2026-03-31 13:59 [PATCH iproute2-next] dpll: add direction and state filtering for pin show Petr Oros
@ 2026-03-31 14:07 ` Ivan Vecera
  2026-04-05 16:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Ivan Vecera @ 2026-03-31 14:07 UTC (permalink / raw)
  To: Petr Oros, netdev; +Cc: dsahern, stephen

On 3/31/26 3:59 PM, Petr Oros wrote:
> Allow filtering pins by direction (input/output) and state
> (connected/disconnected/selectable) in the pin show command.
> These filters match against parent-device nested attributes and
> can be combined with the parent-device filter to check a specific
> parent-device relationship.
> 
> Example: dpll pin show parent-device 0 direction input state connected
> Signed-off-by: Petr Oros <poros@redhat.com>
> ---
>   bash-completion/dpll | 11 ++++++-
>   dpll/dpll.c          | 71 ++++++++++++++++++++++++++++++++++++++++++--
>   man/man8/dpll.8      | 23 +++++++++++++-
>   3 files changed, 100 insertions(+), 5 deletions(-)
> 
> diff --git a/bash-completion/dpll b/bash-completion/dpll
> index 5913c894dda96e..981c3edbf367b0 100644
> --- a/bash-completion/dpll
> +++ b/bash-completion/dpll
> @@ -185,10 +185,19 @@ _dpll_pin()
>                           int-oscillator gnss" -- "$cur" ) )
>                       return 0
>                       ;;
> +                direction)
> +                    COMPREPLY=( $( compgen -W "input output" -- "$cur" ) )
> +                    return 0
> +                    ;;
> +                state)
> +                    COMPREPLY=( $( compgen -W \
> +                        "connected disconnected selectable" -- "$cur" ) )
> +                    return 0
> +                    ;;
>                   *)
>                       COMPREPLY=( $( compgen -W "id parent-device parent-pin \
>                           module-name clock-id board-label panel-label \
> -                        package-label type" \
> +                        package-label type direction state" \
>                           -- "$cur" ) )
>                       return 0
>                       ;;
> diff --git a/dpll/dpll.c b/dpll/dpll.c
> index 634b8fd1976ffd..0afc2b4213180d 100644
> --- a/dpll/dpll.c
> +++ b/dpll/dpll.c
> @@ -162,6 +162,17 @@ static int str_to_dpll_pin_state(const char *state_str, __u32 *state)
>   	return 0;
>   }
>   
> +static int str_to_dpll_pin_direction(const char *dir_str, __u32 *direction)
> +{
> +	int num;
> +
> +	num = str_map_lookup_str(pin_direction_map, dir_str);
> +	if (num < 0)
> +		return num;
> +	*direction = num;
> +	return 0;
> +}
> +
>   static int str_to_dpll_pin_type(const char *type_str, __u32 *type)
>   {
>   	int num;
> @@ -921,6 +932,8 @@ static bool dpll_device_dump_filter(struct dpll_device_filter *filter,
>   #define DPLL_FILTER_PIN_TYPE		BIT(5)
>   #define DPLL_FILTER_PIN_PARENT_DEVICE	BIT(6)
>   #define DPLL_FILTER_PIN_PARENT_PIN	BIT(7)
> +#define DPLL_FILTER_PIN_DIRECTION	BIT(8)
> +#define DPLL_FILTER_PIN_STATE		BIT(9)
>   
>   struct dpll_pin_filter {
>   	uint64_t present;
> @@ -932,6 +945,8 @@ struct dpll_pin_filter {
>   	__u32 type;
>   	__u32 parent_device_id;
>   	__u32 parent_pin_id;
> +	__u32 direction;
> +	__u32 state;
>   };
>   
>   static bool filter_match_nested_id(const struct nlmsghdr *nlh,
> @@ -953,6 +968,39 @@ static bool filter_match_nested_id(const struct nlmsghdr *nlh,
>   	return false;
>   }
>   
> +static bool filter_match_nested_parent_device(const struct nlmsghdr *nlh,
> +					      struct dpll_pin_filter *filter)
> +{
> +	const struct nlattr *attr;
> +
> +	mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
> +		struct nlattr *tb_nest[DPLL_A_PIN_MAX + 1] = {};
> +
> +		if (mnl_attr_get_type(attr) != DPLL_A_PIN_PARENT_DEVICE)
> +			continue;
> +
> +		mnl_attr_parse_nested(attr, attr_pin_cb, tb_nest);
> +
> +		if ((filter->present & DPLL_FILTER_PIN_PARENT_DEVICE) &&
> +		    !filter_match_u32(tb_nest[DPLL_A_PIN_PARENT_ID],
> +				      filter->parent_device_id))
> +			continue;
> +
> +		if ((filter->present & DPLL_FILTER_PIN_DIRECTION) &&
> +		    !filter_match_u32(tb_nest[DPLL_A_PIN_DIRECTION],
> +				      filter->direction))
> +			continue;
> +
> +		if ((filter->present & DPLL_FILTER_PIN_STATE) &&
> +		    !filter_match_u32(tb_nest[DPLL_A_PIN_STATE],
> +				      filter->state))
> +			continue;
> +
> +		return true;
> +	}
> +	return false;
> +}
> +
>   static bool dpll_pin_dump_filter(struct dpll_pin_filter *filter,
>   				 const struct nlmsghdr *nlh,
>   				 struct nlattr **tb)
> @@ -979,9 +1027,10 @@ static bool dpll_pin_dump_filter(struct dpll_pin_filter *filter,
>   	if ((filter->present & DPLL_FILTER_PIN_TYPE) &&
>   	    !filter_match_u32(tb[DPLL_A_PIN_TYPE], filter->type))
>   		return false;
> -	if ((filter->present & DPLL_FILTER_PIN_PARENT_DEVICE) &&
> -	    !filter_match_nested_id(nlh, DPLL_A_PIN_PARENT_DEVICE,
> -				    filter->parent_device_id))
> +	if ((filter->present & (DPLL_FILTER_PIN_PARENT_DEVICE |
> +				DPLL_FILTER_PIN_DIRECTION |
> +				DPLL_FILTER_PIN_STATE)) &&
> +	    !filter_match_nested_parent_device(nlh, filter))
>   		return false;
>   	if ((filter->present & DPLL_FILTER_PIN_PARENT_PIN) &&
>   	    !filter_match_nested_id(nlh, DPLL_A_PIN_PARENT_PIN,
> @@ -1892,6 +1941,22 @@ static int cmd_pin_show(struct dpll *dpll)
>   						   str_to_dpll_pin_type,
>   						   "mux/ext/synce-eth-port/int-oscillator/gnss"))
>   				return -EINVAL;
> +		} else if (dpll_argv_match(dpll, "direction")) {
> +			if (dpll_filter_parse_enum(dpll, "direction",
> +						   &filter.direction,
> +						   &filter.present,
> +						   DPLL_FILTER_PIN_DIRECTION,
> +						   str_to_dpll_pin_direction,
> +						   "input/output"))
> +				return -EINVAL;
> +		} else if (dpll_argv_match(dpll, "state")) {
> +			if (dpll_filter_parse_enum(dpll, "state",
> +						   &filter.state,
> +						   &filter.present,
> +						   DPLL_FILTER_PIN_STATE,
> +						   str_to_dpll_pin_state,
> +						   "connected/disconnected/selectable"))
> +				return -EINVAL;
>   		} else {
>   			pr_err("unknown option: %s\n", dpll_argv(dpll));
>   			return -EINVAL;
> diff --git a/man/man8/dpll.8 b/man/man8/dpll.8
> index 479e5ed9871eeb..4213ae7a494fb8 100644
> --- a/man/man8/dpll.8
> +++ b/man/man8/dpll.8
> @@ -169,7 +169,7 @@ Device type:
>   
>   .SH PIN COMMANDS
>   
> -.SS dpll pin show [ id ID ] [ parent-device DEVICE_ID ] [ parent-pin PIN_ID ] [ module-name NAME ] [ clock-id ID ] [ board-label LABEL ] [ panel-label LABEL ] [ package-label LABEL ] [ type TYPE ]
> +.SS dpll pin show [ id ID ] [ parent-device DEVICE_ID ] [ parent-pin PIN_ID ] [ module-name NAME ] [ clock-id ID ] [ board-label LABEL ] [ panel-label LABEL ] [ package-label LABEL ] [ type TYPE ] [ direction DIR ] [ state STATE ]
>   
>   Display information about DPLL pins. If no arguments are specified,
>   shows all pins in the system.
> @@ -211,6 +211,22 @@ Show only pins with the specified package label.
>   Show only pins of the specified type:
>   .BR mux ", " ext ", " synce-eth-port ", " int-oscillator ", " gnss .
>   
> +.TP
> +.BI direction " DIR"
> +Show only pins that have a parent-device relationship with the specified direction:
> +.BR input ", " output .
> +When combined with
> +.BR parent-device ,
> +only the specified parent-device relationship is checked.
> +
> +.TP
> +.BI state " STATE"
> +Show only pins that have a parent-device relationship with the specified state:
> +.BR connected ", " disconnected ", " selectable .
> +When combined with
> +.BR parent-device ,
> +only the specified parent-device relationship is checked.
> +
>   .PP
>   Output includes:
>   .RS
> @@ -401,6 +417,11 @@ Press Ctrl+C to stop monitoring.
>   .B dpll -jp pin show id 5
>   .fi
>   
> +.SS Show connected input pins on device 0
> +.nf
> +.B dpll pin show parent-device 0 direction input state connected
> +.fi
> +
>   .SS Set pin frequency to 10 MHz
>   .nf
>   .B dpll pin set id 0 frequency 10000000

Hi Petr,
thanks for this!

Tested-by: Ivan Vecera <ivecera@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2-next] dpll: add direction and state filtering for pin show
  2026-03-31 13:59 [PATCH iproute2-next] dpll: add direction and state filtering for pin show Petr Oros
  2026-03-31 14:07 ` Ivan Vecera
@ 2026-04-05 16:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-04-05 16:30 UTC (permalink / raw)
  To: Petr Oros; +Cc: netdev, dsahern, stephen, ivecera

Hello:

This patch was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Tue, 31 Mar 2026 15:59:18 +0200 you wrote:
> Allow filtering pins by direction (input/output) and state
> (connected/disconnected/selectable) in the pin show command.
> These filters match against parent-device nested attributes and
> can be combined with the parent-device filter to check a specific
> parent-device relationship.
> 
> Example: dpll pin show parent-device 0 direction input state connected
> Signed-off-by: Petr Oros <poros@redhat.com>
> 
> [...]

Here is the summary with links:
  - [iproute2-next] dpll: add direction and state filtering for pin show
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=90a9c94bdb79

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-05 16:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 13:59 [PATCH iproute2-next] dpll: add direction and state filtering for pin show Petr Oros
2026-03-31 14:07 ` Ivan Vecera
2026-04-05 16:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox