hw/net/imx_fec: return 0xffff when accessing non-existing PHY
PATCH 1/1 hw/net/imx_fec: return 0xffff when accessing non-existing PHY
If a PHY does not exist, attempts to read from it should return 0xffff. Otherwise the Linux kernel will believe that a PHY is there and select the non-existing PHY. This in turn will result in network errors later on since the real PHY is not selected or configured.
Since reading from or writing to a non-existing PHY is not an emulation error, replace guest error messages with traces.
--- hw/net/imx_fec.c | 8 +++----- hw/net/trace-events | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-)
hw/net/imx_fec.c +3 -5
@@ -283,9 +283,8 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); -return 0 ; +trace_imx_phy_read_num (phy, s->phy_num); +return 0xffff ; } reg %=32 ;
@@ -345,8 +344,7 @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); +trace_imx_phy_write_num (phy, s->phy_num);return ; }
hw/net/trace-events +2 -0
@@ -413,8 +413,10 @@ i82596_set_multicast(uint16_t count) "Added %d multicast entries" i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION" # imx_fec.c +imx_phy_read_num(int phy, int configured) "read request from unconfigured phy %d (configured %d)" imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <= phy[%d].reg[%d]" imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" => phy[%d].reg[%d]" +imx_phy_write_num(int phy, int configured) "write request to unconfigured phy %d (configured %d)" imx_phy_update_link(const char *s) "%s" imx_phy_reset(void) "" imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x"
Signature · 1 line
2.25.1
Quoted 48 lines · Guenter Roeck
If a PHY does not exist, attempts to read from it should return
0xffff. Otherwise the Linux kernel will believe that a PHY is there and select the non-existing PHY. This in turn will result in network errors later on since the real PHY is not selected or configured.Since reading from or writing to a non-existing PHY is not an emulation error, replace guest error messages with traces.
Fixes 461c51ad4275 ("Add a phy-num property to the i.MX FEC emulator")Cc Jean-Christophe Dubois <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- hw/net/imx_fec.c | 8 +++----- hw/net/trace-events | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-)hw/net/imx_fec.c +3
-5@@ -283,9 +283,8 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); -return 0 ; +trace_imx_phy_read_num (phy, s->phy_num); +return 0xffff ; } reg %=32 ;@@ -345,8 +344,7 @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); +trace_imx_phy_write_num (phy, s->phy_num);return ; }hw/net/trace-events +0
-0
hw/net/trace-events i82596_set_multicast(uint16_t count) "Added %d multicast entries" · line 416
Quoted 4 lines
hw/net/trace-events +1
-0@@ -413,8 +413,10 @@ i82596_set_multicast(uint16_t count) "Added %d multicast entries" i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION" # imx_fec.c +imx_phy_read_num(int phy, int configured) "read request from unconfigured phy %d (configured %d)"
nits: could we put this below imx_phy_read(), like you put imx_phy_write_num after imx_phy_write?
hw/net/trace-events i82596_set_multicast(uint16_t count) "Added %d multicast entries"
Quoted 7 lines
hw/net/trace-events +1
-1imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <= phy[%d].reg[%d]" imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" => phy[%d].reg[%d]" +imx_phy_write_num(int phy, int configured) "write request to unconfigured phy %d (configured %d)" imx_phy_update_link(const char *s) "%s" imx_phy_reset(void) "" imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x" --
Otherwise,
Quoted 51 lines · Bin Meng
Quoted 50 lines · Guenter Roeck
If a PHY does not exist, attempts to read from it should return
0xffff. Otherwise the Linux kernel will believe that a PHY is there and select the non-existing PHY. This in turn will result in network errors later on since the real PHY is not selected or configured.Since reading from or writing to a non-existing PHY is not an emulation error, replace guest error messages with traces.
Fixes 461c51ad4275 ("Add a phy-num property to the i.MX FEC emulator")Cc Jean-Christophe Dubois <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- hw/net/imx_fec.c | 8 +++----- hw/net/trace-events | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-)hw/net/imx_fec.c +3
-5@@ -283,9 +283,8 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); -return 0 ; +trace_imx_phy_read_num (phy, s->phy_num); +return 0xffff ; } reg %=32 ;@@ -345,8 +344,7 @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); +trace_imx_phy_write_num (phy, s->phy_num);return ; }hw/net/trace-events +0
-0@@ -413,8 +413,10 @@ i82596_set_multicast(uint16_t count) "Added %d multicast entries" i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION"
Quoted 6 lines
hw/net/trace-events i82596_set_multicast(uint16_t count) "Added %d multicast entries" · line 416
Quoted 2 lines
hw/net/trace-events +1
-0# imx_fec.c +imx_phy_read_num(int phy, int configured) "read request from unconfigured phy %d (configured %d)"nits: could we put this below
imx_phy_read(), like you putimx_phy_write_numafterimx_phy_write?
Sure, makes sense. I'll wait a bit for other feedback and then resend.
Quoted 8 lines
hw/net/trace-events i82596_set_multicast(uint16_t count) "Added %d multicast entries"
Quoted 7 lines
hw/net/trace-events +1
-1imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <= phy[%d].reg[%d]" imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" => phy[%d].reg[%d]" +imx_phy_write_num(int phy, int configured) "write request to unconfigured phy %d (configured %d)" imx_phy_update_link(const char *s) "%s" imx_phy_reset(void) "" imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x" --
Quoted 4 lines
Otherwise,
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
Thanks!
Guenter
Quoted 51 lines · Guenter Roeck
Quoted 50 lines · Bin Meng
Quoted 49 lines · Guenter Roeck
If a PHY does not exist, attempts to read from it should return
0xffff. Otherwise the Linux kernel will believe that a PHY is there and select the non-existing PHY. This in turn will result in network errors later on since the real PHY is not selected or configured.Since reading from or writing to a non-existing PHY is not an emulation error, replace guest error messages with traces.
Fixes 461c51ad4275 ("Add a phy-num property to the i.MX FEC emulator")Cc Jean-Christophe Dubois <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- hw/net/imx_fec.c | 8 +++----- hw/net/trace-events | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-)hw/net/imx_fec.c +3
-5@@ -283,9 +283,8 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); -return 0 ; +trace_imx_phy_read_num (phy, s->phy_num); +return 0xffff ; } reg %=32 ;@@ -345,8 +344,7 @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); +trace_imx_phy_write_num (phy, s->phy_num);return ; }hw/net/trace-events +0
-0@@ -413,8 +413,10 @@ i82596_set_multicast(uint16_t count) "Added %d multicast entries" i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION"
Quoted 6 lines
Quoted 5 lines
hw/net/trace-events i82596_set_multicast(uint16_t count) "Added %d multicast entries" · line 416
Quoted 2 lines
hw/net/trace-events +1
-0# imx_fec.c +imx_phy_read_num(int phy, int configured) "read request from unconfigured phy %d (configured %d)"nits: could we put this below
imx_phy_read(), like you putimx_phy_write_numafterimx_phy_write?Sure, makes sense. I'll wait a bit for other feedback and then resend.
Ok, please send V2.
Thanks
Quoted 16 lines
Quoted 8 lines
hw/net/trace-events i82596_set_multicast(uint16_t count) "Added %d multicast entries"
Quoted 8 lines
hw/net/trace-events +1
-1imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <= phy[%d].reg[%d]" imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" => phy[%d].reg[%d]" +imx_phy_write_num(int phy, int configured) "write request to unconfigured phy %d (configured %d)" imx_phy_update_link(const char *s) "%s" imx_phy_reset(void) "" imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x" --Quoted 4 lines
Otherwise,
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>Thanks!
Guenter
On Thu, May 06, 2021 at 10:24:52AM +0800, Jason Wang wrote:
[ ... ]
Quoted 2 lines
Ok, please send V2.
You should have it by now. Please let me know if it got lost.
Thanks,
Guenter
Quoted 8 lines · Guenter Roeck
If a PHY does not exist, attempts to read from it should return
0xffff. Otherwise the Linux kernel will believe that a PHY is there and select the non-existing PHY. This in turn will result in network errors later on since the real PHY is not selected or configured.Since reading from or writing to a non-existing PHY is not an emulation error, replace guest error messages with traces.
Quoted 7 lines
Fixes 461c51ad4275 ("Add a phy-num property to the i.MX FEC emulator")Cc Jean-Christophe Dubois <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- hw/net/imx_fec.c | 8 +++----- hw/net/trace-events | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-)
Jason Wang
AppliedQuoted 11 lines · Guenter Roeck
If a PHY does not exist, attempts to read from it should return
0xffff. Otherwise the Linux kernel will believe that a PHY is there and select the non-existing PHY. This in turn will result in network errors later on since the real PHY is not selected or configured.Since reading from or writing to a non-existing PHY is not an emulation error, replace guest error messages with traces.
Fixes 461c51ad4275 ("Add a phy-num property to the i.MX FEC emulator")Cc Jean-Christophe Dubois <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
Applied.
Thanks
Quoted 46 lines
--- hw/net/imx_fec.c | 8 +++----- hw/net/trace-events | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-)hw/net/imx_fec.c +3
-5@@ -283,9 +283,8 @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); -return 0 ; +trace_imx_phy_read_num (phy, s->phy_num); +return 0xffff ; } reg %=32 ;@@ -345,8 +344,7 @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)uint32_t phy = reg /32 ;if (phy != s->phy_num) { -qemu_log_mask (LOG_GUEST_ERROR ,"[%s.phy]%s: Bad phy num %u\n" , -TYPE_IMX_FEC , __func__, phy); +trace_imx_phy_write_num (phy, s->phy_num);return ; }hw/net/trace-events +2
-0@@ -413,8 +413,10 @@ i82596_set_multicast(uint16_t count) "Added %d multicast entries" i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION" # imx_fec.c +imx_phy_read_num(int phy, int configured) "read request from unconfigured phy %d (configured %d)" imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <= phy[%d].reg[%d]" imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" => phy[%d].reg[%d]" +imx_phy_write_num(int phy, int configured) "write request to unconfigured phy %d (configured %d)" imx_phy_update_link(const char *s) "%s" imx_phy_reset(void) "" imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x"