net/imx_fec: Updating the IMX_FEC IP to support loopback mode.
PATCH 1/1 net/imx_fec: Updating the IMX_FEC IP to support loopback mode.
From: bwasim <[email protected]>
Loopback mode only works when specific conditions (as dictated by the IP guide) are met, i.e. the MII_MODE is set and the RMII_MODE is cleared. If not, we simply send the packet on the output queue (for TX to the host network). Tested by running a custom RTOS and TXing a ton of packets. The same packets were received on the RX side..
--- hw/net/imx_fec.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
hw/net/imx_fec.c +25 -2
@@ -256,6 +256,29 @@ static const VMStateDescription vmstate_imx_eth = {static void imx_eth_update (IMXFECState *s); +/* +* Function to check if the MAC is configured to run in loopback mode. +* If so, invoke the "receive" routine. +* Else write to the output. +* */ +static void send_pkt (IMXFECState *s,uint8_t *frame,int frame_size) +{ +NetClientState *nc =qemu_get_queue (s->nic); + +/* +* Loopback or Normal mode ? +* Per the FEC Manual: If loopback is enabled, the MII_MODE +* should be SET and the RMII_MODE should be cleared. Loopback +* will only work if this criterion is met. If not met, +* we will send the frame on the output queue. */ +if ((s->regs[ENET_RCR ] &ENET_RCR_LOOP ) && (s->regs[ENET_RCR ] &ENET_RCR_MII_MODE ) + && !(s->regs[ENET_RCR ] &ENET_RCR_RMII_MODE )) { + nc->info->receive (nc, frame, frame_size); + }else { +qemu_send_packet (nc, frame, frame_size); + } +} +/* * The MII phy could raise a GPIO to the processor which in turn * could be handled as an interrpt by the OS.
@@ -488,7 +511,7 @@ static void imx_fec_do_tx(IMXFECState *s) frame_size += len;if (bd.flags &ENET_BD_L ) {/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ; s->regs[ENET_EIR ] |=ENET_INT_TXF ;
@@ -586,7 +609,7 @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) }/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ;
Signature · 1 line
2.19.1.windows.1
Hi Bilal,
Cc'ing Jason, the maintainer of network devices.
Quoted 1 line · On 11/29/19 4:05 PM, [email protected] wrote:
From: bwasim <[email protected]>
Your git setup misses your 'user.name', you could fix it running:
git config user.name "Bilal Wasim"
(eventually with the --global option).
The patch looks good otherwise.
Thanks!
Quoted 65 lines
Loopback mode only works when specific conditions (as dictated by the IP guide) are met, i.e. the
MII_MODEis set and theRMII_MODEis cleared. If not, we simply send the packet on the output queue (for TX to the host network). Tested by running a custom RTOS and TXing a ton of packets. The same packets were received on the RX side..Signed-off-by Bilal Wasim <[email protected]>--- hw/net/imx_fec.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)hw/net/imx_fec.c +25
-2@@ -256,6 +256,29 @@ static const VMStateDescription vmstate_imx_eth = {static void imx_eth_update (IMXFECState *s); +/* +* Function to check if the MAC is configured to run in loopback mode. +* If so, invoke the "receive" routine. +* Else write to the output. +* */ +static void send_pkt (IMXFECState *s,uint8_t *frame,int frame_size) +{ +NetClientState *nc =qemu_get_queue (s->nic); + +/* +* Loopback or Normal mode ? +* Per the FEC Manual: If loopback is enabled, the MII_MODE +* should be SET and the RMII_MODE should be cleared. Loopback +* will only work if this criterion is met. If not met, +* we will send the frame on the output queue. */ +if ((s->regs[ENET_RCR ] &ENET_RCR_LOOP ) && (s->regs[ENET_RCR ] &ENET_RCR_MII_MODE ) + && !(s->regs[ENET_RCR ] &ENET_RCR_RMII_MODE )) { + nc->info->receive (nc, frame, frame_size); + }else { +qemu_send_packet (nc, frame, frame_size); + } +} +/* * The MII phy could raise a GPIO to the processor which in turn * could be handled as an interrpt by the OS. @@ -488,7 +511,7 @@ static void imx_fec_do_tx(IMXFECState *s) frame_size += len;if (bd.flags &ENET_BD_L ) {/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ; s->regs[ENET_EIR ] |=ENET_INT_TXF ;@@ -586,7 +609,7 @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) }/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ;
Thanks for the pointers philippe.. Is the patch okay to be merged without it or do I need to do a re-submission with the updated username ?
- Bilal
-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Friday, November 29, 2019 8:38 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wasim, Bilal <[email protected]>; [email protected]; Jason Wang <[email protected]>
Subject: Re: [PATCH] net/imx_fec: Updating the IMX_FEC IP to support loopback mode.
Hi Bilal,
Cc'ing Jason, the maintainer of network devices.
Quoted 1 line · On 11/29/19 4:05 PM, [email protected] wrote:
From: bwasim <[email protected]>
Your git setup misses your 'user.name', you could fix it running:
git config user.name "Bilal Wasim"
(eventually with the --global option).
The patch looks good otherwise.
Thanks!
Quoted 65 lines
Loopback mode only works when specific conditions (as dictated by the IP guide) are met, i.e. the
MII_MODEis set and theRMII_MODEis cleared. If not, we simply send the packet on the output queue (for TX to the host network). Tested by running a custom RTOS and TXing a ton of packets. The same packets were received on the RX side..Signed-off-by Bilal Wasim <[email protected]>--- hw/net/imx_fec.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)hw/net/imx_fec.c index renamed from hw/net/imx_fec.c +0
-0
bd99236864..c51e7f7363100644hw/net/imx_fec.c +23
-0@@ -256,6 +256,29 @@ static const VMStateDescription vmstate_imx_eth = {static void imx_eth_update (IMXFECState *s); +/* +* Function to check if the MAC is configured to run in loopback mode. +* If so, invoke the "receive" routine. +* Else write to the output. +* */ +static void send_pkt (IMXFECState *s,uint8_t *frame,int frame_size) +{ +NetClientState *nc =qemu_get_queue (s->nic); + +/* +* Loopback or Normal mode ? +* Per the FEC Manual: If loopback is enabled, the MII_MODE +* should be SET and the RMII_MODE should be cleared. Loopback +* will only work if this criterion is met. If not met, +* we will send the frame on the output queue. */ +if ((s->regs[ENET_RCR ] &ENET_RCR_LOOP ) && (s->regs[ENET_RCR ] &ENET_RCR_MII_MODE ) + && !(s->regs[ENET_RCR ] &ENET_RCR_RMII_MODE )) { + nc->info->receive (nc, frame, frame_size); + }else { +qemu_send_packet (nc, frame, frame_size); + } +} +/* * The MII phy could raise a GPIO to the processor which in turn * could be handled as an interrpt by the OS.
hw/net/imx_fec.c +1
-1@@ -488,7 +511,7 @@ static void imx_fec_do_tx(IMXFECState *s) frame_size += len;if (bd.flags &ENET_BD_L ) {/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ; s->regs[ENET_EIR] |= ENET_INT_TXF; @@ -586,7 +609,7 @@static void
imx_enet_do_tx(IMXFECState *s, uint32_t index)} /* Last buffer in frame. */hw/net/imx_fec.c +1
-1-qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ;
Quoted 2 lines · Bilal
Thanks for the pointers philippe.. Is the patch okay to be merged without it or do I need to do a re-submission with the updated username ?
If there are no review comments on your patch, I think the maintainer taking your patch can fix this details directly, no need to resend.
Quoted 90 lines
-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Friday, November 29, 2019 8:38 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wasim, Bilal <[email protected]>; [email protected]; Jason Wang <[email protected]>
Subject: Re: [PATCH]net/imx_fec: Updating theIMX_FECIP to support loopback mode.Hi Bilal,
Cc'ing Jason, the maintainer of network devices.
Quoted 1 line · On 11/29/19 4:05 PM, [email protected] wrote:
From: bwasim <[email protected]>
Your git setup misses your 'user.name', you could fix it running:
git config user.name "Bilal Wasim"
(eventually with the --global option).
The patch looks good otherwise.
Thanks!
Quoted 65 lines
Loopback mode only works when specific conditions (as dictated by the IP guide) are met, i.e. the
MII_MODEis set and theRMII_MODEis cleared. If not, we simply send the packet on the output queue (for TX to the host network). Tested by running a custom RTOS and TXing a ton of packets. The same packets were received on the RX side..Signed-off-by Bilal Wasim <[email protected]>--- hw/net/imx_fec.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)hw/net/imx_fec.c index renamed from hw/net/imx_fec.c +0
-0
bd99236864..c51e7f7363100644hw/net/imx_fec.c +23
-0@@ -256,6 +256,29 @@ static const VMStateDescription vmstate_imx_eth = {static void imx_eth_update (IMXFECState *s); +/* +* Function to check if the MAC is configured to run in loopback mode. +* If so, invoke the "receive" routine. +* Else write to the output. +* */ +static void send_pkt (IMXFECState *s,uint8_t *frame,int frame_size) +{ +NetClientState *nc =qemu_get_queue (s->nic); + +/* +* Loopback or Normal mode ? +* Per the FEC Manual: If loopback is enabled, the MII_MODE +* should be SET and the RMII_MODE should be cleared. Loopback +* will only work if this criterion is met. If not met, +* we will send the frame on the output queue. */ +if ((s->regs[ENET_RCR ] &ENET_RCR_LOOP ) && (s->regs[ENET_RCR ] &ENET_RCR_MII_MODE ) + && !(s->regs[ENET_RCR ] &ENET_RCR_RMII_MODE )) { + nc->info->receive (nc, frame, frame_size); + }else { +qemu_send_packet (nc, frame, frame_size); + } +} +/* * The MII phy could raise a GPIO to the processor which in turn * could be handled as an interrpt by the OS.
hw/net/imx_fec.c +1
-1@@ -488,7 +511,7 @@ static void imx_fec_do_tx(IMXFECState *s) frame_size += len;if (bd.flags &ENET_BD_L ) {/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ; s->regs[ENET_EIR] |= ENET_INT_TXF; @@ -586,7 +609,7 @@static void
imx_enet_do_tx(IMXFECState *s, uint32_t index)} /* Last buffer in frame. */hw/net/imx_fec.c +1
-1-qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ;
ping...
Quoted 27 lines · Philippe Mathieu-Daudé
Quoted 1 line · Bilal
Thanks for the pointers philippe.. Is the patch okay to be merged without it or do I need to do a re-submission with the updated username ?
If there are no review comments on your patch, I think the maintainer taking your patch can fix this details directly, no need to resend.
Quoted 22 lines
-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Friday, November 29, 2019 8:38 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wasim, Bilal <[email protected]>; [email protected]; Jason Wang <[email protected]>
Subject: Re: [PATCH]net/imx_fec: Updating theIMX_FECIP to support loopback mode.Hi Bilal,
Cc'ing Jason, the maintainer of network devices.
Quoted 1 line · On 11/29/19 4:05 PM, [email protected] wrote:
From: bwasim <[email protected]>
Your git setup misses your 'user.name', you could fix it running:
git config user.name "Bilal Wasim"
(eventually with the --global option).
The patch looks good otherwise.
Thanks!
Applied with the fix for user.name.
Thanks
Quoted 66 lines
Quoted 66 lines
Quoted 66 lines
Loopback mode only works when specific conditions (as dictated by the IP guide) are met, i.e. the
MII_MODEis set and theRMII_MODEis cleared. If not, we simply send the packet on the output queue (for TX to the host network). Tested by running a custom RTOS and TXing a ton of packets. The same packets were received on the RX side..Signed-off-by Bilal Wasim <[email protected]>--- hw/net/imx_fec.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)hw/net/imx_fec.c index renamed from hw/net/imx_fec.c +0
-0
bd99236864..c51e7f7363100644hw/net/imx_fec.c +23
-0@@ -256,6 +256,29 @@ static const VMStateDescription vmstate_imx_eth = {static void imx_eth_update (IMXFECState *s); +/* +* Function to check if the MAC is configured to run in loopback mode. +* If so, invoke the "receive" routine. +* Else write to the output. +* */ +static void send_pkt (IMXFECState *s,uint8_t *frame,int frame_size) +{ +NetClientState *nc =qemu_get_queue (s->nic); + +/* +* Loopback or Normal mode ? +* Per the FEC Manual: If loopback is enabled, the MII_MODE +* should be SET and the RMII_MODE should be cleared. Loopback +* will only work if this criterion is met. If not met, +* we will send the frame on the output queue. */ +if ((s->regs[ENET_RCR ] &ENET_RCR_LOOP ) && (s->regs[ENET_RCR ] &ENET_RCR_MII_MODE ) + && !(s->regs[ENET_RCR ] &ENET_RCR_RMII_MODE )) { + nc->info->receive (nc, frame, frame_size); + }else { +qemu_send_packet (nc, frame, frame_size); + } +} +/* * The MII phy could raise a GPIO to the processor which in turn * could be handled as an interrpt by the OS.
hw/net/imx_fec.c +1
-1@@ -488,7 +511,7 @@ static void imx_fec_do_tx(IMXFECState *s) frame_size += len;if (bd.flags &ENET_BD_L ) {/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ; s->regs[ENET_EIR] |= ENET_INT_TXF; @@ -586,7 +609,7 @@static void
imx_enet_do_tx(IMXFECState *s, uint32_t index)} /* Last buffer in frame. */hw/net/imx_fec.c +1
-1-qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); +send_pkt (s, (uint8_t *)&s->frame, frame_size); ptr = s->frame; frame_size =0 ;
Quoted 25 lines · Jason Wang
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 1 line · Bilal
Thanks for the pointers philippe.. Is the patch okay to be merged without it or do I need to do a re-submission with the updated username ?
If there are no review comments on your patch, I think the maintainer taking your patch can fix this details directly, no need to resend.
Quoted 17 lines
-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Friday, November 29, 2019 8:38 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Wasim, Bilal <[email protected]>; [email protected]; Jason Wang <[email protected]>
Subject: Re: [PATCH]net/imx_fec: Updating theIMX_FECIP to support loopback mode.Hi Bilal,
Cc'ing Jason, the maintainer of network devices.
Quoted 1 line · On 11/29/19 4:05 PM, [email protected] wrote:
From: bwasim <[email protected]>
Your git setup misses your 'user.name', you could fix it running:
git config user.name "Bilal Wasim"
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
(eventually with the --global option).
The patch looks good otherwise.
Thanks!
Applied with the fix for user.name.
Could you fix up the non-standard block comment formatting too?
thanks
-- PMM
Quoted 26 lines · Peter Maydell
Quoted 25 lines · Jason Wang
Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 1 line · Bilal
Thanks for the pointers philippe.. Is the patch okay to be merged without it or do I need to do a re-submission with the updated username ?
If there are no review comments on your patch, I think the maintainer taking your patch can fix this details directly, no need to resend.
Quoted 19 lines
-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Friday, November 29, 2019 8:38 PM
To:[email protected];[email protected]
Cc:[email protected];[email protected];[email protected];[email protected]; Wasim, Bilal<[email protected]>;[email protected]; Jason Wang<[email protected]>
Subject: Re: [PATCH]net/imx_fec: Updating theIMX_FECIP to support loopback mode.Hi Bilal,
Cc'ing Jason, the maintainer of network devices.
Quoted 1 line · On 11/29/19 4:05 PM,[email protected] wrote:
From: bwasim<[email protected]>
Your git setup misses your 'user.name', you could fix it running:
git config user.name "Bilal Wasim"
(eventually with the --global option).
Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
The patch looks good otherwise.
Thanks!
Applied with the fix for user.name.
Could you fix up the non-standard block comment formatting too?
thanks
-- PMM
Yes, fixed.
Thanks