Message ID | 1508947167-5304-10-git-send-email-mark.cave-ayland@ilande.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 25 October 2017 at 16:59, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > This enables them to be used outside of lance.c. > > Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> > CC: Jason Wang <jasowang@redhat.com> > diff --git a/include/hw/net/lance.h b/include/hw/net/lance.h > new file mode 100644 > index 0000000..c112fbc > --- /dev/null > +++ b/include/hw/net/lance.h > @@ -0,0 +1,41 @@ > +/* > + * QEMU AMD PC-Net II (Am79C970A) emulation Filename says this is Lance ethernet, but the comment says it's PC-Net ? > +#define TYPE_LANCE "lance" > +#define SYSBUS_PCNET(obj) \ > + OBJECT_CHECK(SysBusPCNetState, (obj), TYPE_LANCE) It's a bit weird that the OBJECT_CHECK macro name and the state structure name don't line up with the device name, but this is just code motion so not a problem. Other than fixing the comment, Reviewed-by: Peter Maydell <peter.maydell@linaro.org> (In an ideal world pcnet.h would be in include/.) thanks -- PMM
On 25/10/17 18:47, Peter Maydell wrote: > On 25 October 2017 at 16:59, Mark Cave-Ayland > <mark.cave-ayland@ilande.co.uk> wrote: >> This enables them to be used outside of lance.c. >> >> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> >> CC: Jason Wang <jasowang@redhat.com> > > >> diff --git a/include/hw/net/lance.h b/include/hw/net/lance.h >> new file mode 100644 >> index 0000000..c112fbc >> --- /dev/null >> +++ b/include/hw/net/lance.h >> @@ -0,0 +1,41 @@ >> +/* >> + * QEMU AMD PC-Net II (Am79C970A) emulation > > Filename says this is Lance ethernet, but the comment says it's PC-Net ? According to the datasheet for Am79C970A, the original Lance is an Am7990 device and the Am79C970A aka PCNet-PCI II as emulated by QEMU is register-compatible with it. I guess the comment above is more technically correct, but I'm happy to adjust it in my local tree if you still feel it needs to change? >> +#define TYPE_LANCE "lance" >> +#define SYSBUS_PCNET(obj) \ >> + OBJECT_CHECK(SysBusPCNetState, (obj), TYPE_LANCE) > > It's a bit weird that the OBJECT_CHECK macro name > and the state structure name don't line up with > the device name, but this is just code motion so > not a problem. Yeah, same issue as above... :/ > Other than fixing the comment, > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > > (In an ideal world pcnet.h would be in include/.) > > thanks > -- PMM ATB, Mark.
On 10/25/2017 12:59 PM, Mark Cave-Ayland wrote: > This enables them to be used outside of lance.c. > > Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > CC: Jason Wang <jasowang@redhat.com> > --- > hw/net/lance.c | 11 +---------- > include/hw/net/lance.h | 41 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 42 insertions(+), 10 deletions(-) > create mode 100644 include/hw/net/lance.h > > diff --git a/hw/net/lance.c b/hw/net/lance.c > index 92b0c68..23929fd 100644 > --- a/hw/net/lance.c > +++ b/hw/net/lance.c > @@ -41,19 +41,10 @@ > #include "qemu/timer.h" > #include "qemu/sockets.h" > #include "hw/sparc/sun4m.h" > -#include "pcnet.h" > +#include "hw/net/lance.h" > #include "trace.h" > #include "sysemu/sysemu.h" > > -#define TYPE_LANCE "lance" > -#define SYSBUS_PCNET(obj) \ > - OBJECT_CHECK(SysBusPCNetState, (obj), TYPE_LANCE) > - > -typedef struct { > - SysBusDevice parent_obj; > - > - PCNetState state; > -} SysBusPCNetState; > > static void parent_lance_reset(void *opaque, int irq, int level) > { > diff --git a/include/hw/net/lance.h b/include/hw/net/lance.h > new file mode 100644 > index 0000000..c112fbc > --- /dev/null > +++ b/include/hw/net/lance.h > @@ -0,0 +1,41 @@ > +/* > + * QEMU AMD PC-Net II (Am79C970A) emulation > + * > + * Copyright (c) 2004 Antony T Curtis > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > + > +#ifndef LANCE_H > +#define LANCE_H > + > +#include "net/net.h" > +#include "hw/net/pcnet.h" > + > +#define TYPE_LANCE "lance" > +#define SYSBUS_PCNET(obj) \ > + OBJECT_CHECK(SysBusPCNetState, (obj), TYPE_LANCE) > + > +typedef struct { > + SysBusDevice parent_obj; > + > + PCNetState state; > +} SysBusPCNetState; > + > +#endif >
On 26/10/17 11:12, Mark Cave-Ayland wrote: > On 25/10/17 18:47, Peter Maydell wrote: > >> On 25 October 2017 at 16:59, Mark Cave-Ayland >> <mark.cave-ayland@ilande.co.uk> wrote: >>> This enables them to be used outside of lance.c. >>> >>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> >>> CC: Jason Wang <jasowang@redhat.com> >> >> >>> diff --git a/include/hw/net/lance.h b/include/hw/net/lance.h >>> new file mode 100644 >>> index 0000000..c112fbc >>> --- /dev/null >>> +++ b/include/hw/net/lance.h >>> @@ -0,0 +1,41 @@ >>> +/* >>> + * QEMU AMD PC-Net II (Am79C970A) emulation >> >> Filename says this is Lance ethernet, but the comment says it's PC-Net ? > > According to the datasheet for Am79C970A, the original Lance is an > Am7990 device and the Am79C970A aka PCNet-PCI II as emulated by QEMU is > register-compatible with it. > > I guess the comment above is more technically correct, but I'm happy to > adjust it in my local tree if you still feel it needs to change? > >>> +#define TYPE_LANCE "lance" >>> +#define SYSBUS_PCNET(obj) \ >>> + OBJECT_CHECK(SysBusPCNetState, (obj), TYPE_LANCE) >> >> It's a bit weird that the OBJECT_CHECK macro name >> and the state structure name don't line up with >> the device name, but this is just code motion so >> not a problem. > > Yeah, same issue as above... :/ > >> Other than fixing the comment, >> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> >> >> (In an ideal world pcnet.h would be in include/.) >> >> thanks >> -- PMM Hi Peter, Did you have any further comments on the above? If not I can tidy up my branch for this (and the sun4m IOMMU work) later today and submit a PR in time for freeze. ATB, Mark.
On 30 October 2017 at 13:10, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > On 26/10/17 11:12, Mark Cave-Ayland wrote: >> On 25/10/17 18:47, Peter Maydell wrote: >>> On 25 October 2017 at 16:59, Mark Cave-Ayland wrote: >>>> --- /dev/null >>>> +++ b/include/hw/net/lance.h >>>> @@ -0,0 +1,41 @@ >>>> +/* >>>> + * QEMU AMD PC-Net II (Am79C970A) emulation >>> >>> Filename says this is Lance ethernet, but the comment says it's PC-Net ? >> >> According to the datasheet for Am79C970A, the original Lance is an >> Am7990 device and the Am79C970A aka PCNet-PCI II as emulated by QEMU is >> register-compatible with it. >> >> I guess the comment above is more technically correct, but I'm happy to >> adjust it in my local tree if you still feel it needs to change? I think we should have a comment that says what the file is for. Since this is a different file from pcnet.h, we should have a comment that isn't the same as the pcnet.h one. I don't particularly mind what it says, as long as it briefly explains what's in the file (and by implication what distinguishes things in this file from things in the other). thanks -- PMM
On 30/10/17 13:22, Peter Maydell wrote: > On 30 October 2017 at 13:10, Mark Cave-Ayland > <mark.cave-ayland@ilande.co.uk> wrote: >> On 26/10/17 11:12, Mark Cave-Ayland wrote: >>> On 25/10/17 18:47, Peter Maydell wrote: >>>> On 25 October 2017 at 16:59, Mark Cave-Ayland wrote: >>>>> --- /dev/null >>>>> +++ b/include/hw/net/lance.h >>>>> @@ -0,0 +1,41 @@ >>>>> +/* >>>>> + * QEMU AMD PC-Net II (Am79C970A) emulation >>>> >>>> Filename says this is Lance ethernet, but the comment says it's PC-Net ? >>> >>> According to the datasheet for Am79C970A, the original Lance is an >>> Am7990 device and the Am79C970A aka PCNet-PCI II as emulated by QEMU is >>> register-compatible with it. >>> >>> I guess the comment above is more technically correct, but I'm happy to >>> adjust it in my local tree if you still feel it needs to change? > > I think we should have a comment that says what the file is > for. Since this is a different file from pcnet.h, we should > have a comment that isn't the same as the pcnet.h one. > I don't particularly mind what it says, as long as it briefly > explains what's in the file (and by implication what distinguishes > things in this file from things in the other). Okay then how about something along the lines of: * QEMU Lance (Am7990) device emulation * * Copyright (c) 2004 Antony T Curtis * Copyright (c) 2017 Mark Cave-Ayland * * This represents the Sparc32 lance (Am7990) ethernet device which is * an earlier register-compatible member of the AMD PC-Net II * (Am79C970A) family. In reality pcnet.c/pcnet.h are just the inner workings of the pcnet-pci and lance devices. The comments in pcnet-pci.c and lance.c are identical except for the Sparc32 reference and it was the same header from pcnet-pci.c that I used as the basis for my last patch. ATB, Mark.
Hi Mark, >>>>>> +/* >>>>>> + * QEMU AMD PC-Net II (Am79C970A) emulation >>>>> >>>>> Filename says this is Lance ethernet, but the comment says it's PC-Net ? >>>> >>>> According to the datasheet for Am79C970A, the original Lance is an >>>> Am7990 device and the Am79C970A aka PCNet-PCI II as emulated by QEMU is >>>> register-compatible with it. >>>> >>>> I guess the comment above is more technically correct, but I'm happy to >>>> adjust it in my local tree if you still feel it needs to change? >> >> I think we should have a comment that says what the file is >> for. Since this is a different file from pcnet.h, we should >> have a comment that isn't the same as the pcnet.h one. >> I don't particularly mind what it says, as long as it briefly >> explains what's in the file (and by implication what distinguishes >> things in this file from things in the other). > > Okay then how about something along the lines of: > > * QEMU Lance (Am7990) device emulation > * > * Copyright (c) 2004 Antony T Curtis > * Copyright (c) 2017 Mark Cave-Ayland > * > * This represents the Sparc32 lance (Am7990) ethernet device which is > * an earlier register-compatible member of the AMD PC-Net II > * (Am79C970A) family. > > In reality pcnet.c/pcnet.h are just the inner workings of the pcnet-pci > and lance devices. The comments in pcnet-pci.c and lance.c are identical > except for the Sparc32 reference and it was the same header from > pcnet-pci.c that I used as the basis for my last patch. You are right the PCnet family is based on the Lance one, but it seems nobody remembers the Lance origin, the "PC-Net" took over. Maybe we can agree with the different families having an unique "hw/net/pcnet_lance.h" header with all Lance/PC-Net related XXX_TYPEs, what do you think? Regards, Phil.
On 30/10/17 18:45, Philippe Mathieu-Daudé wrote: >>>>>>> +/* >>>>>>> + * QEMU AMD PC-Net II (Am79C970A) emulation >>>>>> >>>>>> Filename says this is Lance ethernet, but the comment says it's PC-Net ? >>>>> >>>>> According to the datasheet for Am79C970A, the original Lance is an >>>>> Am7990 device and the Am79C970A aka PCNet-PCI II as emulated by QEMU is >>>>> register-compatible with it. >>>>> >>>>> I guess the comment above is more technically correct, but I'm happy to >>>>> adjust it in my local tree if you still feel it needs to change? >>> >>> I think we should have a comment that says what the file is >>> for. Since this is a different file from pcnet.h, we should >>> have a comment that isn't the same as the pcnet.h one. >>> I don't particularly mind what it says, as long as it briefly >>> explains what's in the file (and by implication what distinguishes >>> things in this file from things in the other). >> >> Okay then how about something along the lines of: >> >> * QEMU Lance (Am7990) device emulation >> * >> * Copyright (c) 2004 Antony T Curtis >> * Copyright (c) 2017 Mark Cave-Ayland >> * >> * This represents the Sparc32 lance (Am7990) ethernet device which is >> * an earlier register-compatible member of the AMD PC-Net II >> * (Am79C970A) family. >> >> In reality pcnet.c/pcnet.h are just the inner workings of the pcnet-pci >> and lance devices. The comments in pcnet-pci.c and lance.c are identical >> except for the Sparc32 reference and it was the same header from >> pcnet-pci.c that I used as the basis for my last patch. > > You are right the PCnet family is based on the Lance one, but it seems > nobody remembers the Lance origin, the "PC-Net" took over. > > Maybe we can agree with the different families having an unique > "hw/net/pcnet_lance.h" header with all Lance/PC-Net related XXX_TYPEs, > what do you think? This is definitely a good idea in principle, however the lance device in its current form cannot work for anything other than SPARC32 because of the the word-size byte swaps for FIFO transfers which occur for DMA transfers (see the code for ledma_memory_read/ledma_memory_write). I think in its current form the patch allows for someone to potentially implement this later for other architectures (e.g x86) so while I don't want to disallow this in future, it isn't really within the scope of this particular patchset. ATB, Mark.
diff --git a/hw/net/lance.c b/hw/net/lance.c index 92b0c68..23929fd 100644 --- a/hw/net/lance.c +++ b/hw/net/lance.c @@ -41,19 +41,10 @@ #include "qemu/timer.h" #include "qemu/sockets.h" #include "hw/sparc/sun4m.h" -#include "pcnet.h" +#include "hw/net/lance.h" #include "trace.h" #include "sysemu/sysemu.h" -#define TYPE_LANCE "lance" -#define SYSBUS_PCNET(obj) \ - OBJECT_CHECK(SysBusPCNetState, (obj), TYPE_LANCE) - -typedef struct { - SysBusDevice parent_obj; - - PCNetState state; -} SysBusPCNetState; static void parent_lance_reset(void *opaque, int irq, int level) { diff --git a/include/hw/net/lance.h b/include/hw/net/lance.h new file mode 100644 index 0000000..c112fbc --- /dev/null +++ b/include/hw/net/lance.h @@ -0,0 +1,41 @@ +/* + * QEMU AMD PC-Net II (Am79C970A) emulation + * + * Copyright (c) 2004 Antony T Curtis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef LANCE_H +#define LANCE_H + +#include "net/net.h" +#include "hw/net/pcnet.h" + +#define TYPE_LANCE "lance" +#define SYSBUS_PCNET(obj) \ + OBJECT_CHECK(SysBusPCNetState, (obj), TYPE_LANCE) + +typedef struct { + SysBusDevice parent_obj; + + PCNetState state; +} SysBusPCNetState; + +#endif
This enables them to be used outside of lance.c. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> CC: Jason Wang <jasowang@redhat.com> --- hw/net/lance.c | 11 +---------- include/hw/net/lance.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 include/hw/net/lance.h