public inbox for patches@ignore.pl
 help / color / mirror / Atom feed
* [PATCH what RFC] ice: implement support for 0x0601 opcode
@ 2025-11-20 10:53 Dawid Osuchowski
  2025-11-20 11:23 ` Aki
  0 siblings, 1 reply; 2+ messages in thread
From: Dawid Osuchowski @ 2025-11-20 10:53 UTC (permalink / raw)
  To: patches; +Cc: Dawid Osuchowski

Signed-off-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
---
PHY Type support is a little wonky and based on 0x0607, but I wanted to get this patch out for comments.
---
 samples/linux_0601.log      |  12 ++
 what/ice/opcodes/0x0601.lua | 238 ++++++++++++++++++++++++++++++++++++
 2 files changed, 250 insertions(+)
 create mode 100644 samples/linux_0601.log
 create mode 100644 what/ice/opcodes/0x0601.lua

diff --git a/samples/linux_0601.log b/samples/linux_0601.log
new file mode 100644
index 000000000000..23dee128ff59
--- /dev/null
+++ b/samples/linux_0601.log
@@ -0,0 +1,12 @@
+[    5.000000] ice 0000:01:00.0: AQ Command: opcode 0x0601, flags 0x3400, datalen 0x0018, retval 0x0000
+	cookie (h,l) 0x00000000 0x00000000
+	param (0,1)  0x00000000 0x00000000
+	addr (h,l)   0x00000004 0x3CB75000
+[    5.000000] ice 0x00000004 0x3CB75000 00000000: 00 40 80 00 00 00 00 00 00 00 00 00 00 00 00 00
+[    5.000000] ice 0x00000004 0x3CB75000 00000010: e0 00 00 00 00 00 04 00
+[    5.000000] ice 0000:01:00.0: AQ Response: opcode 0x0601, flags 0x3403, datalen 0x0018, retval 0x0000
+	cookie (h,l) 0x00000000 0x00000000
+	param (0,1)  0x00000000 0x00000000
+	addr (h,l)   0x00000004 0x3CB75000
+[    5.000000] ice 0x00000004 0x3CB75000 00000000: 00 40 80 00 00 00 00 00 00 00 00 00 00 00 00 00
+[    5.000000] ice 0x00000004 0x3CB75000 00000010: e0 00 00 00 00 00 04 00
diff --git a/what/ice/opcodes/0x0601.lua b/what/ice/opcodes/0x0601.lua
new file mode 100644
index 000000000000..e53c51005617
--- /dev/null
+++ b/what/ice/opcodes/0x0601.lua
@@ -0,0 +1,238 @@
+local blobs = require "what.blobs"
+local bits = require "what.bits"
+local flags = require "what.ice.flags"
+local bit = bits.bit
+local set_phy_config = {}
+local dump = [[
+---
+opcode: 0x0601 (Set PHY Config)
+kind: %s %s
+flags: %s
+retval: 0x%x
+cookie: 0x%08x 0x%08x
+%s...]]
+
+
+function set_phy_config:dump ()
+	return dump:format(
+		self.queue, self.kind,
+		flags.dump(self.flags),
+		self.retval,
+		self.cookie_h, self.cookie_l,
+		self:dump_indirect_buffer())
+end
+
+
+--- 3.3.3.2.1 Extended PHY Capabilities 128-Bit Word Structure[E810]
+--- Table 3-90. 128-Bit Word Extended PHY Capabilities[E810]
+local extended_phy_capabilities = {
+	-- Word[0]:
+	"100BASE-TX",
+	"100M-SGMII",
+	"1000BASE-T",
+	"1000BASE-SX",
+	"1000BASE-LX",
+	"1000BASE-KX",
+	"1G-SGMII",
+	nil,  -- Reserved
+	nil,
+	nil,
+	"5GBASE-T",
+	"5GBASE-KR",
+	nil,
+	"10G-SFI-DA",
+	"10GBASE-SR",
+	"10GBASE-LR",
+	"10GBASE-KR",
+	"10G-SFI-AOC/ACC",
+	"10G-SFI-C2C",
+	nil,
+	"25GBASE-CR",
+	"25GBASE-CR-S",
+	"25GBASE-CR1",
+	"25GBASE-SR",
+	"25GBASE-LR",
+	"25GBASE-KR",
+	"25GBASE-KR-S",
+	"25GBASE-KR1",
+	"25G-AUI-AOC/ACC",
+	"25G-AUI-C2C",
+	nil,
+	nil,
+	-- Word[1]:
+	nil,
+	nil,
+	nil,
+	nil,
+	"50GBASE-CR2",
+	"50G-LAUI2-AOC/ACC w/CL133 PCS",
+	"50G-LAUI2 w/CL133 PCS",
+	"50GBASE-KR2",
+	"50G-LAUI2-AOC/ACC",
+	"50G-LAUI2",
+	"50G-AUI2-AOC/ACC",
+	"50G-AUI2",
+	"50GBASE-CP",
+	"50GBASE-SR",
+	"50GBASE-FR",
+	"50GBASE-LR",
+	"50GBASE-KR-PAM4",
+	"50G-AUI1-AOC/ACC",
+	"50G-AUI1",
+	"100GBASE-CR4",
+	"100GBASE-SR4",
+	"100GBASE-LR4",
+	"100GBASE-KR4",
+	"100G-CAUI4-AOC/ACC",
+	"100G-CAUI4",
+	"100G-AUI4-AOC/ACC",
+	"100G-AUI4",
+	"100GBASE-DR [CAUI4]",
+	"100GBASE-KR4-PAM4",
+	"100GBASE-CR2",
+	"100GBASE-SR2",
+	"100GBASE-DR [AUI2]",
+	-- Word[2]:
+	"100GBASE-KR2-PAM4",
+	nil,
+	nil,
+	"100G-AUI2-AOC/ACC",
+	"100G-AUI2",
+	"100GBASE-CR1",
+	"100GBASE-KR1",
+	"100GBASE-SR1[30m]",
+	"100GBASE-SR1[100m]",
+	"100GBASE-LR",
+	"100GBASE-FR",
+	"100GBASE-DR [AUI1]",
+	"100GBASE-AUI1-AOC/ACC",
+	"100G-AUI1-C2C",
+	"200G-AUI8-AOC/ACC",
+	"200G-AUI8",
+	"200GBASE-CR4-PAM4",
+	"200GBASE-SR4",
+	"200GBASE-FR4",
+	"200GBASE-LR4",
+	"200GBASE-DR4",
+	"200GBASE-KR4-PAM4",
+	"200G-AUI4-AOC/ACC",
+	"200G-AUI4",
+	"200G-CR2",
+	"200GBASE-KR2",
+	"200GBASE-SR2[30m]",
+	"200GBASE-SR2[100m]",
+	"200GBASE-DR2",
+	"200GBASE-AUI2-AOC/ACC",
+	"200G-AUI2-C2C",
+	nil,
+	-- Word[3]: every bit is Reserved
+}
+
+
+local
+function bit_list (entries, count, offset)
+	offset = offset or 0
+	local list = {}
+	for i=1,count do
+		list[i] = entries[offset + i]
+	end
+	return bits.list(list)
+end
+
+
+--- Table 3-28. Set PHY Config Command Data Structure[E810]
+local indirect_buffer = blobs.new {
+	-- TODO: Consider handling >8 bytes in one range definition.
+	-- TODO: Consider supporting default value if lookup fails
+	["0.0-3.7"] = blobs.insert_if_empty("PHY Type", bit_list(extended_phy_capabilities, 32)),
+	["4.0-7.7"] = blobs.insert_if_empty("PHY Type", bit_list(extended_phy_capabilities, 32, 32)),
+	["8.0-11.7"] = blobs.insert_if_empty("PHY Type", bit_list(extended_phy_capabilities, 32, 64)),
+	["12.0-15.7"] = blobs.insert_if_empty("PHY Type", bit_list(extended_phy_capabilities, 32, 96)),
+	["16.0-16.1"] = blobs.list "Pause Ability" {
+		"Enable Tx Link Pause",
+		"Enable Rx Link Pause",
+		neither = "Tx and Rx Disabled",
+	},
+	["16.2"] = blobs.toggle "Power Mode" {
+		[0] = "High Power Mode",
+		[1] = "Low Power Mode",
+	},
+	["16.3"] = blobs.yes_no "Enable Link",
+	["16.5"] = blobs.yes_no "Enable Automatic Link Update",
+	["16.6"] = blobs.yes_no "LESM Enable",
+	["16.7"] = blobs.yes_no "Auto FEC Enable",
+	["17.0-17.3"] = blobs.list "Low Power Control" {
+		"Enable D3cold low power auto-negotiation",
+		nil,  -- Reserved
+		nil,  -- Reserved
+		"AN37 enabled on 1G links",
+		neither = "D3cold and AN37 disabled",
+	},
+	["18.0-19.2"] = blobs.list "EEE Capability Enable" {
+		"100BASE-TX",
+		"1000BASE-T",
+		"10GBASE-T",
+		"1000BASE-KX",
+		"10GBASE-KR",
+		"25GBASE-KR",
+		"50GBASE-KR2",
+		"50GBASE-KR-PAM4",
+		"100GBASE-KR4",
+		"100GBASE-KR2-PAM4",
+		neither = "Disabled",
+	},
+	["20.0-21.7"] = blobs.hexadecimal "EEER Value",
+	["22.0-22.7"] = blobs.list "Link FEC Options" {
+		"FIRE_CODE_10_ABILITY Enable",
+		"FIRE_CODE_10_REQUEST",
+		"RS_528_REQUEST",
+		"FIRE_CODE_25_REQUEST",
+		"RS_544_REQUEST",
+		"No FEC",
+		"RS_528_ABILITY",
+		"FIRE_CODE_25_ABILITY",
+		neither = "None",
+	},
+	["23.0"] = blobs.toggle "Module Compliance Enforcement" {
+		[0] = "Lenient",
+		[1] = "Strict",
+	},
+}
+local order = {
+	"PHY Type",
+	"Pause Ability",
+	"Power Mode",
+	"Enable Link",
+	"Enable Automatic Link Update",
+	"LESM Enable",
+	"Auto FEC Enable",
+	"Low Power Control",
+	"EEE Capability Enable",
+	"EEER Value",
+	"Link FEC Options",
+	"Module Compliance Enforcement",
+}
+
+
+function set_phy_config:dump_indirect_buffer ()
+	local str = ""
+	local result = indirect_buffer({}, self.buffer)
+	for _, key in ipairs(order) do
+		local value = result[key]
+		if value then
+			str = str .. key .. ":"
+			if type(value) == "string" then
+				str = string.format("%s %s", str, value)
+			elseif type(value) == "table" then
+				for _, x in ipairs(value) do
+					str = str .. "\n  - " .. x
+				end
+			end
+			str = str .. "\n"
+		end
+	end
+	return str
+end
+
+
+return set_phy_config
-- 
2.51.0


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

* Re: [PATCH what RFC] ice: implement support for 0x0601 opcode
  2025-11-20 10:53 [PATCH what RFC] ice: implement support for 0x0601 opcode Dawid Osuchowski
@ 2025-11-20 11:23 ` Aki
  0 siblings, 0 replies; 2+ messages in thread
From: Aki @ 2025-11-20 11:23 UTC (permalink / raw)
  To: Dawid Osuchowski; +Cc: patches

On 20/11/2025 11:53, Dawid Osuchowski wrote:
> Signed-off-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
> ---
> PHY Type support is a little wonky and based on 0x0607, but I wanted to get this patch out for comments.

Of course.  Thank you for sending a patch.

> ---
>   samples/linux_0601.log      |  12 ++
>   what/ice/opcodes/0x0601.lua | 238 ++++++++++++++++++++++++++++++++++++
>   2 files changed, 250 insertions(+)
>   create mode 100644 samples/linux_0601.log
>   create mode 100644 what/ice/opcodes/0x0601.lua
> 
> diff --git a/samples/linux_0601.log b/samples/linux_0601.log
> new file mode 100644
> index 000000000000..23dee128ff59
> --- /dev/null
> +++ b/samples/linux_0601.log
> @@ -0,0 +1,12 @@
> +[    5.000000] ice 0000:01:00.0: AQ Command: opcode 0x0601, flags 0x3400, datalen 0x0018, retval 0x0000
> +	cookie (h,l) 0x00000000 0x00000000
> +	param (0,1)  0x00000000 0x00000000
> +	addr (h,l)   0x00000004 0x3CB75000
> +[    5.000000] ice 0x00000004 0x3CB75000 00000000: 00 40 80 00 00 00 00 00 00 00 00 00 00 00 00 00
> +[    5.000000] ice 0x00000004 0x3CB75000 00000010: e0 00 00 00 00 00 04 00
> +[    5.000000] ice 0000:01:00.0: AQ Response: opcode 0x0601, flags 0x3403, datalen 0x0018, retval 0x0000
> +	cookie (h,l) 0x00000000 0x00000000
> +	param (0,1)  0x00000000 0x00000000
> +	addr (h,l)   0x00000004 0x3CB75000
> +[    5.000000] ice 0x00000004 0x3CB75000 00000000: 00 40 80 00 00 00 00 00 00 00 00 00 00 00 00 00
> +[    5.000000] ice 0x00000004 0x3CB75000 00000010: e0 00 00 00 00 00 04 00

I think we can append to samples/$platform.log for now.  In the long
run, I think having the same directory tree structure under samples/
as in what/.  As in: 0x0601.log would be in samples/ice/opcodes/; but
there is very little stuff available now, plus this was before I started
tinkering with multiple platforms.

Append it to samples/linux.log for now.

The gist is we want

$ make test

to smoke everything that's available.

> diff --git a/what/ice/opcodes/0x0601.lua b/what/ice/opcodes/0x0601.lua
> new file mode 100644
> index 000000000000..e53c51005617
> --- /dev/null
> +++ b/what/ice/opcodes/0x0601.lua
> @@ -0,0 +1,238 @@
> +local blobs = require "what.blobs"
> +local bits = require "what.bits"
> +local flags = require "what.ice.flags"
> +local bit = bits.bit

bit is unused.  Remove it, please.

> +local set_phy_config = {}
> +local dump = [[
> +---
> +opcode: 0x0601 (Set PHY Config)
> +kind: %s %s
> +flags: %s
> +retval: 0x%x
> +cookie: 0x%08x 0x%08x
> +%s...]]
> +
> +
> +function set_phy_config:dump ()
> +	return dump:format(
> +		self.queue, self.kind,
> +		flags.dump(self.flags),
> +		self.retval,
> +		self.cookie_h, self.cookie_l,
> +		self:dump_indirect_buffer())
> +end

Yeah, comment for myself to reduce the code duplication opcodes
boilerplate generates.

> +
> +
> +--- 3.3.3.2.1 Extended PHY Capabilities 128-Bit Word Structure[E810]
> +--- Table 3-90. 128-Bit Word Extended PHY Capabilities[E810]
> +local extended_phy_capabilities = {
> +	-- Word[0]:
> +	"100BASE-TX",
> +	"100M-SGMII",

...

> +	"200G-AUI2-C2C",
> +	nil,
> +	-- Word[3]: every bit is Reserved
> +}

Can you move this to what.ice.extended_phy_capabilities and require it
here and in 0x0607 in a separate patch.  Can be in a series.

> +

...

> +--- Table 3-28. Set PHY Config Command Data Structure[E810]
> +local indirect_buffer = blobs.new {
> +	-- TODO: Consider handling >8 bytes in one range definition.
> +	-- TODO: Consider supporting default value if lookup fails
> +	["0.0-3.7"] = blobs.insert_if_empty("PHY Type", bit_list(extended_phy_capabilities, 32)),
> +	["4.0-7.7"] = blobs.insert_if_empty("PHY Type", bit_list(extended_phy_capabilities, 32, 32)),
> +	["8.0-11.7"] = blobs.insert_if_empty("PHY Type", bit_list(extended_phy_capabilities, 32, 64)),
> +	["12.0-15.7"] = blobs.insert_if_empty("PHY Type", bit_list(extended_phy_capabilities, 32, 96)),

This will not work as expected.  We need something like:

	["0.0-3.7"] = blobs.concat("PHY Type", bit_list(...)),

That would concatenate lists together (or: "append" at the end of
lists/strings).  This does not need a resolution from your side, if you
address comments above but skip this, I'll merge this and work on this
myself since this could be tricky (as in: super Lua-specific).

> +	["16.0-16.1"] = blobs.list "Pause Ability" {

...

> +		[1] = "Strict",
> +	},
> +}

Note to self to cross-check this with datasheet in v2.

Thanks again!

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

end of thread, other threads:[~2025-11-20 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-20 10:53 [PATCH what RFC] ice: implement support for 0x0601 opcode Dawid Osuchowski
2025-11-20 11:23 ` Aki

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