From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: bilalwasim676@gmail.com, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Jason Wang <jasowang@redhat.com>,
aa1ronham@gmail.com, jcd@tribudubois.net, qemu-arm@nongnu.org,
bilal_wasim@mentor.com, linux@roeck-us.net
Subject: Re: [PATCH] net/imx_fec: Updating the IMX_FEC IP to support loopback mode.
Date: Fri, 29 Nov 2019 16:38:16 +0100 [thread overview]
Message-ID: <afe9efde-7ac1-8607-446a-8fbf10accece@redhat.com> (raw)
In-Reply-To: <20191129150508.24404-1-bilalwasim676@gmail.com>
Hi Bilal,
Cc'ing Jason, the maintainer of network devices.
On 11/29/19 4:05 PM, bilalwasim676@gmail.com wrote:
> From: bwasim <bilal_wasim@mentor.com>
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!
> 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..
>
> Signed-off-by: Bilal Wasim <bilal_wasim@mentor.com>
> ---
> hw/net/imx_fec.c | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
> index bd99236864..c51e7f7363 100644
> --- a/hw/net/imx_fec.c
> +++ b/hw/net/imx_fec.c
> @@ -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;
>
next prev parent reply other threads:[~2019-11-29 15:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-29 15:05 [PATCH] net/imx_fec: Updating the IMX_FEC IP to support loopback mode bilalwasim676
2019-11-29 15:38 ` Philippe Mathieu-Daudé [this message]
2019-11-29 15:59 ` Wasim, Bilal
2019-11-29 16:04 ` Philippe Mathieu-Daudé
2019-12-03 16:04 ` Bilal Wasim
2019-12-04 2:14 ` Jason Wang
2019-12-04 15:11 ` Peter Maydell
2019-12-05 14:06 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=afe9efde-7ac1-8607-446a-8fbf10accece@redhat.com \
--to=philmd@redhat.com \
--cc=aa1ronham@gmail.com \
--cc=bilal_wasim@mentor.com \
--cc=bilalwasim676@gmail.com \
--cc=jasowang@redhat.com \
--cc=jcd@tribudubois.net \
--cc=linux@roeck-us.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).