Re: CVS commit: src/sys/dev/pci

2021-02-01 Thread J. Hannken-Illjes
> On 12. Jul 2020, at 21:05, Jaromir Dolecek  wrote:
> 
> Module Name:  src
> Committed By: jdolecek
> Date: Sun Jul 12 19:05:32 UTC 2020
> 
> Modified Files:
>   src/sys/dev/pci: if_bnx.c if_bnxvar.h
> 
> Log Message:
> enable MSI/MSI-X if supported by adapter
> 
> tested MSI-X with Broadcom NetXtreme II BCM5709 1000Base-T
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.95 -r1.96 src/sys/dev/pci/if_bnx.c
> cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/if_bnxvar.h
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.

With this change my Dell PowerEdge 2850 spits watchdog resets:

[  68.1828359] bnx0: Watchdog timeout -- resetting!
[  88.6042909] bnx0: Watchdog timeout -- resetting!
[ 119.0265230] bnx0: Watchdog timeout -- resetting!
[ 145.4484562] bnx0: Watchdog timeout -- resetting!

Dmesg before is:

[ 1.017306] pci4 at ppb3 bus 7
[ 1.017306] pci4: i/o space, memory space enabled, rd/line, wr/inv ok
[ 1.017306] bnx0 at pci4 dev 0 function 0: Broadcom NetXtreme II BCM5708 
1000Base-T
[ 1.017306] bnx0: Ethernet address 00:24:e8:67:4b:db
[ 1.017306] bnx0: ASIC BCM5708 B2 (0x57081020)
[ 1.017306] bnx0: PCI-X 64bit 133MHz
[ 1.017306] bnx0: B/C (4.6.0); Bufs (RX:2;TX:2); Flags (MFW); MFW (ipms 
1.6.0)
[ 1.017306] bnx0: Coal (RX:6,6,18,18; TX:20,20,80,80)
[ 1.017306] brgphy0 at bnx0 phy 1: BCM5708C 1000BASE-T media interface, 
rev. 6
[ 1.017306] brgphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 
1000baseT, 1000baseT-FDX, auto
[ 1.017306] bnx0: interrupting at ioapic0 pin 16

while dmesg after is:

[ 1.017262] pci4 at ppb3 bus 7
[ 1.017262] pci4: i/o space, memory space enabled, rd/line, wr/inv ok
[ 1.017262] bnx0 at pci4 dev 0 function 0: Broadcom NetXtreme II BCM5708 
1000Base-T
[ 1.017262] bnx0: Ethernet address 00:24:e8:67:4b:db
[ 1.017262] bnx0: ASIC BCM5708 B2 (0x57081020)
[ 1.017262] bnx0: PCI-X 64bit 133MHz
[ 1.017262] bnx0: B/C (4.6.0); Bufs (RX:2;TX:2); Flags (MFW); MFW (ipms 
1.6.0)
[ 1.017262] bnx0: Coal (RX:6,6,18,18; TX:20,20,80,80)
[ 1.017262] brgphy0 at bnx0 phy 1: BCM5708C 1000BASE-T media interface, 
rev. 6
[ 1.017262] brgphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 
1000baseT, 1000baseT-FDX, auto
[ 1.017262] bnx0: interrupting at msi0 vec 0

Pcictl dump gives (in the MSI-X case):

  PCI Message Signaled Interrupt
Message Control register: 0x0081
  MSI Enabled: on
  Multiple Message Capable: no (1 vector)
  Multiple Message Enabled: off (1 vector)
  64 Bit Address Capable: on
  Per-Vector Masking Capable: off
  Extended Message Data Capable: off
  Extended Message Data Enable: off
Message Address (lower) register: 0xfee0
Message Address (upper) register: 0x
Message Data register: 0x0064

Any ideas how to fix this issue?

--
J. Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)


signature.asc
Description: Message signed with OpenPGP


Re: CVS commit: src/sys/dev/pci

2021-01-26 Thread Reinoud Zandijk
On Tue, Jan 26, 2021 at 05:51:42PM +0900, Rin Okuyama wrote:
> Hi,

> This seems not correct for me. Is the attached patch OK with you?

Well you spotted a bug indeed int he freeing section. I'll fix and commit it.
Thanks for reporting.

Reinoud


signature.asc
Description: PGP signature


Re: CVS commit: src/sys/dev/pci

2021-01-26 Thread Rin Okuyama

Hi,

On 2021/01/25 0:33, Reinoud Zandijk wrote:

Module Name:src
Committed By:   reinoud
Date:   Sun Jan 24 15:33:02 UTC 2021

Modified Files:
src/sys/dev/pci: virtio_pci.c

Log Message:
On error unmap the pci_mapreg_map()d regions using bus_space_unmap() as
suggested by jak@


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/virtio_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.


This seems not correct for me. Is the attached patch OK with you?

Thanks,
rin
Index: sys/dev/pci/virtio_pci.c
===
RCS file: /home/netbsd/src/sys/dev/pci/virtio_pci.c,v
retrieving revision 1.25
diff -p -u -r1.25 virtio_pci.c
--- sys/dev/pci/virtio_pci.c24 Jan 2021 15:59:35 -  1.25
+++ sys/dev/pci/virtio_pci.c26 Jan 2021 08:47:23 -
@@ -444,7 +444,7 @@ virtio_pci_attach_10(device_t self, void
bus_size_t bars[NMAPREG] = { 0 };
int bars_idx[NMAPREG] = { 0 };
struct virtio_pci_cap *caps[] = { , , ,  };
-   int i, j = 0, ret = 0;
+   int i, j, ret = 0;
 
if (virtio_pci_find_cap(psc, VIRTIO_PCI_CAP_COMMON_CFG,
, sizeof(common)))
@@ -471,7 +471,7 @@ virtio_pci_attach_10(device_t self, void
bars[bar] = len;
}
 
-   for (i = 0; i < __arraycount(bars); i++) {
+   for (i = j = 0; i < __arraycount(bars); i++) {
int reg;
pcireg_t type;
if (bars[i] == 0)
@@ -550,11 +550,12 @@ virtio_pci_attach_10(device_t self, void
 
 err:
/* undo our pci_mapreg_map()s */ 
-   for (i = 0; i < __arraycount(bars); i++) {
+   for (i = j = 0; i < __arraycount(bars); i++) {
if (bars[i] == 0)
continue;
bus_space_unmap(psc->sc_bars_iot[j], psc->sc_bars_ioh[j],
psc->sc_bars_iosize[j]);
+   j++;
}
return ret;
 }


Re: CVS commit: src/sys/dev/pci

2021-01-25 Thread Jason Thorpe


> On Jan 24, 2021, at 10:20 PM, Martin Husemann  wrote:
> 
>> I kept getting a ?static after non-static declaration? error when building 
>> for aarch64.
> 
> I guess that was with outdated arm/include/bus_funcs.h and
> sys/bus_proto.h (or where was the previous declaration)?

I did a “cvs update” just before, *shrug*.  In any case, the problem was easily 
avoidable, and now it is avoided.

-- thorpej



Re: CVS commit: src/sys/dev/pci

2021-01-24 Thread Martin Husemann
On Sun, Jan 24, 2021 at 09:45:14PM -0800, Jason Thorpe wrote:
> 
> > On Jan 24, 2021, at 9:37 PM, Martin Husemann  wrote:
> > 
> > While I don't care for names, I would like to understand fallout in
> > details before hiding it - what exactly did not compile correctly?
> > At least the affected arm kernels worked for me in the state directly
> > before your commit.
> 
> I kept getting a ?static after non-static declaration? error when building 
> for aarch64.

I guess that was with outdated arm/include/bus_funcs.h and
sys/bus_proto.h (or where was the previous declaration)?

Martin


Re: CVS commit: src/sys/dev/pci

2021-01-24 Thread Jason Thorpe


> On Jan 24, 2021, at 9:37 PM, Martin Husemann  wrote:
> 
> While I don't care for names, I would like to understand fallout in
> details before hiding it - what exactly did not compile correctly?
> At least the affected arm kernels worked for me in the state directly
> before your commit.

I kept getting a “static after non-static declaration” error when building for 
aarch64.

-- thorpej



Re: CVS commit: src/sys/dev/pci

2021-01-24 Thread Martin Husemann
On Sun, Jan 24, 2021 at 03:34:08PM +, Jason R Thorpe wrote:
> Module Name:  src
> Committed By: thorpej
> Date: Sun Jan 24 15:34:08 UTC 2021
> 
> Modified Files:
>   src/sys/dev/pci: virtio_pci.c
> 
> Log Message:
> Redefining bus_space functions in drivers is a bad idea, and we just
> should't be in the habit of doing so.  Besides, the previous "solutions"
> still did not compile correctly, and this does, so let's be done with
> this nonsense, shall we?

While I don't care for names, I would like to understand fallout in
details before hiding it - what exactly did not compile correctly?
At least the affected arm kernels worked for me in the state directly
before your commit.

Martin


Re: CVS commit: src/sys/dev/pci

2021-01-23 Thread Jason Thorpe


> On Jan 23, 2021, at 5:40 PM, Christos Zoulas  wrote:
> 
>> it's a bad example.  someone might copy it into another
>> driver that _doesn't_ work with this version, but may seem
>> to fix a build error.
>> 
>> that's why i wanted to wrap the usage to make it clear if
>> someone were to copy it elsewhere.
> 
> I will add a comment.

Yah, I was gonna say, “big fat comment in order!"

-- thorpej



Re: CVS commit: src/sys/dev/pci

2021-01-23 Thread Christos Zoulas
In article <17141.1611452...@splode.eterna.com.au>,
matthew green   wrote:
>Christos Zoulas writes:
>> In article <20210123230600.52be160...@jupiter.mumble.net>,
>> Taylor R Campbell   wrote:
>> >
>> >Conversely, how do you know whether this hacked-up implementation
>> >which tears the write into two will actually work?  Maybe it works for
>> >virtio but there are likely other devices out there for which it will
>> >fail or have weird side effects if the architecture doesn't have
>> >native 8-byte bus I/O.
>>
>> But it is a static function defined in virtio_pci.c. How will other
>> devices use it? I must be missing something.
>
>it's a bad example.  someone might copy it into another
>driver that _doesn't_ work with this version, but may seem
>to fix a build error.
>
>that's why i wanted to wrap the usage to make it clear if
>someone were to copy it elsewhere.

I will add a comment.

christos



re: CVS commit: src/sys/dev/pci

2021-01-23 Thread matthew green
Christos Zoulas writes:
> In article <20210123230600.52be160...@jupiter.mumble.net>,
> Taylor R Campbell   wrote:
> >
> >Conversely, how do you know whether this hacked-up implementation
> >which tears the write into two will actually work?  Maybe it works for
> >virtio but there are likely other devices out there for which it will
> >fail or have weird side effects if the architecture doesn't have
> >native 8-byte bus I/O.
>
> But it is a static function defined in virtio_pci.c. How will other
> devices use it? I must be missing something.

it's a bad example.  someone might copy it into another
driver that _doesn't_ work with this version, but may seem
to fix a build error.

that's why i wanted to wrap the usage to make it clear if
someone were to copy it elsewhere.


.mrg.


Re: CVS commit: src/sys/dev/pci

2021-01-23 Thread Christos Zoulas
In article <20210123230600.52be160...@jupiter.mumble.net>,
Taylor R Campbell   wrote:
>
>Conversely, how do you know whether this hacked-up implementation
>which tears the write into two will actually work?  Maybe it works for
>virtio but there are likely other devices out there for which it will
>fail or have weird side effects if the architecture doesn't have
>native 8-byte bus I/O.

But it is a static function defined in virtio_pci.c. How will other
devices use it? I must be missing something.

christos



Re: CVS commit: src/sys/dev/pci

2021-01-23 Thread Taylor R Campbell
> Date: Sat, 23 Jan 2021 22:59:22 - (UTC)
> From: chris...@astron.com (Christos Zoulas)
> 
> In article <23974.1611441...@splode.eterna.com.au>,
> matthew green   wrote:
> >this seems dangerous to me.  we don't define it on
> >some platforms because we can't, so having it faked
> >out here seems like someone later will be confused
> >and the wrong thing will happen.
> >
> >i would rather have something like
> >
> >virtio_write8(...)
> >{
> >#ifdef __HAVE_BUS_SPACE_8
> > just use the real thing
> >#else
> > use the dual-_4 version that is ok _for this device_
> >#endif
> >}
> >
> >and then use this wrapper in the rest of the code.
> 
> This implementation is internal to virtio_pci and is guaranteed to work
> by the spec, how will someone else us it?

Conversely, how do you know whether this hacked-up implementation
which tears the write into two will actually work?  Maybe it works for
virtio but there are likely other devices out there for which it will
fail or have weird side effects if the architecture doesn't have
native 8-byte bus I/O.


Re: CVS commit: src/sys/dev/pci

2021-01-23 Thread Christos Zoulas
In article <23974.1611441...@splode.eterna.com.au>,
matthew green   wrote:
>"Christos Zoulas" writes:
>> Module Name: src
>> Committed By:christos
>> Date:Sat Jan 23 20:00:19 UTC 2021
>>
>> Modified Files:
>>  src/sys/dev/pci: virtio_pci.c
>>
>> Log Message:
>> Provide a generic bus_space_write_8 function that is bi-endian.
>
>this seems dangerous to me.  we don't define it on
>some platforms because we can't, so having it faked
>out here seems like someone later will be confused
>and the wrong thing will happen.
>
>i would rather have something like
>
>virtio_write8(...)
>{
>#ifdef __HAVE_BUS_SPACE_8
>   just use the real thing
>#else
>   use the dual-_4 version that is ok _for this device_
>#endif
>}
>
>and then use this wrapper in the rest of the code.

This implementation is internal to virtio_pci and is guaranteed to work
by the spec, how will someone else us it?


christos



re: CVS commit: src/sys/dev/pci

2021-01-23 Thread matthew green
"Christos Zoulas" writes:
> Module Name:  src
> Committed By: christos
> Date: Sat Jan 23 20:00:19 UTC 2021
>
> Modified Files:
>   src/sys/dev/pci: virtio_pci.c
>
> Log Message:
> Provide a generic bus_space_write_8 function that is bi-endian.

this seems dangerous to me.  we don't define it on
some platforms because we can't, so having it faked
out here seems like someone later will be confused
and the wrong thing will happen.

i would rather have something like

virtio_write8(...)
{
#ifdef __HAVE_BUS_SPACE_8
just use the real thing
#else
use the dual-_4 version that is ok _for this device_
#endif
}

and then use this wrapper in the rest of the code.


.mrg.


Re: CVS commit: src/sys/dev/pci

2021-01-23 Thread Christos Zoulas
In article ,
Reinoud Zandijk   wrote:
>On Fri, Jan 22, 2021 at 04:54:51PM +1100, matthew green wrote:
>> > +#ifndef _LP64
>> 
>> _LP64 is a terrible way to make this choice.
>> 
>> heaps of our 32 bit platforms implement the _8 variants.
>
>Can't we then just make sure they have the 8 bit variant? and set a define if
>its atomic or not?
>
>This way drivers van use the _8 variant freely and for the few drivers that
>NEED the atomicity, they can check the define and deal with it the way they
>like.

Perhaps. But still for the ones that don't have it should use the central
implementation so that we don't duplicate code.

christos



Re: CVS commit: src/sys/dev/pci

2021-01-23 Thread Christos Zoulas
In article ,
Nick Hudson   wrote:
>On 22/01/2021 04:48, Christos Zoulas wrote:
>> +#if _QUAD_HIGHWORD
>> +bus_space_write_4(iot, ioh, offset, (uint32_t)(value & 0x));
>> +bus_space_write_4(iot, ioh, offset + 4, (uint32_t)(value >> 32));
>> +#else
>> +bus_space_write_4(iot, ioh, offset, (uint32_t)(value >> 32));
>> +bus_space_write_4(iot, ioh, offset + 4, (uint32_t)(value & 0x));
>> +#endif
>> +}
>> +#endif /* !_LP64 */
>
>
>BUS_ADDR_{HI,LO}32 are also available for your convenience.

Will use those thanks!

christos



Re: CVS commit: src/sys/dev/pci

2021-01-22 Thread Reinoud Zandijk
On Fri, Jan 22, 2021 at 04:54:51PM +1100, matthew green wrote:
> > +#ifndef _LP64
> 
> _LP64 is a terrible way to make this choice.
> 
> heaps of our 32 bit platforms implement the _8 variants.

Can't we then just make sure they have the 8 bit variant? and set a define if
its atomic or not?

This way drivers van use the _8 variant freely and for the few drivers that
NEED the atomicity, they can check the define and deal with it the way they
like.

Reinoud


Re: CVS commit: src/sys/dev/pci

2021-01-22 Thread Nick Hudson

On 22/01/2021 04:48, Christos Zoulas wrote:

+#if _QUAD_HIGHWORD
+   bus_space_write_4(iot, ioh, offset, (uint32_t)(value & 0x));
+   bus_space_write_4(iot, ioh, offset + 4, (uint32_t)(value >> 32));
+#else
+   bus_space_write_4(iot, ioh, offset, (uint32_t)(value >> 32));
+   bus_space_write_4(iot, ioh, offset + 4, (uint32_t)(value & 0x));
+#endif
+}
+#endif /* !_LP64 */



BUS_ADDR_{HI,LO}32 are also available for your convenience.

Nick


Re: CVS commit: src/sys/dev/pci

2021-01-21 Thread Christos Zoulas
In article <27744.1611294...@splode.eterna.com.au>,
matthew green   wrote:
>> +#ifndef _LP64
>
>_LP64 is a terrible way to make this choice.
>
>heaps of our 32 bit platforms implement the _8 variants.

Let's add a _HAVE_ variable then?

christos



re: CVS commit: src/sys/dev/pci

2021-01-21 Thread matthew green
> +#ifndef _LP64

_LP64 is a terrible way to make this choice.

heaps of our 32 bit platforms implement the _8 variants.


.mrg.


Re: CVS commit: src/sys/dev/pci

2021-01-21 Thread Christos Zoulas
In article <20210121204833.9ebcff...@cvs.netbsd.org>,
Reinoud Zandijk  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  reinoud
>Date:  Thu Jan 21 20:48:33 UTC 2021
>
>Modified Files:
>   src/sys/dev/pci: virtio_pci.c
>
>Log Message:
>Remove dependency on bus_space_write_8() for i386 and instead implement it as
>two bus_space_write_4()'s as allowed in the spec.

Isn't it better to do it this way so it always works (not just for little
endian)? We could even provide this in the MI bus.h if others need it
and don't care about the non-atomic transactions. I have not even compile
tested it.

christos

Index: virtio_pci.c
===
RCS file: /cvsroot/src/sys/dev/pci/virtio_pci.c,v
retrieving revision 1.18
diff -u -p -u -r1.18 virtio_pci.c
--- virtio_pci.c21 Jan 2021 20:48:33 -  1.18
+++ virtio_pci.c22 Jan 2021 04:46:24 -
@@ -34,6 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: virtio_pci.c
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -731,9 +732,20 @@ virtio_pci_read_queue_size_10(struct vir
  * By definition little endian only in v1.0 and 8 byters are allowed to be
  * written as two 4 byters
  */
-#define bus_space_write_le_8(iot, ioh, reg, val) \
-   bus_space_write_4(iot, ioh, reg, ((uint64_t) (val)) & 0x); \
-   bus_space_write_4(iot, ioh, reg + 4, ((uint64_t) (val)) >> 32);
+#ifndef _LP64
+static __inline void
+bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh,
+ bus_size_t offset, uint64_t value)
+{
+#if _QUAD_HIGHWORD
+   bus_space_write_4(iot, ioh, offset, (uint32_t)(value & 0x));
+   bus_space_write_4(iot, ioh, offset + 4, (uint32_t)(value >> 32));
+#else
+   bus_space_write_4(iot, ioh, offset, (uint32_t)(value >> 32));
+   bus_space_write_4(iot, ioh, offset + 4, (uint32_t)(value & 0x));
+#endif
+}
+#endif /* !_LP64 */
 
 static void
 virtio_pci_setup_queue_10(struct virtio_softc *sc, uint16_t idx, uint64_t addr)
@@ -747,15 +759,15 @@ virtio_pci_setup_queue_10(struct virtio_
bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SELECT, vq->vq_index);
if (addr == 0) {
bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 0);
-   bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC,   0);
-   bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL,  0);
-   bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED,   0);
+   bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC,   0);
+   bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL,  0);
+   bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED,   0);
} else {
-   bus_space_write_le_8(iot, ioh,
+   bus_space_write_8(iot, ioh,
VIRTIO_CONFIG1_QUEUE_DESC, addr);
-   bus_space_write_le_8(iot, ioh,
+   bus_space_write_8(iot, ioh,
VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset);
-   bus_space_write_le_8(iot, ioh,
+   bus_space_write_8(iot, ioh,
VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset);
bus_space_write_2(iot, ioh,
VIRTIO_CONFIG1_QUEUE_ENABLE, 1);
@@ -771,7 +783,6 @@ virtio_pci_setup_queue_10(struct virtio_
VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR, vec);
}
 }
-#undef bus_space_write_le_8
 
 static void
 virtio_pci_set_status_10(struct virtio_softc *sc, int status)




Re: CVS commit: src/sys/dev/pci/ixgbe

2020-12-10 Thread SAITOH Masanobu

On 2020/12/11 14:01, SAITOH Masanobu wrote:

Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 11 05:01:19 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_type.h

Log Message:
  Don't use EIMC_OTHER bit because it's read only other than 82598.

  Documents say:

   82598:
  All of bit 31(OTHER bit) of EIxx are reserved. In reality, at least
 EIMS_OTHER and EIMC_OTHER exist and the OTHER interrupt doesn't work
 without EIMS_OTHER.

   Other than 82598:


+  EICR's bit 31 is defined and other EIXX's bit 31 are reserved.
+  In reality,


  EIMS_OTHER is read only and EIMC_OTHER doesn't exist. If one of
 bit 29..16 is set, EIMS_OTHER is set to 1 (Note that bit 30(TCP timer
 isn't included)). Even if write bit 31 of EIMC to 1, it's ignored
 (EIMS_OTHER doesn't set).

  We introduced new spin mutex in ixgbe.c rev. 1.260, so it's OK to remove
EIMC_OTHER stuff. We already set EIMS_OTHER in if_init(), so keep it for
82598. No functional change other than 82598.

  Another solution is to control bit 30..16 directly to mask/unmask interrupt
instead of the mutex.

TODO:
   Some MSI-X interrupt(LSC, module insertion/removal etc.)'s mask/unmask
   code between ixgbe_msix_admin() and ixgbe_handle_admin() may be wrong.
   It'll be fixed later.


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/ixgbe/ixgbe_type.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




--
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


Re: CVS commit: src/sys/dev/pci

2020-10-16 Thread SAITOH Masanobu

On 2020/10/16 14:53, SAITOH Masanobu wrote:

Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 16 05:53:40 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
  Fixes a problem that the attach function reported
"wm_gmii_setup_phytype: Unknown PHY model. OUI=00, model=" and
"PHY type is still unknown."


This was dmesg only problem. The SGMII read/write functions were correctly set
even though error message was printed. This problem was added in if_wm.c
rev. 1.656 which added SFP support.


Don't call wm_gmii_setup_phytype() three times if
the interface uses SGMII with internal MDIO.

  Tested with I354(Rangeley(SGMII(MDIO))) and I350(SERDES(SFP), SGMII(SFP)).


To generate a diff of this commit:
cvs rdiff -u -r1.690 -r1.691 src/sys/dev/pci/if_wm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




--
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


Re: CVS commit: src/sys/dev/pci

2020-10-12 Thread Michael
Hello,

On Sun, 11 Oct 2020 21:41:57 +
"Julian Coleman"  wrote:

> Module Name:  src
> Committed By: jdc
> Date: Sun Oct 11 21:41:57 UTC 2020
> 
> Modified Files:
>   src/sys/dev/pci: radeonfb.c
> 
> Log Message:
...
>   don't ignore the bottom 200 lines of the display (for no apparent reason))

The reason I have that in most of my drivers is so I can see a good
part of the glyph cache, which starts right below the VRAM area used by
wsdisplay. Most drivers use it only for anti-aliased fonts so you
probably didn't see anything there...

have fun
Michael


Re: CVS commit: src/sys/dev/pci

2020-07-17 Thread Jaromír Doleček
One of the things which need to be done is calling the if_ioctl always
with the IFNET_LOCK() held. Right now it sometimes is, and other times
it is not, so it's not possible to rely on it and KASSERT().

As for bnx(4) I did just some basic fixes around making it work with
MSI(-X), since I don't really have easy access to the hw for testing.
This might change soon, then I might look into making it NET_MPSAFE,
after some other bug fixes.

Jaromir

Le sam. 18 juil. 2020 à 00:54, Jason Thorpe  a écrit :
>
>
>
> > On Jul 17, 2020, at 3:50 PM, matthew green  wrote:
> >
> > any chance you can look at NET_MPSAFE here etc? :)
>
> I have a bunch of local changes for this in one of my trees, and I hope to 
> get back to it after netbsd-10 branches.
>
> -- thorpej
>


Re: CVS commit: src/sys/dev/pci

2020-07-17 Thread Jason Thorpe



> On Jul 17, 2020, at 3:50 PM, matthew green  wrote:
> 
> any chance you can look at NET_MPSAFE here etc? :)

I have a bunch of local changes for this in one of my trees, and I hope to get 
back to it after netbsd-10 branches.

-- thorpej



re: CVS commit: src/sys/dev/pci

2020-07-17 Thread matthew green
"Jaromir Dolecek" writes:
> Module Name:  src
> Committed By: jdolecek
> Date: Fri Jul 17 09:48:21 UTC 2020
> 
> Modified Files:
>   src/sys/dev/pci: if_bnx.c
> 
> Log Message:
> re-enable MSI/MSI-X, the TX timeouts were caused by the IFF_OACTIVE handling,
> which was fixed in previous revision

"fixed IFF_OACTIVE" in modern netbsd means "removed IFF_OACTIVE
and handled it in the driver", as the flag is not SMP friendly.

any chance you can look at NET_MPSAFE here etc? :)

thanks.


.mrg.


Re: [virtio] Re: CVS commit: src/sys/dev/pci

2020-05-31 Thread Maxime Villard

Le 01/06/2020 à 03:23, Shoichi Yamaguchi a écrit :

Hi,

On Wed, May 27, 2020 at 8:47 PM Shoichi Yamaguchi  wrote:


I modified virtio(4) not to allocate unused memory.
I guess it fixes the issue.

Could you check this?


I confirmed your closing the report on syzbot.
https://syzkaller.appspot.com/bug?id=73f690e8a3d8e304407808555f1dacfa004685d1

Thank you for your response.


Sorry for my lack of response -- I was waiting for the kMSan instance
to sync, but it is currently down, and has been down for four days and
a half now.

The kMSan instance got the time to run 24h before it broke for unrelated
reasons. 24h before your patch, it triggered the bug 6 times. 24h after
your patch, it triggered the bug 0 times.

So indeed, we can call it fixed, thanks for the fix


Re: [virtio] Re: CVS commit: src/sys/dev/pci

2020-05-31 Thread Shoichi Yamaguchi
Hi,

On Wed, May 27, 2020 at 8:47 PM Shoichi Yamaguchi  wrote:
>
> I modified virtio(4) not to allocate unused memory.
> I guess it fixes the issue.
>
> Could you check this?

I confirmed your closing the report on syzbot.
https://syzkaller.appspot.com/bug?id=73f690e8a3d8e304407808555f1dacfa004685d1

Thank you for your response.

Regards,
yamaguchi


Re: [virtio] Re: CVS commit: src/sys/dev/pci

2020-05-27 Thread Shoichi Yamaguchi
Hi,

On Wed, May 27, 2020 at 2:20 AM Maxime Villard  wrote:
>
> Hi,
> I don't know if this is related to your changes, but kMSan detected one uninit
> variable in virtio 3h ago:
>
> https://syzkaller.appspot.com/text?tag=CrashReport=12084ef610
>
> [ 153.4370851] panic: MSan: Uninitialized Kmem Memory From 
> virtio_pci_setup_interrupts()
> [ 153.4448669] cpu0: Begin traceback...
> [ 153.4448669] vpanic() at netbsd:vpanic+0x7c1 sys/kern/subr_prf.c:288
> [ 153.4632004] panic() at netbsd:panic+0x1ad sys/kern/subr_prf.c:209
> [ 153.4734357] __msan_warning() at netbsd:__msan_warning+0xe7 
> kmsan_report_inline sys/kern/subr_msan.c:239 [inline]
> [ 153.4734357] __msan_warning() at netbsd:__msan_warning+0xe7 
> sys/kern/subr_msan.c:612
> [ 153.4931985] virtio_pci_free_interrupts() at 
> netbsd:virtio_pci_free_interrupts+0x1b4 sys/dev/pci/virtio_pci.c:740
> [ 153.5132006] virtio_child_detach() at 
> netbsd:virtio_child_detach+0x116 sys/dev/pci/virtio.c:924
> [ 153.5331982] vioscsi_detach() at netbsd:vioscsi_detach+0x40d 
> sys/dev/pci/vioscsi.c:244
> [ 153.5532009] config_detach() at netbsd:config_detach+0x7e3 
> sys/kern/subr_autoconf.c:1760
> [ 153.5732017] config_detach_all() at netbsd:config_detach_all+0x29a 
> sys/kern/subr_autoconf.c:1906
> [ 153.5831984] cpu_reboot() at netbsd:cpu_reboot+0x290 
> sys/arch/amd64/amd64/machdep.c:700
> [ 153.6031986] kern_reboot() at netbsd:kern_reboot+0x18f 
> sys/kern/kern_reboot.c:73
> [ 153.6231980] sys_reboot() at netbsd:sys_reboot+0x28d
>
> This means that some memory allocated by virtio_pci_setup_interrupts() on
> the kmem allocator was not initialized, and later one access to it was made
> by virtio_pci_free_interrupts() at l.740 of the file.

Thank you for your pointed out.
I modified virtio(4) not to allocate unused memory.
I guess it fixes the issue.

Could you check this?

Thanks,
yamaguchi


[virtio] Re: CVS commit: src/sys/dev/pci

2020-05-26 Thread Maxime Villard

Hi,
I don't know if this is related to your changes, but kMSan detected one uninit
variable in virtio 3h ago:

https://syzkaller.appspot.com/text?tag=CrashReport=12084ef610

[ 153.4370851] panic: MSan: Uninitialized Kmem Memory From 
virtio_pci_setup_interrupts()
[ 153.4448669] cpu0: Begin traceback...
[ 153.4448669] vpanic() at netbsd:vpanic+0x7c1 sys/kern/subr_prf.c:288
[ 153.4632004] panic() at netbsd:panic+0x1ad sys/kern/subr_prf.c:209
[ 153.4734357] __msan_warning() at netbsd:__msan_warning+0xe7 
kmsan_report_inline sys/kern/subr_msan.c:239 [inline]
[ 153.4734357] __msan_warning() at netbsd:__msan_warning+0xe7 
sys/kern/subr_msan.c:612
[ 153.4931985] virtio_pci_free_interrupts() at 
netbsd:virtio_pci_free_interrupts+0x1b4 sys/dev/pci/virtio_pci.c:740
[ 153.5132006] virtio_child_detach() at 
netbsd:virtio_child_detach+0x116 sys/dev/pci/virtio.c:924
[ 153.5331982] vioscsi_detach() at netbsd:vioscsi_detach+0x40d 
sys/dev/pci/vioscsi.c:244
[ 153.5532009] config_detach() at netbsd:config_detach+0x7e3 
sys/kern/subr_autoconf.c:1760
[ 153.5732017] config_detach_all() at netbsd:config_detach_all+0x29a 
sys/kern/subr_autoconf.c:1906
[ 153.5831984] cpu_reboot() at netbsd:cpu_reboot+0x290 
sys/arch/amd64/amd64/machdep.c:700
[ 153.6031986] kern_reboot() at netbsd:kern_reboot+0x18f 
sys/kern/kern_reboot.c:73
[ 153.6231980] sys_reboot() at netbsd:sys_reboot+0x28d

This means that some memory allocated by virtio_pci_setup_interrupts() on
the kmem allocator was not initialized, and later one access to it was made
by virtio_pci_free_interrupts() at l.740 of the file.

Can you have a look?

Thanks,
Maxime


Re: CVS commit: src/sys/dev/pci

2020-05-20 Thread Sevan Janiyan



On 20/05/2020 21:18, Sevan Janiyan wrote:
> Bump rcs tag which was missed in r1.9

That should've been r1.10


Sevan


Re: CVS commit: src/sys/dev/pci

2020-01-14 Thread Masanobu SAITOH
On 2020/01/10 15:59, Jason Thorpe wrote:
> 
> 
>> On Jan 9, 2020, at 9:02 PM, Masanobu SAITOH  wrote:
>>
>> The reason why I moved stge_softc to if_stgereg.h was that ipgphy.c
>> required to check stge's chip revision. So, if there is no any objection,
>> I'll make new if_stgevar.h and share it with if_stge.c and ipgphy.c.
> 
> That seems fine.  Although it might be preferable to set a property on the 
> parent dev_t and then query that from ipgphy,

I've changed by this way. If it use if_stgevar.h and it includes pci related
header file, some archs' kernel which use ipgphy and not use PCI can't be
compiled. Some other MII PHY drivers do so.

 Thanks.

> rather than accessing the softc.
> 
> -- thorpej
> 


-- 
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


Re: CVS commit: src/sys/dev/pci

2020-01-09 Thread Jason Thorpe



> On Jan 9, 2020, at 9:02 PM, Masanobu SAITOH  wrote:
> 
> The reason why I moved stge_softc to if_stgereg.h was that ipgphy.c
> required to check stge's chip revision. So, if there is no any objection,
> I'll make new if_stgevar.h and share it with if_stge.c and ipgphy.c.

That seems fine.  Although it might be preferable to set a property on the 
parent dev_t and then query that from ipgphy, rather than accessing the softc.

-- thorpej



Re: CVS commit: src/sys/dev/pci

2020-01-09 Thread Masanobu SAITOH
On 2020/01/10 13:13, Jason Thorpe wrote:
> 
> 
>> On Jan 9, 2020, at 6:11 PM, Masanobu SAITOH  wrote:
>>
>>
>> Before my change, struct stge_softc is already in if_stgereg.h,
>> so I had thought it would be OK to move to it.
> 
> Ah, I don't think I would have put it there when I wrote the driver 
> originally, so it must have been moved there at some point.
 Oh, it was me :)

http://mail-index.netbsd.org/source-changes/2019/10/07/msg109768.html

>  In any case, moving it into if_stgereg.h was also an error.
> 
>>
>>> Please move them back to if_stge.c.  Doing incorrect things simply to 
>>> reduce the diff against someone else's copy of the code is not something we 
>>> should be undertaking.
>> Two options:
>>
>> a) Move some structs (including struct stge_softc) and defines
>>to if_stge.c
> 
> There is no reason to have if_stgevar.h, because no other modules need these 
> definitions, so it should all move to if_stge.c.

The reason why I moved stge_softc to if_stgereg.h was that ipgphy.c
required to check stge's chip revision. So, if there is no any objection,
I'll make new if_stgevar.h and share it with if_stge.c and ipgphy.c.

> Thanks!
> 
>>
>> b) Move them to new if_stgevar.h
>>
>> Which one is prefer?
> 
> -- thorpej
> 


-- 
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


Re: CVS commit: src/sys/dev/pci

2020-01-09 Thread Jason Thorpe



> On Jan 9, 2020, at 6:11 PM, Masanobu SAITOH  wrote:
> 
> 
> Before my change, struct stge_softc is already in if_stgereg.h,
> so I had thought it would be OK to move to it.

Ah, I don't think I would have put it there when I wrote the driver originally, 
so it must have been moved there at some point.  In any case, moving it into 
if_stgereg.h was also an error.

> 
>> Please move them back to if_stge.c.  Doing incorrect things simply to reduce 
>> the diff against someone else's copy of the code is not something we should 
>> be undertaking.
> Two options:
> 
> a) Move some structs (including struct stge_softc) and defines
>to if_stge.c

There is no reason to have if_stgevar.h, because no other modules need these 
definitions, so it should all move to if_stge.c.

Thanks!

> 
> b) Move them to new if_stgevar.h
> 
> Which one is prefer?

-- thorpej



re: CVS commit: src/sys/dev/pci

2020-01-09 Thread matthew green
>  Two options:
> 
>  a) Move some structs (including struct stge_softc) and defines
> to if_stge.c
> 
>  b) Move them to new if_stgevar.h

i've always preferred:

  - fooreg.h and foovar.h exist only when more than 1
file use them

  - fooreg.h ONLY has hardware constructs

  - foovar.h ONLY has software constructs

though i tend to only delete single-use foovar.h, not fooreg.h.


.mrg.


Re: CVS commit: src/sys/dev/pci

2020-01-09 Thread Masanobu SAITOH
On 2020/01/09 23:08, Jason Thorpe wrote:
> 
> 
>> On Jan 9, 2020, at 2:54 AM, SAITOH Masanobu  wrote:
>>
>> Module Name: src
>> Committed By:msaitoh
>> Date:Thu Jan  9 10:54:16 UTC 2020
>>
>> Modified Files:
>>  src/sys/dev/pci: if_stge.c if_stgereg.h
>>
>> Log Message:
>> Reduce diff against OpenBSD. No functional change.
>>
>> - USE CSR_{READ,WRITE}_*() macro.
>> - Move some macros from if_stge.c to if_stgereg.h
> 
> This diff is incorrect.

Yes. You're right.

>  The macros that were moved to if_stgereg.h are not related to hardware / 
> register definitions, but are purely software constructs.

Before my change, struct stge_softc is already in if_stgereg.h,
so I had thought it would be OK to move to it.

>  Please move them back to if_stge.c.  Doing incorrect things simply to reduce 
> the diff against someone else's copy of the code is not something we should 
> be undertaking.
 Two options:

 a) Move some structs (including struct stge_softc) and defines
to if_stge.c

 b) Move them to new if_stgevar.h

Which one is prefer?

> -- thorpej
> 


-- 
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


Re: CVS commit: src/sys/dev/pci

2020-01-09 Thread Jason Thorpe



> On Jan 9, 2020, at 2:54 AM, SAITOH Masanobu  wrote:
> 
> Module Name:  src
> Committed By: msaitoh
> Date: Thu Jan  9 10:54:16 UTC 2020
> 
> Modified Files:
>   src/sys/dev/pci: if_stge.c if_stgereg.h
> 
> Log Message:
> Reduce diff against OpenBSD. No functional change.
> 
> - USE CSR_{READ,WRITE}_*() macro.
> - Move some macros from if_stge.c to if_stgereg.h

This diff is incorrect.  The macros that were moved to if_stgereg.h are not 
related to hardware / register definitions, but are purely software constructs. 
 Please move them back to if_stge.c.  Doing incorrect things simply to reduce 
the diff against someone else's copy of the code is not something we should be 
undertaking.

-- thorpej



CVS commit: src/sys/dev/pci

2019-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 29 15:17:14 UTC 2019

Modified Files:
src/sys/dev/pci: if_mcx.c

Log Message:
Set if_baudrate.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.8 src/sys/dev/pci/if_mcx.c:1.9
--- src/sys/dev/pci/if_mcx.c:1.8	Thu Nov 28 16:02:07 2019
+++ src/sys/dev/pci/if_mcx.c	Fri Nov 29 15:17:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.8 2019/11/28 16:02:07 msaitoh Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.9 2019/11/29 15:17:14 msaitoh Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -6653,6 +6653,7 @@ mcx_port_change(struct work *wk, void *x
 	struct ifnet *ifp = >sc_ec.ec_if;
 	struct mcx_reg_paos paos;
 	int link_state = LINK_STATE_DOWN;
+	struct ifmediareq ifmr;
 
 	memset(, 0, sizeof(paos));
 	paos.rp_local_port = 1;
@@ -6660,6 +6661,8 @@ mcx_port_change(struct work *wk, void *x
 	sizeof(paos)) == 0) {
 		if (paos.rp_oper_status == MCX_REG_PAOS_OPER_STATUS_UP)
 			link_state = LINK_STATE_UP;
+		mcx_media_status(ifp, );
+		ifp->if_baudrate = ifmedia_baudrate(ifmr.ifm_active);
 	}
 
 	if (link_state != ifp->if_link_state) {



CVS commit: src/sys/dev/pci

2019-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 29 15:17:14 UTC 2019

Modified Files:
src/sys/dev/pci: if_mcx.c

Log Message:
Set if_baudrate.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-28 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Nov 29 05:47:26 UTC 2019

Modified Files:
src/sys/dev/pci: if_kse.c

Log Message:
switch to deferred if_start framework.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_kse.c
diff -u src/sys/dev/pci/if_kse.c:1.42 src/sys/dev/pci/if_kse.c:1.43
--- src/sys/dev/pci/if_kse.c:1.42	Tue Nov 26 08:37:05 2019
+++ src/sys/dev/pci/if_kse.c	Fri Nov 29 05:47:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_kse.c,v 1.42 2019/11/26 08:37:05 nisimura Exp $	*/
+/*	$NetBSD: if_kse.c,v 1.43 2019/11/29 05:47:26 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.42 2019/11/26 08:37:05 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.43 2019/11/29 05:47:26 nisimura Exp $");
 
 #include 
 #include 
@@ -567,6 +567,7 @@ kse_attach(device_t parent, device_t sel
 	IFCAP_CSUM_UDPv4_Tx | IFCAP_CSUM_UDPv4_Rx;
 
 	if_attach(ifp);
+	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, enaddr);
 
 #ifdef KSE_EVENT_COUNTERS
@@ -1012,7 +1013,8 @@ kse_start(struct ifnet *ifp)
 		bus_dmamap_sync(sc->sc_dmat, dmamap, 0, dmamap->dm_mapsize,
 		BUS_DMASYNC_PREWRITE);
 
-		lasttx = -1; tdes0 = 0;
+		tdes0 = 0; /* to postpone 1st segment T0_OWN write */
+		lasttx = -1;
 		for (nexttx = sc->sc_txnext, seg = 0;
 		 seg < dmamap->dm_nsegs;
 		 seg++, nexttx = KSE_NEXTTX(nexttx)) {
@@ -1027,10 +1029,9 @@ kse_start(struct ifnet *ifp)
 			tdes->t1 = sc->sc_t1csum
 			 | (dmamap->dm_segs[seg].ds_len & T1_TBS_MASK);
 			tdes->t0 = tdes0;
-			tdes0 |= T0_OWN;
+			tdes0 = T0_OWN; /* 2nd and other segments */
 			lasttx = nexttx;
 		}
-
 		/*
 		 * Outgoing NFS mbuf must be unloaded when Tx completed.
 		 * Without T1_IC NFS mbuf is left unack'ed for excessive
@@ -1047,7 +1048,7 @@ kse_start(struct ifnet *ifp)
 			}
 		} while ((m = m->m_next) != NULL);
 
-		/* Write last T0_OWN bit of the 1st segment */
+		/* Write deferred 1st segment T0_OWN at the final stage */
 		sc->sc_txdescs[lasttx].t1 |= T1_LS;
 		sc->sc_txdescs[sc->sc_txnext].t1 |= T1_FS;
 		sc->sc_txdescs[sc->sc_txnext].t0 = T0_OWN;
@@ -1188,6 +1189,7 @@ static int
 kse_intr(void *arg)
 {
 	struct kse_softc *sc = arg;
+	struct ifnet *ifp = >sc_ethercom.ec_if;
 	uint32_t isr;
 
 	if ((isr = CSR_READ_4(sc, INTST)) == 0)
@@ -1203,6 +1205,10 @@ kse_intr(void *arg)
 		aprint_error_dev(sc->sc_dev, "Rx descriptor full\n");
 
 	CSR_WRITE_4(sc, INTST, isr);
+
+	if (ifp->if_flags & IFF_RUNNING)
+		if_schedule_deferred_start(ifp);
+
 	return 1;
 }
 



CVS commit: src/sys/dev/pci

2019-11-28 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Nov 29 05:47:26 UTC 2019

Modified Files:
src/sys/dev/pci: if_kse.c

Log Message:
switch to deferred if_start framework.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 28 16:02:07 UTC 2019

Modified Files:
src/sys/dev/pci: if_mcx.c

Log Message:
- Change IFM_10G_T(10GBase-T) entry to IFM_10G_CR1(10GBASE-CR1)
- Add the following entries:

20GBASE-KR2
56GBASE-R4
100GBASE-LR4
100BaseTX
1000baseT
10GBase-T


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.7 src/sys/dev/pci/if_mcx.c:1.8
--- src/sys/dev/pci/if_mcx.c:1.7	Tue Nov 26 10:33:19 2019
+++ src/sys/dev/pci/if_mcx.c	Thu Nov 28 16:02:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.7 2019/11/26 10:33:19 jmcneill Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.8 2019/11/28 16:02:07 msaitoh Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -159,8 +159,10 @@
 #define MCX_ETHER_CAP_10G_CX4	(1 << 2)
 #define MCX_ETHER_CAP_10G_KX4	(1 << 3)
 #define MCX_ETHER_CAP_10G_KR	(1 << 4)
+#define MCX_ETHER_CAP_20G_KR2	(1 << 5)
 #define MCX_ETHER_CAP_40G_CR4	(1 << 6)
 #define MCX_ETHER_CAP_40G_KR4	(1 << 7)
+#define MCX_ETHER_CAP_56G_R4	(1 << 8)
 #define MCX_ETHER_CAP_10G_CR	(1 << 12)
 #define MCX_ETHER_CAP_10G_SR	(1 << 13)
 #define MCX_ETHER_CAP_10G_LR	(1 << 14)
@@ -170,6 +172,10 @@
 #define MCX_ETHER_CAP_100G_CR4	(1 << 20)
 #define MCX_ETHER_CAP_100G_SR4	(1 << 21)
 #define MCX_ETHER_CAP_100G_KR4	(1 << 22)
+#define MCX_ETHER_CAP_100G_LR4	(1 << 23)
+#define MCX_ETHER_CAP_100_TX	(1 << 24)
+#define MCX_ETHER_CAP_1000_T	(1 << 25)
+#define MCX_ETHER_CAP_10G_T	(1 << 26)
 #define MCX_ETHER_CAP_25G_CR	(1 << 27)
 #define MCX_ETHER_CAP_25G_KR	(1 << 28)
 #define MCX_ETHER_CAP_25G_SR	(1 << 29)
@@ -2146,14 +2152,14 @@ static const uint64_t mcx_eth_cap_map[] 
 	IFM_10G_CX4,
 	IFM_10G_KX4,
 	IFM_10G_KR,
-	0,
+	IFM_20G_KR2,
 	IFM_40G_CR4,
 	IFM_40G_KR4,
+	IFM_56G_R4,
 	0,
 	0,
 	0,
-	0,
-	IFM_10G_T,
+	IFM_10G_CR1,
 	IFM_10G_SR,
 	IFM_10G_LR,
 	IFM_40G_SR4,
@@ -2164,10 +2170,10 @@ static const uint64_t mcx_eth_cap_map[] 
 	IFM_100G_CR4,
 	IFM_100G_SR4,
 	IFM_100G_KR4,
-	0,
-	0,
-	0,
-	0,
+	IFM_100G_LR4,
+	IFM_100_TX,
+	IFM_1000_T,
+	IFM_10G_T,
 	IFM_25G_CR,
 	IFM_25G_KR,
 	IFM_25G_SR,



CVS commit: src/sys/dev/pci

2019-11-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 28 16:02:07 UTC 2019

Modified Files:
src/sys/dev/pci: if_mcx.c

Log Message:
- Change IFM_10G_T(10GBase-T) entry to IFM_10G_CR1(10GBASE-CR1)
- Add the following entries:

20GBASE-KR2
56GBASE-R4
100GBASE-LR4
100BaseTX
1000baseT
10GBase-T


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 27 03:47:06 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
 Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.1379 -r1.1380 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1378 -r1.1379 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 27 03:45:54 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
- Add Xeon D-1500 NTB-secondary
- Add Xeon D NS QuickData DMA channel 0-7


To generate a diff of this commit:
cvs rdiff -u -r1.1391 -r1.1392 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1391 src/sys/dev/pci/pcidevs:1.1392
--- src/sys/dev/pci/pcidevs:1.1391	Thu Nov 14 09:10:41 2019
+++ src/sys/dev/pci/pcidevs	Wed Nov 27 03:45:54 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1391 2019/11/14 09:10:41 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1392 2019/11/27 03:45:54 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -4995,6 +4995,7 @@ product INTEL XEOND_PCIE_9	0x6f0a	Core i
 product INTEL XEOND_PCIE_10	0x6f0b	Core i7-6xxxK/Xeon-D PCIe Root Port (x16, x8 or x4 max)
 product INTEL XEOND_PCIE_NTBNTB	0x6f0d	Xeon-D PCIe Root Port NTB-NTB
 product INTEL XEOND_PCIE_NTBRP	0x6f0e	Xeon-D PCIe Root Port NTB-RP
+product INTEL XEOND_PCIE_NTB2ND	0x6f0f	Xeon-D PCIe Root Port NTB-secondary
 product INTEL XEOND_IIO_DEBUG_0	0x6f10	Xeon-D IIO Debug
 product INTEL XEOND_IIO_DEBUG_1	0x6f11	Xeon-D IIO Debug
 product INTEL XEOND_IIO_DEBUG_2	0x6f12	Xeon-D IIO Debug
@@ -5011,7 +5012,15 @@ product INTEL XEOND_IIO_DEBUG_12 0x6f1c	
 product INTEL XEOND_R2_0	0x6f1d	Xeon-D R2 PCIe Agent
 product INTEL XEOND_UBOX_0	0x6f1e	Core i7-6xxxK/Xeon-D Ubox
 product INTEL XEOND_UBOX_1	0x6f1f	Core i7-6xxxK/Xeon-D Ubox
-product INTEL XEOND_ADDRMAP	0x6f28	Core i7-6xxxK/Xeon-D IIO Address Map, VTD_Misc, System Management
+product INTEL XEONDNS_QD_0	0x6f20	Xeon-D NS QuickData DMA Channel 0
+product INTEL XEONDNS_QD_1	0x6f21	Xeon-D NS QuickData DMA Channel 1
+product INTEL XEONDNS_QD_2	0x6f22	Xeon-D NS QuickData DMA Channel 2
+product INTEL XEONDNS_QD_3	0x6f23	Xeon-D NS QuickData DMA Channel 3
+product INTEL XEONDNS_QD_4	0x6f24	Xeon-D NS QuickData DMA Channel 4
+product INTEL XEONDNS_QD_5	0x6f25	Xeon-D NS QuickData DMA Channel 5
+product INTEL XEONDNS_QD_6	0x6f26	Xeon-D NS QuickData DMA Channel 6
+product INTEL XEONDNS_QD_7	0x6f27	Xeon-D NS QuickData DMA Channel 7
+product INTEL XEONDNS_ADDRMAP	0x6f28	Core i7-6xxxK/Xeon-D IIO Address Map, VTD_Misc, System Management
 product INTEL XEOND_HOTPLUG	0x6f29	Xeon-D IIO Hot Plug
 product INTEL XEOND_RAS		0x6f2a	Core i7-6xxxK/Xeon-D IIO RAS, Control Status, Global Errors
 product INTEL XEOND_IOAPIC_2	0x6f2c	Core i7-6xxxK/Xeon-D I/O APIC



CVS commit: src/sys/dev/pci

2019-11-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 27 03:45:54 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
- Add Xeon D-1500 NTB-secondary
- Add Xeon D NS QuickData DMA channel 0-7


To generate a diff of this commit:
cvs rdiff -u -r1.1391 -r1.1392 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 26 10:33:19 UTC 2019

Modified Files:
src/sys/dev/pci: if_mcx.c

Log Message:
Fix IFF_ALLMULTI handling.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.6 src/sys/dev/pci/if_mcx.c:1.7
--- src/sys/dev/pci/if_mcx.c:1.6	Mon Nov 18 04:40:05 2019
+++ src/sys/dev/pci/if_mcx.c	Tue Nov 26 10:33:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.6 2019/11/18 04:40:05 nonaka Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.7 2019/11/26 10:33:19 jmcneill Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -6205,8 +6205,11 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 {
 	struct mcx_softc *sc = (struct mcx_softc *)ifp->if_softc;
 	struct ifreq *ifr = (struct ifreq *)data;
+	struct ethercom *ec = >sc_ec;
 	uint8_t addrhi[ETHER_ADDR_LEN], addrlo[ETHER_ADDR_LEN];
-	int s, i, error = 0;
+	struct ether_multi *enm;
+	struct ether_multistep step;
+	int s, i, flags, error = 0;
 
 	s = splnet();
 	switch (cmd) {
@@ -6214,8 +6217,10 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 	case SIOCADDMULTI:
 		if (ether_addmulti(ifreq_getaddr(cmd, ifr), >sc_ec) == ENETRESET) {
 			error = ether_multiaddr(>ifr_addr, addrlo, addrhi);
-			if (error != 0)
+			if (error != 0) {
+splx(s);
 return (error);
+			}
 
 			for (i = 0; i < MCX_NUM_MCAST_FLOWS; i++) {
 if (sc->sc_mcast_flows[i][0] == 0) {
@@ -6238,7 +6243,7 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 	error = ENETRESET;
 }
 
-if (sc->sc_ec.ec_multicnt > 0) {
+if (memcmp(addrlo, addrhi, ETHER_ADDR_LEN)) {
 	SET(ifp->if_flags, IFF_ALLMULTI);
 	error = ENETRESET;
 }
@@ -6249,8 +6254,10 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 	case SIOCDELMULTI:
 		if (ether_delmulti(ifreq_getaddr(cmd, ifr), >sc_ec) == ENETRESET) {
 			error = ether_multiaddr(>ifr_addr, addrlo, addrhi);
-			if (error != 0)
+			if (error != 0) {
+splx(s);
 return (error);
+			}
 
 			for (i = 0; i < MCX_NUM_MCAST_FLOWS; i++) {
 if (memcmp(sc->sc_mcast_flows[i], addrlo,
@@ -6269,10 +6276,23 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd,
 sc->sc_extra_mcast--;
 
 			if (ISSET(ifp->if_flags, IFF_ALLMULTI) &&
-			(sc->sc_extra_mcast == 0) &&
-			(sc->sc_ec.ec_multicnt == 0)) {
-CLR(ifp->if_flags, IFF_ALLMULTI);
-error = ENETRESET;
+			sc->sc_extra_mcast == 0) {
+flags = 0;
+ETHER_LOCK(ec);
+ETHER_FIRST_MULTI(step, ec, enm);
+while (enm != NULL) {
+	if (memcmp(enm->enm_addrlo,
+	enm->enm_addrhi, ETHER_ADDR_LEN)) {
+		SET(flags, IFF_ALLMULTI);
+		break;
+	}
+	ETHER_NEXT_MULTI(step, enm);
+}
+ETHER_UNLOCK(ec);
+if (!ISSET(flags, IFF_ALLMULTI)) {
+	CLR(ifp->if_flags, IFF_ALLMULTI);
+	error = ENETRESET;
+}
 			}
 		}
 		break;



CVS commit: src/sys/dev/pci

2019-11-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 26 10:33:19 UTC 2019

Modified Files:
src/sys/dev/pci: if_mcx.c

Log Message:
Fix IFF_ALLMULTI handling.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Nov 26 08:37:05 UTC 2019

Modified Files:
src/sys/dev/pci: files.pci if_kse.c

Log Message:
- use mii(4) layer to control KSZ8841 builtin PHY.
- handle PAUSE flow control properly according to ifconfig(8) mediaopt
  selection.
- some style knits; use aprint(9) and modernise callout(9).


To generate a diff of this commit:
cvs rdiff -u -r1.416 -r1.417 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Nov 26 08:37:05 UTC 2019

Modified Files:
src/sys/dev/pci: files.pci if_kse.c

Log Message:
- use mii(4) layer to control KSZ8841 builtin PHY.
- handle PAUSE flow control properly according to ifconfig(8) mediaopt
  selection.
- some style knits; use aprint(9) and modernise callout(9).


To generate a diff of this commit:
cvs rdiff -u -r1.416 -r1.417 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/files.pci
diff -u src/sys/dev/pci/files.pci:1.416 src/sys/dev/pci/files.pci:1.417
--- src/sys/dev/pci/files.pci:1.416	Wed Nov 20 09:37:45 2019
+++ src/sys/dev/pci/files.pci	Tue Nov 26 08:37:05 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.416 2019/11/20 09:37:45 hikaru Exp $
+#	$NetBSD: files.pci,v 1.417 2019/11/26 08:37:05 nisimura Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -965,7 +965,7 @@ attach  nfe at pci
 filedev/pci/if_nfe.cnfe
 
 # MICREL Etherent
-device	kse: ether, ifnet, arp
+device	kse: ether, ifnet, arp, mii
 attach	kse at pci
 file	dev/pci/if_kse.c		kse
 

Index: src/sys/dev/pci/if_kse.c
diff -u src/sys/dev/pci/if_kse.c:1.41 src/sys/dev/pci/if_kse.c:1.42
--- src/sys/dev/pci/if_kse.c:1.41	Thu Nov  7 22:00:37 2019
+++ src/sys/dev/pci/if_kse.c	Tue Nov 26 08:37:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_kse.c,v 1.41 2019/11/07 22:00:37 nisimura Exp $	*/
+/*	$NetBSD: if_kse.c,v 1.42 2019/11/26 08:37:05 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,11 +30,11 @@
  */
 
 /*
- * Micrel 8841/8842 10/100 ethernet driver
+ * Micrel 8841/8842 10/100 PCI ethernet driver
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.41 2019/11/07 22:00:37 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.42 2019/11/26 08:37:05 nisimura Exp $");
 
 #include 
 #include 
@@ -55,6 +55,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -68,9 +70,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1
 #define CSR_WRITE_4(sc, off, val) \
 	bus_space_write_4(sc->sc_st, sc->sc_sh, off, val)
 #define CSR_READ_2(sc, off) \
-	bus_space_read_2(sc->sc_st, sc->sc_sh, off)
+	bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (off))
 #define CSR_WRITE_2(sc, off, val) \
-	bus_space_write_2(sc->sc_st, sc->sc_sh, off, val)
+	bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (off), (val))
 
 #define MDTXC	0x000	/* DMA transmit control */
 #define MDRXC	0x004	/* DMA receive control */
@@ -86,8 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1
 #define MARM	0x202	/* MAC address middle */
 #define MARH	0x204	/* MAC address high */
 #define GRR	0x216	/* global reset */
-#define CIDR	0x400	/* chip ID and enable */
-#define CGCR	0x40a	/* chip global control */
+#define SIDER	0x400	/* switch ID and function enable */
 #define IACR	0x4a0	/* indirect access control */
 #define IADR1	0x4a2	/* indirect access data 66:63 */
 #define IADR2	0x4a4	/* indirect access data 47:32 */
@@ -98,24 +99,27 @@ __KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1
 #define P1SR	0x514	/* port 1 status */
 #define P2CR4	0x532	/* port 2 control 4 */
 #define P2SR	0x534	/* port 2 status */
-#define PxCR_STARTNEG	(1U << 9)	/* restart auto negotiation */
-#define PxCR_AUTOEN	(1U << 7)	/* auto negotiation enable */
-#define PxCR_SPD100	(1U << 6)	/* force speed 100 */
-#define PxCR_USEFDX	(1U << 5)	/* force full duplex */
-#define PxCR_USEFC	(1U << 4)	/* advertise pause flow control */
-#define PxSR_ACOMP	(1U << 6)	/* auto negotiation completed */
-#define PxSR_SPD100	(1U << 10)	/* speed is 100Mbps */
-#define PxSR_FDX	(1U << 9)	/* full duplex */
-#define PxSR_LINKUP	(1U << 5)	/* link is good */
-#define PxSR_RXFLOW	(1U << 12)	/* receive flow control active */
-#define PxSR_TXFLOW	(1U << 11)	/* transmit flow control active */
+#define  PxCR_STARTNEG	(1U<<9)		/* restart auto negotiation */
+#define  PxCR_AUTOEN	(1U<<7)		/* auto negotiation enable */
+#define  PxCR_SPD100	(1U<<6)		/* force speed 100 */
+#define  PxCR_USEFDX	(1U<<5)		/* force full duplex */
+#define  PxCR_USEFC	(1U<<4)		/* advertise pause flow control */
+#define  PxSR_ACOMP	(1U<<6)		/* auto negotiation completed */
+#define  PxSR_SPD100	(1U<<10)	/* speed is 100Mbps */
+#define  PxSR_FDX	(1U<<9)		/* full duplex */
+#define  PxSR_LINKUP	(1U<<5)		/* link is good */
+#define  PxSR_RXFLOW	(1U<<12)	/* receive flow control active */
+#define  PxSR_TXFLOW	(1U<<11)	/* transmit flow control active */
+#define P1VIDCR	0x504	/* port 1 vtag */
+#define P2VIDCR	0x524	/* port 2 vtag */
+#define P3VIDCR	0x544	/* 8842 host vtag */
 
 #define TXC_BS_MSK	0x3f00	/* burst size */
 #define TXC_BS_SFT	(24)		/* 1,2,4,8,16,32 or 0 for unlimited 

CVS commit: src/sys/dev/pci

2019-11-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 25 05:35:26 UTC 2019

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
 Modify PHY initialization code. This change fix a bug that SK-9D21 doesn't
detect MII PHY.
 - Add error check to bge_miibus_writereg().
 - Change return value of bge_miibus_readreg() when a read error occurred.
   It also add error message using with aprint_debug_dev(). This error occurs
   on some devices while detecting MII devices.
 - Move the location of BGE_MI_MODE register's initialization to next to
   bge_chipinit().
 - Set BGE_MAC_MODE before calling ifmedia_init() and/or mii_attach().
 - Add retry code for mii_attach() failed. Same as FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/sys/dev/pci/if_bge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 25 05:35:26 UTC 2019

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
 Modify PHY initialization code. This change fix a bug that SK-9D21 doesn't
detect MII PHY.
 - Add error check to bge_miibus_writereg().
 - Change return value of bge_miibus_readreg() when a read error occurred.
   It also add error message using with aprint_debug_dev(). This error occurs
   on some devices while detecting MII devices.
 - Move the location of BGE_MI_MODE register's initialization to next to
   bge_chipinit().
 - Set BGE_MAC_MODE before calling ifmedia_init() and/or mii_attach().
 - Add retry code for mii_attach() failed. Same as FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/sys/dev/pci/if_bge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.341 src/sys/dev/pci/if_bge.c:1.342
--- src/sys/dev/pci/if_bge.c:1.341	Mon Nov 25 05:18:59 2019
+++ src/sys/dev/pci/if_bge.c	Mon Nov 25 05:35:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.341 2019/11/25 05:18:59 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.342 2019/11/25 05:35:26 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.341 2019/11/25 05:18:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.342 2019/11/25 05:35:26 msaitoh Exp $");
 
 #include 
 #include 
@@ -1113,9 +1113,11 @@ bge_miibus_readreg(device_t dev, int phy
 	if (i == BGE_TIMEOUT) {
 		aprint_error_dev(sc->bge_dev, "PHY read timed out\n");
 		rv = ETIMEDOUT;
-	} else if ((data & BGE_MICOMM_READFAIL) != 0)
-		rv = -1;
-	else
+	} else if ((data & BGE_MICOMM_READFAIL) != 0) {
+		/* XXX This error occurs on some devices while attaching. */
+		aprint_debug_dev(sc->bge_dev, "PHY read I/O error\n");
+		rv = EIO;
+	} else
 		*val = data & BGE_MICOMM_DATA;
 
 	if (autopoll & BGE_MIMODE_AUTOPOLL) {
@@ -1133,7 +1135,8 @@ static int
 bge_miibus_writereg(device_t dev, int phy, int reg, uint16_t val)
 {
 	struct bge_softc *sc = device_private(dev);
-	uint32_t autopoll;
+	uint32_t data, autopoll;
+	int rv = 0;
 	int i;
 
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906 &&
@@ -1156,13 +1159,22 @@ bge_miibus_writereg(device_t dev, int ph
 
 	for (i = 0; i < BGE_TIMEOUT; i++) {
 		delay(10);
-		if (!(CSR_READ_4(sc, BGE_MI_COMM) & BGE_MICOMM_BUSY)) {
+		data = CSR_READ_4(sc, BGE_MI_COMM);
+		if (!(data & BGE_MICOMM_BUSY)) {
 			delay(5);
-			CSR_READ_4(sc, BGE_MI_COMM);
+			data = CSR_READ_4(sc, BGE_MI_COMM);
 			break;
 		}
 	}
 
+	if (i == BGE_TIMEOUT) {
+		aprint_error_dev(sc->bge_dev, "PHY write timed out\n");
+		rv = ETIMEDOUT;
+	} else if ((data & BGE_MICOMM_READFAIL) != 0) {
+		aprint_error_dev(sc->bge_dev, "PHY write I/O error\n");
+		rv = EIO;
+	}
+
 	if (autopoll & BGE_MIMODE_AUTOPOLL) {
 		BGE_STS_SETBIT(sc, BGE_STS_AUTOPOLL);
 		BGE_SETBIT_FLUSH(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL);
@@ -1176,7 +1188,7 @@ bge_miibus_writereg(device_t dev, int ph
 		return ETIMEDOUT;
 	}
 
-	return 0;
+	return rv;
 }
 
 static void
@@ -3176,14 +3188,14 @@ bge_attach(device_t parent, device_t sel
 	uint32_t		command;
 	struct ifnet		*ifp;
 	struct mii_data * const mii = >bge_mii;
-	uint32_t		misccfg, mimode;
+	uint32_t		misccfg, mimode, macmode;
 	void *			kva;
 	u_char			eaddr[ETHER_ADDR_LEN];
 	pcireg_t		memtype, subid, reg;
 	bus_addr_t		memaddr;
 	uint32_t		pm_ctl;
 	bool			no_seeprom;
-	int			capmask;
+	int			capmask, trys;
 	int			mii_flags;
 	int			map_flags;
 	char intrbuf[PCI_INTRSTR_LEN];
@@ -3427,15 +3439,6 @@ bge_attach(device_t parent, device_t sel
 	BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57780)
 		sc->bge_flags |= BGEF_CPMU_PRESENT;
 
-	/* Set MI_MODE */
-	mimode = BGE_MIMODE_PHYADDR(sc->bge_phy_addr);
-	if ((sc->bge_flags & BGEF_CPMU_PRESENT) != 0)
-		mimode |= BGE_MIMODE_500KHZ_CONST;
-	else
-		mimode |= BGE_MIMODE_BASE;
-	CSR_WRITE_4(sc, BGE_MI_MODE, mimode);
-	DELAY(80);
-
 	/*
 	 * When using the BCM5701 in PCI-X mode, data corruption has
 	 * been observed in the first few bytes of some received packets.
@@ -3680,6 +3683,21 @@ bge_attach(device_t parent, device_t sel
 		return;
 	}
 
+	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5700) {
+		BGE_SETBIT_FLUSH(sc, BGE_MISC_LOCAL_CTL,
+		BGE_MLC_MISCIO_OUT1 | BGE_MLC_MISCIO_OUTEN1);
+		DELAY(100);
+	}
+
+	/* Set MI_MODE */
+	mimode = BGE_MIMODE_PHYADDR(sc->bge_phy_addr);
+	if ((sc->bge_flags & BGEF_CPMU_PRESENT) != 0)
+		mimode |= BGE_MIMODE_500KHZ_CONST;
+	else
+		mimode |= BGE_MIMODE_BASE;
+	CSR_WRITE_4_FLUSH(sc, BGE_MI_MODE, mimode);
+	DELAY(80);
+
 	/*
 	 * Get station address from the EEPROM.
 	 */
@@ -3866,8 +3884,14 @@ bge_attach(device_t parent, device_t sel
 	prop_dictionary_set_uint32(dict, "phyflags", sc->bge_phy_flags);
 	prop_dictionary_set_uint32(dict, "chipid", 

CVS commit: src/sys/dev/pci

2019-11-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 25 05:18:59 UTC 2019

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
- Use *_FLUSH() more. The main purpose is to wait following delay() correctly.
- Add missing DELAY(80) after writing BGE_MI_MODE register.


To generate a diff of this commit:
cvs rdiff -u -r1.340 -r1.341 src/sys/dev/pci/if_bge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.340 src/sys/dev/pci/if_bge.c:1.341
--- src/sys/dev/pci/if_bge.c:1.340	Mon Nov 25 04:52:27 2019
+++ src/sys/dev/pci/if_bge.c	Mon Nov 25 05:18:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.340 2019/11/25 04:52:27 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.341 2019/11/25 05:18:59 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.340 2019/11/25 04:52:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.341 2019/11/25 05:18:59 msaitoh Exp $");
 
 #include 
 #include 
@@ -1027,10 +1027,10 @@ bge_eeprom_getbyte(struct bge_softc *sc,
 	 * Enable use of auto EEPROM access so we can avoid
 	 * having to use the bitbang method.
 	 */
-	BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
+	BGE_SETBIT_FLUSH(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
 
 	/* Reset the EEPROM, load the clock period. */
-	CSR_WRITE_4(sc, BGE_EE_ADDR,
+	CSR_WRITE_4_FLUSH(sc, BGE_EE_ADDR,
 	BGE_EEADDR_RESET | BGE_EEHALFCLK(BGE_HALFCLK_384SCL));
 	DELAY(20);
 
@@ -2280,7 +2280,7 @@ bge_chipinit(struct bge_softc *sc)
 #endif
 
 	/* Set the timer prescaler (always 66MHz) */
-	CSR_WRITE_4(sc, BGE_MISC_CFG, BGE_32BITTIME_66MHZ);
+	CSR_WRITE_4_FLUSH(sc, BGE_MISC_CFG, BGE_32BITTIME_66MHZ);
 
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906) {
 		DELAY(40);	/* XXX */
@@ -3434,6 +3434,7 @@ bge_attach(device_t parent, device_t sel
 	else
 		mimode |= BGE_MIMODE_BASE;
 	CSR_WRITE_4(sc, BGE_MI_MODE, mimode);
+	DELAY(80);
 
 	/*
 	 * When using the BCM5701 in PCI-X mode, data corruption has
@@ -3630,10 +3631,10 @@ bge_attach(device_t parent, device_t sel
 	 * Reset NVRAM before bge_reset(). It's required to acquire NVRAM
 	 * lock in bge_reset().
 	 */
-	CSR_WRITE_4(sc, BGE_EE_ADDR,
+	CSR_WRITE_4_FLUSH(sc, BGE_EE_ADDR,
 	BGE_EEADDR_RESET | BGE_EEHALFCLK(BGE_HALFCLK_384SCL));
 	delay(1000);
-	BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
+	BGE_SETBIT_FLUSH(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
 
 	bge_stop_fw(sc);
 	bge_sig_pre_reset(sc, BGE_RESET_START);
@@ -5670,10 +5671,10 @@ bge_ifmedia_upd(struct ifnet *ifp)
 			break;
 		case IFM_1000_SX:
 			if ((ifm->ifm_media & IFM_FDX) != 0) {
-BGE_CLRBIT(sc, BGE_MAC_MODE,
+BGE_CLRBIT_FLUSH(sc, BGE_MAC_MODE,
 BGE_MACMODE_HALF_DUPLEX);
 			} else {
-BGE_SETBIT(sc, BGE_MAC_MODE,
+BGE_SETBIT_FLUSH(sc, BGE_MAC_MODE,
 BGE_MACMODE_HALF_DUPLEX);
 			}
 			DELAY(40);
@@ -6071,7 +6072,7 @@ bge_link_upd(struct bge_softc *sc)
 BGE_STS_SETBIT(sc, BGE_STS_LINK);
 if (BGE_ASICREV(sc->bge_chipid)
 == BGE_ASICREV_BCM5704) {
-	BGE_CLRBIT(sc, BGE_MAC_MODE,
+	BGE_CLRBIT_FLUSH(sc, BGE_MAC_MODE,
 	BGE_MACMODE_TBI_SEND_CFGS);
 	DELAY(40);
 }



CVS commit: src/sys/dev/pci

2019-11-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 25 05:18:59 UTC 2019

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
- Use *_FLUSH() more. The main purpose is to wait following delay() correctly.
- Add missing DELAY(80) after writing BGE_MI_MODE register.


To generate a diff of this commit:
cvs rdiff -u -r1.340 -r1.341 src/sys/dev/pci/if_bge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 25 04:52:27 UTC 2019

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
 Fix a bug that SK-9D41 can't detect fiber media. Check the subsystem ID
correctly. This bug was added in if_bge.c rev. 1.161.


To generate a diff of this commit:
cvs rdiff -u -r1.339 -r1.340 src/sys/dev/pci/if_bge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 25 04:52:27 UTC 2019

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
 Fix a bug that SK-9D41 can't detect fiber media. Check the subsystem ID
correctly. This bug was added in if_bge.c rev. 1.161.


To generate a diff of this commit:
cvs rdiff -u -r1.339 -r1.340 src/sys/dev/pci/if_bge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.339 src/sys/dev/pci/if_bge.c:1.340
--- src/sys/dev/pci/if_bge.c:1.339	Sun Nov 10 21:16:36 2019
+++ src/sys/dev/pci/if_bge.c	Mon Nov 25 04:52:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.339 2019/11/10 21:16:36 chs Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.340 2019/11/25 04:52:27 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.339 2019/11/10 21:16:36 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.340 2019/11/25 04:52:27 msaitoh Exp $");
 
 #include 
 #include 
@@ -3847,7 +3847,7 @@ bge_attach(device_t parent, device_t sel
 	 * by its PCI subsystem ID, as we do below for the SysKonnect SK-9D41.
 	 * The SysKonnect SK-9D41 is a 1000baseSX card.
 	 */
-	if (PCI_PRODUCT(pa->pa_id) == SK_SUBSYSID_9D41 ||
+	if (PCI_PRODUCT(subid) == SK_SUBSYSID_9D41 ||
 	(hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) {
 		if (BGE_IS_5705_PLUS(sc)) {
 			sc->bge_flags |= BGEF_FIBER_MII;



CVS commit: src/sys/dev/pci

2019-11-21 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Nov 21 17:47:23 UTC 2019

Modified Files:
src/sys/dev/pci: ichsmb.c

Log Message:
If attach fails, don't panic on detach.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/ichsmb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ichsmb.c
diff -u src/sys/dev/pci/ichsmb.c:1.60 src/sys/dev/pci/ichsmb.c:1.61
--- src/sys/dev/pci/ichsmb.c:1.60	Mon Dec 10 06:23:54 2018
+++ src/sys/dev/pci/ichsmb.c	Thu Nov 21 17:47:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichsmb.c,v 1.60 2018/12/10 06:23:54 jdolecek Exp $	*/
+/*	$NetBSD: ichsmb.c,v 1.61 2019/11/21 17:47:23 ad Exp $	*/
 /*	$OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.60 2018/12/10 06:23:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.61 2019/11/21 17:47:23 ad Exp $");
 
 #include 
 #include 
@@ -265,7 +265,8 @@ ichsmb_detach(device_t self, int flags)
 		sc->sc_pihp = NULL;
 	}
 
-	bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_size);
+	if (sc->sc_size != 0)
+		bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_size);
 
 	return 0;
 }



CVS commit: src/sys/dev/pci

2019-11-21 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Nov 21 17:47:23 UTC 2019

Modified Files:
src/sys/dev/pci: ichsmb.c

Log Message:
If attach fails, don't panic on detach.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/ichsmb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 21 09:18:17 UTC 2019

Modified Files:
src/sys/dev/pci: if_ale.c

Log Message:
 Remove accidentally committed debug code. Sorry.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/if_ale.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 21 09:18:17 UTC 2019

Modified Files:
src/sys/dev/pci: if_ale.c

Log Message:
 Remove accidentally committed debug code. Sorry.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/if_ale.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_ale.c
diff -u src/sys/dev/pci/if_ale.c:1.35 src/sys/dev/pci/if_ale.c:1.36
--- src/sys/dev/pci/if_ale.c:1.35	Thu Nov 21 09:12:30 2019
+++ src/sys/dev/pci/if_ale.c	Thu Nov 21 09:18:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ale.c,v 1.35 2019/11/21 09:12:30 msaitoh Exp $	*/
+/*	$NetBSD: if_ale.c,v 1.36 2019/11/21 09:18:16 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2008, Pyun YongHyeon 
@@ -32,7 +32,7 @@
 /* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.35 2019/11/21 09:12:30 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.36 2019/11/21 09:18:16 msaitoh Exp $");
 
 #include "vlan.h"
 
@@ -136,9 +136,10 @@ ale_miibus_readreg(device_t dev, int phy
 	if (phy != sc->ale_phyaddr)
 		return -1;
 
-#if 1
 	if (sc->ale_flags & ALE_FLAG_FASTETHER) {
 		switch (reg) {
+		case MII_100T2CR:
+		case MII_100T2SR:
 		case MII_EXTSR:
 			*val = 0;
 			return 0;
@@ -146,7 +147,6 @@ ale_miibus_readreg(device_t dev, int phy
 			break;
 		}
 	}
-#endif
 
 	CSR_WRITE_4(sc, ALE_MDIO, MDIO_OP_EXECUTE | MDIO_OP_READ |
 	MDIO_SUP_PREAMBLE | MDIO_CLK_25_4 | MDIO_REG_ADDR(reg));
@@ -177,23 +177,19 @@ ale_miibus_writereg(device_t dev, int ph
 	if (phy != sc->ale_phyaddr)
 		return -1;
 
-#if 1
 	if (sc->ale_flags & ALE_FLAG_FASTETHER) {
-#if 0
 		switch (reg) {
+		case MII_100T2CR:
+		case MII_100T2SR:
 		case MII_EXTSR:
-			printf("%s:  write EXTSR with %04hx\n", __func__,
-val);
 			return 0;
 		default:
 			break;
 		}
-#endif
 	}
-#endif
 
 	CSR_WRITE_4(sc, ALE_MDIO, MDIO_OP_EXECUTE | MDIO_OP_WRITE |
-		((uint32_t)val & MDIO_DATA_MASK) << MDIO_DATA_SHIFT |
+	(val & MDIO_DATA_MASK) << MDIO_DATA_SHIFT |
 	MDIO_SUP_PREAMBLE | MDIO_CLK_25_4 | MDIO_REG_ADDR(reg));
 	for (i = ALE_PHY_TIMEOUT; i > 0; i--) {
 		DELAY(5);
@@ -259,9 +255,6 @@ ale_mediastatus(struct ifnet *ifp, struc
 	struct ale_softc *sc = ifp->if_softc;
 	struct mii_data *mii = >sc_miibus;
 
-	if ((ifp->if_flags & IFF_UP) == 0)
-		return;
-
 	mii_pollstat(mii);
 	ifmr->ifm_status = mii->mii_media_status;
 	ifmr->ifm_active = mii->mii_media_active;
@@ -274,7 +267,6 @@ ale_mediachange(struct ifnet *ifp)
 	struct mii_data *mii = >sc_miibus;
 	int error;
 
-	printf("%s: called\n", __func__);
 	if (mii->mii_instance != 0) {
 		struct mii_softc *miisc;
 
@@ -343,20 +335,16 @@ ale_get_macaddr(struct ale_softc *sc)
 void
 ale_phy_reset(struct ale_softc *sc)
 {
-//	int error;
-
-	printf("%s: called\n", __func__);
 	/* Reset magic from Linux. */
 	CSR_WRITE_2(sc, ALE_GPHY_CTRL,
 	GPHY_CTRL_HIB_EN | GPHY_CTRL_HIB_PULSE | GPHY_CTRL_SEL_ANA_RESET |
 	GPHY_CTRL_PHY_PLL_ON);
-	DELAY(2000);
+	DELAY(1000);
 	CSR_WRITE_2(sc, ALE_GPHY_CTRL,
 	GPHY_CTRL_EXT_RESET | GPHY_CTRL_HIB_EN | GPHY_CTRL_HIB_PULSE |
 	GPHY_CTRL_SEL_ANA_RESET | GPHY_CTRL_PHY_PLL_ON);
-	DELAY(2000);
+	DELAY(1000);
 
-#define	ATPHY_INT_CTRL		0x12
 #define	ATPHY_DBG_ADDR		0x1D
 #define	ATPHY_DBG_DATA		0x1E
 
@@ -386,10 +374,9 @@ ale_phy_reset(struct ale_softc *sc)
 	ale_miibus_writereg(sc->sc_dev, sc->ale_phyaddr,
 	ATPHY_DBG_DATA, 0x2C46);
 
-	DELAY(1000);
-
 #undef	ATPHY_DBG_ADDR
 #undef	ATPHY_DBG_DATA
+	DELAY(1000);
 }
 
 void
@@ -402,7 +389,7 @@ ale_attach(device_t parent, device_t sel
 	const char *intrstr;
 	struct ifnet *ifp;
 	struct mii_data * const mii = >sc_miibus;
-	pcireg_t memtype, pcireg, capoff;
+	pcireg_t memtype;
 	int mii_flags, error = 0;
 	uint32_t rxf_len, txf_len;
 	const char *chipname;
@@ -436,26 +423,6 @@ ale_attach(device_t parent, device_t sel
 		return;
 	}
 
-	pcireg = pci_conf_read(sc->sc_pct, sc->sc_pcitag,
-	PCI_COMMAND_STATUS_REG);
-	printf("%s: command = %08x\n", __func__, pcireg);
-	pcireg |= PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE;
-	pci_conf_write(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG, pcireg);
-
-#if 1
-	if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_PWRMGMT, ,
-	NULL) != 0) {
-		pcireg = pci_conf_read(pa->pa_pc, pa->pa_tag,
-		PCI_COMMAND_STATUS_REG);
-		printf("%s: CSR was %#08x\n", __func__, pcireg);
-		pcireg = pci_conf_read(pa->pa_pc, pa->pa_tag,
-		capoff + PCI_PMCSR);
-		printf("%s: PMCSR was %#08x\n", __func__, pcireg);
-		pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + PCI_PMCSR, 0);
-		delay(1000);
-	}
-#endif
-
 	if (pci_intr_map(pa, ) != 0) {
 		aprint_error_dev(self, "could not map interrupt\n");
 		goto fail;
@@ -479,6 +446,11 @@ ale_attach(device_t parent, device_t sel
 	sc->ale_phyaddr = ALE_PHY_ADDR;
 
 	/* Reset PHY. */
+	ale_phy_reset(sc);
+
+	/* Reset the ethernet 

CVS commit: src/sys/dev/pci

2019-11-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 21 09:12:30 UTC 2019

Modified Files:
src/sys/dev/pci: if_age.c if_alc.c if_ale.c if_cas.c

Log Message:
Fix a bug that IFF_ALLMULTI is almost always set.

 OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pci/if_age.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pci/if_alc.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/if_ale.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/if_cas.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_age.c
diff -u src/sys/dev/pci/if_age.c:1.63 src/sys/dev/pci/if_age.c:1.64
--- src/sys/dev/pci/if_age.c:1.63	Thu Nov 21 06:22:09 2019
+++ src/sys/dev/pci/if_age.c	Thu Nov 21 09:12:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_age.c,v 1.63 2019/11/21 06:22:09 msaitoh Exp $ */
+/*	$NetBSD: if_age.c,v 1.64 2019/11/21 09:12:30 msaitoh Exp $ */
 /*	$OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $	*/
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.63 2019/11/21 06:22:09 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.64 2019/11/21 09:12:30 msaitoh Exp $");
 
 #include "vlan.h"
 
@@ -2275,27 +2275,37 @@ age_rxfilter(struct age_softc *sc)
 	 */
 	rxcfg |= MAC_CFG_BCAST;
 
-	if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
+	/* Program new filter. */
+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		goto update;
+
+	memset(mchash, 0, sizeof(mchash));
+
+	ETHER_LOCK(ec);
+	ETHER_FIRST_MULTI(step, ec, enm);
+	while (enm != NULL) {
+		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+			ETHER_UNLOCK(ec);
+			goto update;
+		}
+		crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+		mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+		ETHER_NEXT_MULTI(step, enm);
+	}
+	ETHER_UNLOCK(ec);
+
+update:
+	if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+		if (ifp->if_flags & IFF_PROMISC) {
 			rxcfg |= MAC_CFG_PROMISC;
-		else
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+		} else
 			rxcfg |= MAC_CFG_ALLMULTI;
 		mchash[0] = mchash[1] = 0x;
-	} else {
-		/* Program new filter. */
-		memset(mchash, 0, sizeof(mchash));
-
-		ETHER_LOCK(ec);
-		ETHER_FIRST_MULTI(step, ec, enm);
-		while (enm != NULL) {
-			crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-			mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-			ETHER_NEXT_MULTI(step, enm);
-		}
-		ETHER_UNLOCK(ec);
 	}
-
 	CSR_WRITE_4(sc, AGE_MAR0, mchash[0]);
 	CSR_WRITE_4(sc, AGE_MAR1, mchash[1]);
 	CSR_WRITE_4(sc, AGE_MAC_CFG, rxcfg);

Index: src/sys/dev/pci/if_alc.c
diff -u src/sys/dev/pci/if_alc.c:1.43 src/sys/dev/pci/if_alc.c:1.44
--- src/sys/dev/pci/if_alc.c:1.43	Wed Oct 30 07:26:28 2019
+++ src/sys/dev/pci/if_alc.c	Thu Nov 21 09:12:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_alc.c,v 1.43 2019/10/30 07:26:28 msaitoh Exp $	*/
+/*	$NetBSD: if_alc.c,v 1.44 2019/11/21 09:12:30 msaitoh Exp $	*/
 /*	$OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $	*/
 /*-
  * Copyright (c) 2009, Pyun YongHyeon 
@@ -3443,27 +3443,37 @@ alc_iff(struct alc_softc *sc)
 	 */
 	rxcfg |= MAC_CFG_BCAST;
 
-	if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
+	/* Program new filter. */
+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		goto update;
+
+	memset(mchash, 0, sizeof(mchash));
+
+	ETHER_LOCK(ec);
+	ETHER_FIRST_MULTI(step, ec, enm);
+	while (enm != NULL) {
+		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+			ETHER_UNLOCK(ec);
+			goto update;
+		}
+		crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+		mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+		ETHER_NEXT_MULTI(step, enm);
+	}
+	ETHER_UNLOCK(ec);
+
+update:
+	if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+		if (ifp->if_flags & IFF_PROMISC) {
 			rxcfg |= MAC_CFG_PROMISC;
-		else
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+		} else
 			rxcfg |= MAC_CFG_ALLMULTI;
 		mchash[0] = mchash[1] = 0x;
-	} else {
-		/* Program new filter. */
-		memset(mchash, 0, sizeof(mchash));
-
-		ETHER_LOCK(ec);
-		ETHER_FIRST_MULTI(step, ec, enm);
-		while (enm != NULL) {
-			crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-			mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-			ETHER_NEXT_MULTI(step, enm);
-		}
-		ETHER_UNLOCK(ec);
 	}
-
 	CSR_WRITE_4(sc, ALC_MAR0, mchash[0]);
 	CSR_WRITE_4(sc, ALC_MAR1, mchash[1]);
 	CSR_WRITE_4(sc, ALC_MAC_CFG, rxcfg);

Index: src/sys/dev/pci/if_ale.c
diff -u 

CVS commit: src/sys/dev/pci

2019-11-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 21 09:12:30 UTC 2019

Modified Files:
src/sys/dev/pci: if_age.c if_alc.c if_ale.c if_cas.c

Log Message:
Fix a bug that IFF_ALLMULTI is almost always set.

 OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pci/if_age.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pci/if_alc.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/if_ale.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/if_cas.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 21 06:22:09 UTC 2019

Modified Files:
src/sys/dev/pci: if_age.c

Log Message:
 Fix multicast handling. All Atheros controllers use big-endian form
when computing multicast hash. Same as OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/pci/if_age.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_age.c
diff -u src/sys/dev/pci/if_age.c:1.62 src/sys/dev/pci/if_age.c:1.63
--- src/sys/dev/pci/if_age.c:1.62	Wed Oct 30 07:26:28 2019
+++ src/sys/dev/pci/if_age.c	Thu Nov 21 06:22:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_age.c,v 1.62 2019/10/30 07:26:28 msaitoh Exp $ */
+/*	$NetBSD: if_age.c,v 1.63 2019/11/21 06:22:09 msaitoh Exp $ */
 /*	$OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $	*/
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.62 2019/10/30 07:26:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.63 2019/11/21 06:22:09 msaitoh Exp $");
 
 #include "vlan.h"
 
@@ -2289,7 +2289,7 @@ age_rxfilter(struct age_softc *sc)
 		ETHER_LOCK(ec);
 		ETHER_FIRST_MULTI(step, ec, enm);
 		while (enm != NULL) {
-			crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
+			crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
 			mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
 			ETHER_NEXT_MULTI(step, enm);
 		}



CVS commit: src/sys/dev/pci

2019-11-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 21 06:22:09 UTC 2019

Modified Files:
src/sys/dev/pci: if_age.c

Log Message:
 Fix multicast handling. All Atheros controllers use big-endian form
when computing multicast hash. Same as OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/pci/if_age.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 21 02:59:44 UTC 2019

Modified Files:
src/sys/dev/pci: if_vge.c

Log Message:
- Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
  the current active link status.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/if_vge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 21 02:59:44 UTC 2019

Modified Files:
src/sys/dev/pci: if_vge.c

Log Message:
- Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
  the current active link status.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/if_vge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_vge.c
diff -u src/sys/dev/pci/if_vge.c:1.76 src/sys/dev/pci/if_vge.c:1.77
--- src/sys/dev/pci/if_vge.c:1.76	Tue Nov 19 09:54:07 2019
+++ src/sys/dev/pci/if_vge.c	Thu Nov 21 02:59:43 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.76 2019/11/19 09:54:07 msaitoh Exp $ */
+/* $NetBSD: if_vge.c,v 1.77 2019/11/21 02:59:43 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.76 2019/11/19 09:54:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.77 2019/11/21 02:59:43 msaitoh Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -1928,33 +1928,34 @@ vge_miibus_statchg(struct ifnet *ifp)
 	 * always implied, so we turn on the forced mode bit but leave
 	 * the FDX bit cleared.
 	 */
-
 	dctl = CSR_READ_1(sc, VGE_DIAGCTL);
 
-	switch (IFM_SUBTYPE(ife->ifm_media)) {
-	case IFM_AUTO:
+	if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
 		dctl &= ~VGE_DIAGCTL_MACFORCE;
 		dctl &= ~VGE_DIAGCTL_FDXFORCE;
-		break;
-	case IFM_1000_T:
-		dctl |= VGE_DIAGCTL_MACFORCE;
-		dctl &= ~VGE_DIAGCTL_FDXFORCE;
-		dctl |= VGE_DIAGCTL_GMII;
-		break;
-	case IFM_100_TX:
-	case IFM_10_T:
+	} else {
+		u_int ifmword;
+
+		/* If the link is up, use the current active media. */
+		if ((mii->mii_media_status & IFM_ACTIVE) != 0)
+			ifmword = mii->mii_media_active;
+		else
+			ifmword = ife->ifm_media;
+
 		dctl |= VGE_DIAGCTL_MACFORCE;
-		dctl &= ~VGE_DIAGCTL_GMII;
-		if ((ife->ifm_media & IFM_FDX) != 0)
+		if ((ifmword & IFM_FDX) != 0)
 			dctl |= VGE_DIAGCTL_FDXFORCE;
 		else
 			dctl &= ~VGE_DIAGCTL_FDXFORCE;
-		break;
-	default:
-		printf("%s: unknown media type: %x\n",
-		device_xname(sc->sc_dev),
-		IFM_SUBTYPE(ife->ifm_media));
-		break;
+
+		if (IFM_SUBTYPE(ifmword) == IFM_1000_T) {
+			/*
+			 * It means the user setting is not auto but it's
+			 * 1000baseT-FDX or 1000baseT.
+			 */
+			dctl |= VGE_DIAGCTL_GMII;
+		} else
+			dctl &= ~VGE_DIAGCTL_GMII;
 	}
 
 	CSR_WRITE_1(sc, VGE_DIAGCTL, dctl);



CVS commit: src/sys/dev/pci

2019-11-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Nov 19 09:54:07 UTC 2019

Modified Files:
src/sys/dev/pci: if_vge.c

Log Message:
 Fixes a bug that "ifmedia vge0 media 1000baseT-FDX" causes device timeout.

If the interface's media is NOT in the "best" mode (i.e. other than IFM_AUTO),
control VGE_DIAGCTL_GMII bit.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/if_vge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Nov 19 09:54:07 UTC 2019

Modified Files:
src/sys/dev/pci: if_vge.c

Log Message:
 Fixes a bug that "ifmedia vge0 media 1000baseT-FDX" causes device timeout.

If the interface's media is NOT in the "best" mode (i.e. other than IFM_AUTO),
control VGE_DIAGCTL_GMII bit.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/if_vge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_vge.c
diff -u src/sys/dev/pci/if_vge.c:1.75 src/sys/dev/pci/if_vge.c:1.76
--- src/sys/dev/pci/if_vge.c:1.75	Tue Oct  8 14:26:27 2019
+++ src/sys/dev/pci/if_vge.c	Tue Nov 19 09:54:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.75 2019/10/08 14:26:27 msaitoh Exp $ */
+/* $NetBSD: if_vge.c,v 1.76 2019/11/19 09:54:07 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.75 2019/10/08 14:26:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.76 2019/11/19 09:54:07 msaitoh Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -1916,6 +1916,7 @@ vge_miibus_statchg(struct ifnet *ifp)
 	struct vge_softc *sc = ifp->if_softc;
 	struct mii_data *mii = >sc_mii;
 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
+	uint8_t dctl;
 
 	/*
 	 * If the user manually selects a media mode, we need to turn
@@ -1928,23 +1929,26 @@ vge_miibus_statchg(struct ifnet *ifp)
 	 * the FDX bit cleared.
 	 */
 
+	dctl = CSR_READ_1(sc, VGE_DIAGCTL);
+
 	switch (IFM_SUBTYPE(ife->ifm_media)) {
 	case IFM_AUTO:
-		CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE);
-		CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE);
+		dctl &= ~VGE_DIAGCTL_MACFORCE;
+		dctl &= ~VGE_DIAGCTL_FDXFORCE;
 		break;
 	case IFM_1000_T:
-		CSR_SETBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE);
-		CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE);
+		dctl |= VGE_DIAGCTL_MACFORCE;
+		dctl &= ~VGE_DIAGCTL_FDXFORCE;
+		dctl |= VGE_DIAGCTL_GMII;
 		break;
 	case IFM_100_TX:
 	case IFM_10_T:
-		CSR_SETBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE);
-		if ((ife->ifm_media & IFM_FDX) != 0) {
-			CSR_SETBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE);
-		} else {
-			CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE);
-		}
+		dctl |= VGE_DIAGCTL_MACFORCE;
+		dctl &= ~VGE_DIAGCTL_GMII;
+		if ((ife->ifm_media & IFM_FDX) != 0)
+			dctl |= VGE_DIAGCTL_FDXFORCE;
+		else
+			dctl &= ~VGE_DIAGCTL_FDXFORCE;
 		break;
 	default:
 		printf("%s: unknown media type: %x\n",
@@ -1952,6 +1956,8 @@ vge_miibus_statchg(struct ifnet *ifp)
 		IFM_SUBTYPE(ife->ifm_media));
 		break;
 	}
+
+	CSR_WRITE_1(sc, VGE_DIAGCTL, dctl);
 }
 
 static int



Re: CVS commit: src/sys/dev/pci

2019-11-17 Thread Kimihiro Nonaka
It only prevent null pointer dereference.

On Mon, Nov 18, 2019 at 3:18 PM  wrote:
>
> On Mon, Nov 18, 2019 at 06:15:27AM +, m...@netbsd.org wrote:
> > > Modified files:
> > >
> > > Index: src/sys/dev/pci/if_mcx.c
> > > diff -u src/sys/dev/pci/if_mcx.c:1.5 src/sys/dev/pci/if_mcx.c:1.6
> > > --- src/sys/dev/pci/if_mcx.c:1.5Thu Oct 17 15:57:56 2019
> > > +++ src/sys/dev/pci/if_mcx.cMon Nov 18 04:40:05 2019
> > > @@ -1,4 +1,4 @@
> > > -/* $NetBSD: if_mcx.c,v 1.5 2019/10/17 15:57:56 msaitoh Exp $ */
> > > +/* $NetBSD: if_mcx.c,v 1.6 2019/11/18 04:40:05 nonaka Exp $ */
> > >  /* $OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
> > >
> > >  /*
> > > @@ -6347,7 +6347,7 @@ mcx_load_mbuf(struct mcx_softc *sc, stru
> > > break;
> > >
> > > case EFBIG:
> > > -   if (m_defrag(m, M_DONTWAIT) == 0 &&
> > > +   if (m_defrag(m, M_DONTWAIT) != NULL &&
> > > bus_dmamap_load_mbuf(sc->sc_dmat, ms->ms_map, m,
> > > BUS_DMA_STREAMING | BUS_DMA_NOWAIT) == 0)
> > > break;
> > >
> >
> > Is this one of those "m_defrag misbehaves because it will not turn it
> > into a chain of 1 packet, but 2"?
> >
> > (I think this will not work)
>
> Additional context:
> http://mail-index.netbsd.org/tech-net/2018/09/01/msg007031.html


Re: CVS commit: src/sys/dev/pci

2019-11-17 Thread maya
> Modified files:
> 
> Index: src/sys/dev/pci/if_mcx.c
> diff -u src/sys/dev/pci/if_mcx.c:1.5 src/sys/dev/pci/if_mcx.c:1.6
> --- src/sys/dev/pci/if_mcx.c:1.5  Thu Oct 17 15:57:56 2019
> +++ src/sys/dev/pci/if_mcx.c  Mon Nov 18 04:40:05 2019
> @@ -1,4 +1,4 @@
> -/*   $NetBSD: if_mcx.c,v 1.5 2019/10/17 15:57:56 msaitoh Exp $ */
> +/*   $NetBSD: if_mcx.c,v 1.6 2019/11/18 04:40:05 nonaka Exp $ */
>  /*   $OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
>  
>  /*
> @@ -6347,7 +6347,7 @@ mcx_load_mbuf(struct mcx_softc *sc, stru
>   break;
>  
>   case EFBIG:
> - if (m_defrag(m, M_DONTWAIT) == 0 &&
> + if (m_defrag(m, M_DONTWAIT) != NULL &&
>   bus_dmamap_load_mbuf(sc->sc_dmat, ms->ms_map, m,
>   BUS_DMA_STREAMING | BUS_DMA_NOWAIT) == 0)
>   break;
> 

Is this one of those "m_defrag misbehaves because it will not turn it
into a chain of 1 packet, but 2"?

(I think this will not work)


CVS commit: src/sys/dev/pci

2019-11-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Nov 18 04:40:05 UTC 2019

Modified Files:
src/sys/dev/pci: if_mcx.c

Log Message:
Fixed incorrect m_defrag return value check.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.5 src/sys/dev/pci/if_mcx.c:1.6
--- src/sys/dev/pci/if_mcx.c:1.5	Thu Oct 17 15:57:56 2019
+++ src/sys/dev/pci/if_mcx.c	Mon Nov 18 04:40:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.5 2019/10/17 15:57:56 msaitoh Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.6 2019/11/18 04:40:05 nonaka Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -6347,7 +6347,7 @@ mcx_load_mbuf(struct mcx_softc *sc, stru
 		break;
 
 	case EFBIG:
-		if (m_defrag(m, M_DONTWAIT) == 0 &&
+		if (m_defrag(m, M_DONTWAIT) != NULL &&
 		bus_dmamap_load_mbuf(sc->sc_dmat, ms->ms_map, m,
 		BUS_DMA_STREAMING | BUS_DMA_NOWAIT) == 0)
 			break;



CVS commit: src/sys/dev/pci

2019-11-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Nov 18 04:40:05 UTC 2019

Modified Files:
src/sys/dev/pci: if_mcx.c

Log Message:
Fixed incorrect m_defrag return value check.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/if_mcx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci/ixgbe

2019-11-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 18 03:17:51 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixv.c

Log Message:
 Print MAC address.

 XXX Should we move such type of printf() to ether_ifattach?


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.140 -r1.141 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.215 src/sys/dev/pci/ixgbe/ixgbe.c:1.216
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.215	Sun Nov 10 21:16:36 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Nov 18 03:17:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.215 2019/11/10 21:16:36 chs Exp $ */
+/* $NetBSD: ixgbe.c,v 1.216 2019/11/18 03:17:51 msaitoh Exp $ */
 
 /**
 
@@ -1333,6 +1333,8 @@ ixgbe_setup_interface(device_t dev, stru
 	}
 	adapter->ipq = if_percpuq_create(>osdep.ec.ec_if);
 	ether_ifattach(ifp, adapter->hw.mac.addr);
+	aprint_normal_dev(dev, "Ethernet address %s\n",
+	ether_sprintf(adapter->hw.mac.addr));
 	/*
 	 * We use per TX queue softint, so if_deferred_start_init() isn't
 	 * used.

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.140 src/sys/dev/pci/ixgbe/ixv.c:1.141
--- src/sys/dev/pci/ixgbe/ixv.c:1.140	Wed Nov  6 04:17:16 2019
+++ src/sys/dev/pci/ixgbe/ixv.c	Mon Nov 18 03:17:51 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.140 2019/11/06 04:17:16 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.141 2019/11/18 03:17:51 msaitoh Exp $*/
 
 /**
 
@@ -1610,6 +1610,8 @@ ixv_setup_interface(device_t dev, struct
 	}
 	adapter->ipq = if_percpuq_create(>osdep.ec.ec_if);
 	ether_ifattach(ifp, adapter->hw.mac.addr);
+	aprint_normal_dev(dev, "Ethernet address %s\n",
+	ether_sprintf(adapter->hw.mac.addr));
 	/*
 	 * We use per TX queue softint, so if_deferred_start_init() isn't
 	 * used.



CVS commit: src/sys/dev/pci/ixgbe

2019-11-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 18 03:17:51 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixv.c

Log Message:
 Print MAC address.

 XXX Should we move such type of printf() to ether_ifattach?


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.140 -r1.141 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 15 12:38:09 UTC 2019

Modified Files:
src/sys/dev/pci: if_msk.c if_skreg.h

Log Message:
 Make Yukon EX, FE+, SUPR stable. The code is mainly taken from FreeBSD.

 At least, this change made my own Yukon EX machine (HP ProBook 4501s) much
stable than before.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/if_skreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.93 src/sys/dev/pci/if_msk.c:1.94
--- src/sys/dev/pci/if_msk.c:1.93	Sun Nov 10 21:16:36 2019
+++ src/sys/dev/pci/if_msk.c	Fri Nov 15 12:38:09 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.93 2019/11/10 21:16:36 chs Exp $ */
+/* $NetBSD: if_msk.c,v 1.94 2019/11/15 12:38:09 msaitoh Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.93 2019/11/10 21:16:36 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.94 2019/11/15 12:38:09 msaitoh Exp $");
 
 #include 
 #include 
@@ -881,10 +881,27 @@ void
 mskc_reset(struct sk_softc *sc)
 {
 	uint32_t imtimer_ticks, reg1;
+	uint16_t status;
 	int reg;
 
 	DPRINTFN(2, ("mskc_reset\n"));
 
+	/* Disable ASF */
+	if ((sc->sk_type == SK_YUKON_EX) || (sc->sk_type == SK_YUKON_SUPR)) {
+		CSR_WRITE_4(sc, SK_Y2_CPU_WDOG, 0);
+		status = CSR_READ_2(sc, SK_Y2_ASF_HCU_CCSR);
+		/* Clear AHB bridge & microcontroller reset. */
+		status &= ~(SK_Y2_ASF_HCU_CSSR_ARB_RST |
+		SK_Y2_ASF_HCU_CSSR_CPU_RST_MODE);
+		/* Clear ASF microcontroller state. */
+		status &= ~SK_Y2_ASF_HCU_CSSR_UC_STATE_MSK;
+		status &= ~SK_Y2_ASF_HCU_CSSR_CPU_CLK_DIVIDE_MSK;
+		CSR_WRITE_2(sc, SK_Y2_ASF_HCU_CCSR, status);
+		CSR_WRITE_4(sc, SK_Y2_CPU_WDOG, 0);
+	} else
+		CSR_WRITE_1(sc, SK_Y2_ASF_CSR, SK_Y2_ASF_RESET);
+	CSR_WRITE_2(sc, SK_CSR, SK_CSR_ASF_OFF);
+
 	CSR_WRITE_1(sc, SK_CSR, SK_CSR_SW_RESET);
 	CSR_WRITE_1(sc, SK_CSR, SK_CSR_MASTER_RESET);
 
@@ -957,10 +974,6 @@ mskc_reset(struct sk_softc *sc)
 	DPRINTFN(2, ("mskc_reset: sk_link_ctrl=%x\n",
 		 CSR_READ_2(sc, SK_LINK_CTRL)));
 
-	/* Disable ASF */
-	CSR_WRITE_1(sc, SK_Y2_ASF_CSR, SK_Y2_ASF_RESET);
-	CSR_WRITE_2(sc, SK_CSR, SK_CSR_ASF_OFF);
-
 	/* Clear I2C IRQ noise */
 	CSR_WRITE_4(sc, SK_I2CHWIRQ, 1);
 
@@ -1096,9 +1109,9 @@ msk_reset(struct sk_if_softc *sc_if)
 {
 	/* GMAC and GPHY Reset */
 	SK_IF_WRITE_4(sc_if, 0, SK_GMAC_CTRL, SK_GMAC_RESET_SET);
-	SK_IF_WRITE_4(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_SET);
+	SK_IF_WRITE_1(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_SET);
 	DELAY(1000);
-	SK_IF_WRITE_4(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_CLEAR);
+	SK_IF_WRITE_1(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_CLEAR);
 	SK_IF_WRITE_4(sc_if, 0, SK_GMAC_CTRL, SK_GMAC_LOOP_OFF |
 		  SK_GMAC_PAUSE_ON | SK_GMAC_RESET_CLEAR);
 }
@@ -2404,17 +2417,31 @@ msk_init_yukon(struct sk_if_softc *sc_if
 
 	/* Configure RX MAC FIFO */
 	SK_IF_WRITE_1(sc_if, 0, SK_RXMF1_CTRL_TEST, SK_RFCTL_RESET_CLEAR);
-	SK_IF_WRITE_2(sc_if, 0, SK_RXMF1_CTRL_TEST, SK_RFCTL_OPERATION_ON |
-	SK_RFCTL_FIFO_FLUSH_ON);
-
-	/* Increase flush threshold to 64 bytes */
-	SK_IF_WRITE_2(sc_if, 0, SK_RXMF1_FLUSH_THRESHOLD,
-	SK_RFCTL_FIFO_THRESHOLD + 1);
+	v =  SK_RFCTL_OPERATION_ON | SK_RFCTL_FIFO_FLUSH_ON;
+	if ((sc->sk_type == SK_YUKON_EX) || (sc->sk_type == SK_YUKON_FE_P))
+		v |= SK_RFCTL_RX_OVER_ON;
+	SK_IF_WRITE_2(sc_if, 0, SK_RXMF1_CTRL_TEST, v);
+
+	if ((sc->sk_type == SK_YUKON_FE_P) &&
+	(sc->sk_rev == SK_YUKON_FE_P_REV_A0))
+		v = 0x178; /* Magic value */
+	else {
+		/* Increase flush threshold to 64 bytes */
+		v = SK_RFCTL_FIFO_THRESHOLD + 1;
+	}
+	SK_IF_WRITE_2(sc_if, 0, SK_RXMF1_FLUSH_THRESHOLD, v);
 
 	/* Configure TX MAC FIFO */
 	SK_IF_WRITE_1(sc_if, 0, SK_TXMF1_CTRL_TEST, SK_TFCTL_RESET_CLEAR);
 	SK_IF_WRITE_2(sc_if, 0, SK_TXMF1_CTRL_TEST, SK_TFCTL_OPERATION_ON);
 
+	if ((sc->sk_type == SK_YUKON_FE_P) &&
+	(sc->sk_rev == SK_YUKON_FE_P_REV_A0)) {
+		v = SK_IF_READ_2(sc_if, 0, SK_TXMF1_END);
+		v &= ~SK_TXEND_WM_ON;
+		SK_IF_WRITE_2(sc_if, 0, SK_TXMF1_END, v);
+	}	
+
 #if 1
 	SK_YU_WRITE_2(sc_if, YUKON_GPCR, YU_GPCR_TXEN | YU_GPCR_RXEN);
 #endif
@@ -2451,7 +2478,7 @@ msk_init(struct ifnet *ifp)
 	/* Configure transmit arbiter(s) */
 	SK_IF_WRITE_1(sc_if, 0, SK_TXAR1_COUNTERCTL, SK_TXARCTL_ON);
 #if 0
-	SK_TXARCTL_ON | SK_TXARCTL_FSYNC_ON);
+/*	SK_TXARCTL_ON | SK_TXARCTL_FSYNC_ON); */
 #endif
 
 	if (sc->sk_ramsize) {
@@ -2559,6 +2586,13 @@ msk_init(struct ifnet *ifp)
 	SK_IF_WRITE_2(sc_if, 0, SK_RXQ1_Y2_PREF_PUTIDX,
 	sc_if->sk_cdata.sk_rx_prod);
 
+	
+	if ((sc->sk_type == SK_YUKON_EX) || (sc->sk_type == SK_YUKON_SUPR)) {
+		/* Disable flushing of non-ASF packets. */
+		SK_IF_WRITE_4(sc_if, 0, SK_RXMF1_CTRL_TEST,
+		SK_RFCTL_RX_MACSEC_FLUSH_OFF);
+	}
+
 	/* Configure 

CVS commit: src/sys/dev/pci

2019-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 15 12:38:09 UTC 2019

Modified Files:
src/sys/dev/pci: if_msk.c if_skreg.h

Log Message:
 Make Yukon EX, FE+, SUPR stable. The code is mainly taken from FreeBSD.

 At least, this change made my own Yukon EX machine (HP ProBook 4501s) much
stable than before.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/if_skreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 14 09:11:36 UTC 2019

Modified Files:
src/sys/dev/pci: if_jmereg.h if_re_pci.c xhci_pci.c

Log Message:
Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/if_jmereg.h
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pci/if_re_pci.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/xhci_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_jmereg.h
diff -u src/sys/dev/pci/if_jmereg.h:1.3 src/sys/dev/pci/if_jmereg.h:1.4
--- src/sys/dev/pci/if_jmereg.h:1.3	Fri Jan 16 19:56:06 2009
+++ src/sys/dev/pci/if_jmereg.h	Thu Nov 14 09:11:35 2019
@@ -62,6 +62,21 @@
 #define	SPI_SCK_CTRL		0x0002
 #define	SPI_CS_N_CTRL		0x0001
 
+#define	JME_EFUSE_CTL1		0xB8
+#define	EFUSE_CTL1_DATA_MASK	0xF000
+#define	EFUSE_CTL1_EXECUTE	0x0800
+#define	EFUSE_CTL1_CMD_AUTOLOAD	0x0200
+#define	EFUSE_CTL1_CMD_READ	0x0400
+#define	EFUSE_CTL1_CMD_BLOW	0x0600
+#define	EFUSE_CTL1_CMD_MASK	0x0600
+#define	EFUSE_CTL1_AUTOLOAD_ERR	0x0001
+#define	EFUSE_CTL1_BYTE_SEL_MASK	0xFF00
+#define	EFUSE_CTL1_BIT_SEL_MASK	0x0070
+#define	EFUSE_CTL1_AUTOLAOD_DONE	0x0001
+
+#define	JME_EFUSE_CTL2		0xBC
+#define	EFUSE_CTL2_RESET	0x8000
+
 #define	JME_PCI_PHYCFG0		0xC0
 
 #define	JME_PCI_PHYCFG1		0xC4
@@ -757,6 +772,10 @@
 #define	CHIPMODE_MODE_128P_MAC	0x0003
 #define	CHIPMODE_MODE_128P_DBG	0x0002
 #define	CHIPMODE_MODE_128P_PHY	0x
+/* Chip full mask revision. */
+#define	CHIPMODE_REVFM(x)	((x) & 0x0F)
+/* Chip ECO revision. */
+#define	CHIPMODE_REVECO(x)	(((x) >> 4) & 0x0F)
 
 /* Shadow status base address high/low. */
 #define	JME_SHBASE_ADDR_HI	0x48

Index: src/sys/dev/pci/if_re_pci.c
diff -u src/sys/dev/pci/if_re_pci.c:1.49 src/sys/dev/pci/if_re_pci.c:1.50
--- src/sys/dev/pci/if_re_pci.c:1.49	Tue Nov 13 20:12:45 2018
+++ src/sys/dev/pci/if_re_pci.c	Thu Nov 14 09:11:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_re_pci.c,v 1.49 2018/11/13 20:12:45 jdolecek Exp $	*/
+/*	$NetBSD: if_re_pci.c,v 1.50 2019/11/14 09:11:35 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.49 2018/11/13 20:12:45 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.50 2019/11/14 09:11:35 msaitoh Exp $");
 
 #include 
 
@@ -99,6 +99,9 @@ static const struct rtk_type re_devs[] =
 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8168,
 	RTK_8168,
 	"RealTek 8168/8111 PCIe Gigabit Ethernet" },
+	{ PCI_VENDOR_NCUBE, PCI_PRODUCT_NCUBE_TG3648,
+	RTK_8168,
+	"TP-Link TG-3468 v2 (RTL8168) Gigabit Ethernet" },
 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169,
 	RTK_8169,
 	"RealTek 8169/8110 Gigabit Ethernet" },
@@ -111,6 +114,9 @@ static const struct rtk_type re_devs[] =
 	{ PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE528T,
 	RTK_8169,
 	"D-Link DGE-528T Gigabit Ethernet" },
+	{ PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE530T_C1,
+	RTK_8169,
+	"D-Link DGE-530T C1 Gigabit Ethernet" },
 	{ PCI_VENDOR_USR2, PCI_PRODUCT_USR2_USR997902,
 	RTK_8169,
 	"US Robotics (3Com) USR997902 Gigabit Ethernet" },

Index: src/sys/dev/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.21 src/sys/dev/pci/xhci_pci.c:1.22
--- src/sys/dev/pci/xhci_pci.c:1.21	Wed Jan 23 06:56:19 2019
+++ src/sys/dev/pci/xhci_pci.c	Thu Nov 14 09:11:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.21 2019/01/23 06:56:19 msaitoh Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.22 2019/11/14 09:11:35 msaitoh Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.21 2019/01/23 06:56:19 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.22 2019/11/14 09:11:35 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -203,10 +203,17 @@ xhci_pci_attach(device_t parent, device_
 		   csr | PCI_COMMAND_MASTER_ENABLE);
 
 	/* Allocate and establish the interrupt. */
+#if 0
 	if (pci_intr_alloc(pa, >sc_pihp, NULL, 0)) {
 		aprint_error_dev(self, "can't allocate handler\n");
 		goto fail;
 	}
+#else
+	if (pci_intx_alloc(pa, >sc_pihp)) {
+		aprint_error_dev(self, "can't allocate handler\n");
+		goto fail;
+	}
+#endif
 	intrstr = pci_intr_string(pc, psc->sc_pihp[0], intrbuf,
 	sizeof(intrbuf));
 	psc->sc_ih = pci_intr_establish_xname(pc, psc->sc_pihp[0], IPL_USB,



CVS commit: src/sys/dev/pci

2019-11-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 14 09:11:36 UTC 2019

Modified Files:
src/sys/dev/pci: if_jmereg.h if_re_pci.c xhci_pci.c

Log Message:
Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/if_jmereg.h
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pci/if_re_pci.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/xhci_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 14 09:15:12 UTC 2019

Modified Files:
src/sys/dev/pci: if_jmereg.h xhci_pci.c

Log Message:
 Revert previous. Sorry.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/if_jmereg.h
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/xhci_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 14 09:15:12 UTC 2019

Modified Files:
src/sys/dev/pci: if_jmereg.h xhci_pci.c

Log Message:
 Revert previous. Sorry.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/if_jmereg.h
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/xhci_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_jmereg.h
diff -u src/sys/dev/pci/if_jmereg.h:1.4 src/sys/dev/pci/if_jmereg.h:1.5
--- src/sys/dev/pci/if_jmereg.h:1.4	Thu Nov 14 09:11:35 2019
+++ src/sys/dev/pci/if_jmereg.h	Thu Nov 14 09:15:12 2019
@@ -62,21 +62,6 @@
 #define	SPI_SCK_CTRL		0x0002
 #define	SPI_CS_N_CTRL		0x0001
 
-#define	JME_EFUSE_CTL1		0xB8
-#define	EFUSE_CTL1_DATA_MASK	0xF000
-#define	EFUSE_CTL1_EXECUTE	0x0800
-#define	EFUSE_CTL1_CMD_AUTOLOAD	0x0200
-#define	EFUSE_CTL1_CMD_READ	0x0400
-#define	EFUSE_CTL1_CMD_BLOW	0x0600
-#define	EFUSE_CTL1_CMD_MASK	0x0600
-#define	EFUSE_CTL1_AUTOLOAD_ERR	0x0001
-#define	EFUSE_CTL1_BYTE_SEL_MASK	0xFF00
-#define	EFUSE_CTL1_BIT_SEL_MASK	0x0070
-#define	EFUSE_CTL1_AUTOLAOD_DONE	0x0001
-
-#define	JME_EFUSE_CTL2		0xBC
-#define	EFUSE_CTL2_RESET	0x8000
-
 #define	JME_PCI_PHYCFG0		0xC0
 
 #define	JME_PCI_PHYCFG1		0xC4
@@ -772,10 +757,6 @@
 #define	CHIPMODE_MODE_128P_MAC	0x0003
 #define	CHIPMODE_MODE_128P_DBG	0x0002
 #define	CHIPMODE_MODE_128P_PHY	0x
-/* Chip full mask revision. */
-#define	CHIPMODE_REVFM(x)	((x) & 0x0F)
-/* Chip ECO revision. */
-#define	CHIPMODE_REVECO(x)	(((x) >> 4) & 0x0F)
 
 /* Shadow status base address high/low. */
 #define	JME_SHBASE_ADDR_HI	0x48

Index: src/sys/dev/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.22 src/sys/dev/pci/xhci_pci.c:1.23
--- src/sys/dev/pci/xhci_pci.c:1.22	Thu Nov 14 09:11:35 2019
+++ src/sys/dev/pci/xhci_pci.c	Thu Nov 14 09:15:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.22 2019/11/14 09:11:35 msaitoh Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.23 2019/11/14 09:15:12 msaitoh Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.22 2019/11/14 09:11:35 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.23 2019/11/14 09:15:12 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -203,17 +203,10 @@ xhci_pci_attach(device_t parent, device_
 		   csr | PCI_COMMAND_MASTER_ENABLE);
 
 	/* Allocate and establish the interrupt. */
-#if 0
 	if (pci_intr_alloc(pa, >sc_pihp, NULL, 0)) {
 		aprint_error_dev(self, "can't allocate handler\n");
 		goto fail;
 	}
-#else
-	if (pci_intx_alloc(pa, >sc_pihp)) {
-		aprint_error_dev(self, "can't allocate handler\n");
-		goto fail;
-	}
-#endif
 	intrstr = pci_intr_string(pc, psc->sc_pihp[0], intrbuf,
 	sizeof(intrbuf));
 	psc->sc_ih = pci_intr_establish_xname(pc, psc->sc_pihp[0], IPL_USB,



CVS commit: src/sys/dev/pci

2019-11-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 14 09:10:41 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.


To generate a diff of this commit:
cvs rdiff -u -r1.1390 -r1.1391 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1390 src/sys/dev/pci/pcidevs:1.1391
--- src/sys/dev/pci/pcidevs:1.1390	Fri Nov  8 04:37:45 2019
+++ src/sys/dev/pci/pcidevs	Thu Nov 14 09:10:41 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1390 2019/11/08 04:37:45 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1391 2019/11/14 09:10:41 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2513,6 +2513,7 @@ product DLINK DL4000		0x4000	DL-4000 Gig
 product DLINK DGE550SX		0x4001	DGE-550SX
 product DLINK DFE520TX		0x4200	DFE-520TX 10/100 Ethernet
 product DLINK DGE528T		0x4300	DGE-528T Gigabit Ethernet
+product DLINK DGE530T_C1	0x4302	DGE-530T C1
 product DLINK DGE560T		0x4b00	DGE-560T Gigabit Ethernet
 product DLINK DGE560T_2		0x4b01	DGE-560T_2 Gigabit Ethernet
 product DLINK DGE560SX		0x4b02	DGE-560SX
@@ -5965,6 +5966,9 @@ product MYRICOM MYRINET	0x8043	Myrinet
 /* Myson-Century Technology products */
 product MYSON MTD803	0x0803	MTD803 3-in-1 Fast Ethernet Controller
 
+/* Ncube products */
+product NCUBE TG3648	0x8168	TP-Link TG-3468 v2 Gigabit Ethernet
+
 /* National Datacomm products */
 product NDC NCP130		0x0130 NCP130 Wireless NIC
 product NDC NCP130A2		0x0131 NCP130 rev A2 Wireless NIC



CVS commit: src/sys/dev/pci

2019-11-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 14 09:11:06 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
 Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.1378 -r1.1379 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1377 -r1.1378 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 14 09:10:41 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.


To generate a diff of this commit:
cvs rdiff -u -r1.1390 -r1.1391 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-14 Thread Hauke Fath
Module Name:src
Committed By:   hauke
Date:   Thu Nov 14 08:49:48 UTC 2019

Modified Files:
src/sys/dev/pci: pucdata.c

Log Message:
The 16C1054 and 16C1058 serial multi-port controllers need a clock
multiplier of 8, just like the 16C1050 controller.

Verified with an ExSys EX-41388.

ryo@ checked back with the hardware his original commit was based on,
and confirmed the change.

XXX Pull-up to netbsd-{7,8,9}


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/pucdata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-14 Thread Hauke Fath
Module Name:src
Committed By:   hauke
Date:   Thu Nov 14 08:49:48 UTC 2019

Modified Files:
src/sys/dev/pci: pucdata.c

Log Message:
The 16C1054 and 16C1058 serial multi-port controllers need a clock
multiplier of 8, just like the 16C1050 controller.

Verified with an ExSys EX-41388.

ryo@ checked back with the hardware his original commit was based on,
and confirmed the change.

XXX Pull-up to netbsd-{7,8,9}


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/pucdata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pucdata.c
diff -u src/sys/dev/pci/pucdata.c:1.104 src/sys/dev/pci/pucdata.c:1.105
--- src/sys/dev/pci/pucdata.c:1.104	Thu May  2 21:33:12 2019
+++ src/sys/dev/pci/pucdata.c	Thu Nov 14 08:49:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pucdata.c,v 1.104 2019/05/02 21:33:12 jdolecek Exp $	*/
+/*	$NetBSD: pucdata.c,v 1.105 2019/11/14 08:49:48 hauke Exp $	*/
 
 /*
  * Copyright (c) 1998, 1999 Christopher G. Demetriou.  All rights reserved.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.104 2019/05/02 21:33:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.105 2019/11/14 08:49:48 hauke Exp $");
 
 #include 
 #include 
@@ -2883,10 +2883,10 @@ const struct puc_device_description puc_
 	{	PCI_VENDOR_SYSTEMBASE, PCI_PRODUCT_SYSTEMBASE_SB16C1054, 0, 0 },
 	{	0x,	0x,		 0, 0 },
 	{
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x08, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x10, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x18, COM_FREQ },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x08, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x10, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x18, COM_FREQ * 8 },
 	},
 	},
 
@@ -2895,14 +2895,14 @@ const struct puc_device_description puc_
 	{   PCI_VENDOR_SYSTEMBASE, PCI_PRODUCT_SYSTEMBASE_SB16C1058, 0, 0 },
 	{	0x,	0x,		 0, 0 },
 	{
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x08, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x10, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x18, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x20, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x28, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x30, COM_FREQ },
-		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x38, COM_FREQ },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x08, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x10, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x18, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x20, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x28, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x30, COM_FREQ * 8 },
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x38, COM_FREQ * 8 },
 	},
 	},
 



CVS commit: src/sys/dev/pci

2019-11-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Nov 12 19:44:46 UTC 2019

Modified Files:
src/sys/dev/pci: if_vte.c

Log Message:
Fix whitespace. From vezhlys


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pci/if_vte.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_vte.c
diff -u src/sys/dev/pci/if_vte.c:1.27 src/sys/dev/pci/if_vte.c:1.28
--- src/sys/dev/pci/if_vte.c:1.27	Wed Oct 30 07:26:28 2019
+++ src/sys/dev/pci/if_vte.c	Tue Nov 12 19:44:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vte.c,v 1.27 2019/10/30 07:26:28 msaitoh Exp $	*/
+/*	$NetBSD: if_vte.c,v 1.28 2019/11/12 19:44:46 maya Exp $	*/
 
 /*
  * Copyright (c) 2011 Manuel Bouyer.  All rights reserved.
@@ -55,7 +55,7 @@
 /* Driver for DM Electronics, Inc, Vortex86 RDC R6040 FastEthernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vte.c,v 1.27 2019/10/30 07:26:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vte.c,v 1.28 2019/11/12 19:44:46 maya Exp $");
 
 #include 
 #include 
@@ -847,7 +847,7 @@ vte_mediachange(struct ifnet *ifp)
 		aprint_error_dev(sc->vte_dev, "could not set media\n");
 		return error;
 	}
-			return 0;
+	return 0;
 
 }
 



CVS commit: src/sys/dev/pci

2019-11-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Nov 12 19:44:46 UTC 2019

Modified Files:
src/sys/dev/pci: if_vte.c

Log Message:
Fix whitespace. From vezhlys


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pci/if_vte.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Nov 10 13:34:52 UTC 2019

Modified Files:
src/sys/dev/pci: if_stge.c

Log Message:
 Add missing initialization of sc_dev.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pci/if_stge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_stge.c
diff -u src/sys/dev/pci/if_stge.c:1.72 src/sys/dev/pci/if_stge.c:1.73
--- src/sys/dev/pci/if_stge.c:1.72	Wed Oct 30 07:26:28 2019
+++ src/sys/dev/pci/if_stge.c	Sun Nov 10 13:34:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_stge.c,v 1.72 2019/10/30 07:26:28 msaitoh Exp $	*/
+/*	$NetBSD: if_stge.c,v 1.73 2019/11/10 13:34:52 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.72 2019/10/30 07:26:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.73 2019/11/10 13:34:52 msaitoh Exp $");
 
 
 #include 
@@ -264,6 +264,7 @@ stge_attach(device_t parent, device_t se
 	uint8_t enaddr[ETHER_ADDR_LEN];
 	char intrbuf[PCI_INTRSTR_LEN];
 
+	sc->sc_dev = self;
 	callout_init(>sc_tick_ch, 0);
 
 	sp = stge_lookup(pa);



CVS commit: src/sys/dev/pci

2019-11-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Nov 10 13:34:52 UTC 2019

Modified Files:
src/sys/dev/pci: if_stge.c

Log Message:
 Add missing initialization of sc_dev.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pci/if_stge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  8 04:45:55 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
 Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.1377 -r1.1378 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1376 -r1.1377 src/sys/dev/pci/pcidevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  8 04:37:45 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
- Update Intel's NVMe SSDs.
  - Modify 0x0953's description to "750 or DC P3[567]00 SSD"
  - Add DC P4[56]00
- Add Apollo Lake TXE HECI.


To generate a diff of this commit:
cvs rdiff -u -r1.1389 -r1.1390 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1389 src/sys/dev/pci/pcidevs:1.1390
--- src/sys/dev/pci/pcidevs:1.1389	Tue Oct 29 16:31:48 2019
+++ src/sys/dev/pci/pcidevs	Fri Nov  8 04:37:45 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1389 2019/10/29 16:31:48 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1390 2019/11/08 04:37:45 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3117,7 +3117,7 @@ product INTEL X1000_HS_UART	0x0936	Quark
 product INTEL X1000_MAC		0x0937	Quark X1000 10/100 Ethernet MAC
 product INTEL X1000_EHCI	0x0939	Quark X1000 EHCI
 product INTEL X1000_OHCI	0x093a	Quark X1000 OHCI
-product INTEL PCIE_NVME_SSD	0x0953	PCIe NVMe SSD
+product INTEL PCIE_NVME_SSD	0x0953	750 or DC P3[567]00 SSD
 product INTEL X1000_HB		0x0958	Quark X1000 Host Bridge
 product INTEL WIFI_LINK_7265_1	0x095a	Dual Band Wireless AC 7265
 product INTEL WIFI_LINK_7265_2	0x095b	Dual Band Wireless AC 7265
@@ -3142,6 +3142,8 @@ product INTEL CORE4G_S_ULT_GT3	0x0a2a	HD
 product INTEL CORE4G_R_ULT_GT3_1 0x0a2b	HD Graphics
 product INTEL CORE4G_R_ULT_GT3_2 0x0a2e	Iris Graphics 5100
 product INTEL DC_P3520_SSD	0x0a53	SSD DC P3520
+product INTEL DC_P4500_SSD	0x0a54	SSD DC P4500
+product INTEL DC_P4600_SSD	0x0a55	SSD DC P4600
 product INTEL HASWELL_HOST_DRAM	0x0c00	Haswell Host Bridge, DRAM
 product INTEL HASWELL_PCIE16	0x0c01	Haswell PCI-E x16 Controller
 product INTEL HASWELL_PCIE8	0x0c05	Haswell PCI-E x8 Controller
@@ -4944,6 +4946,9 @@ product INTEL APL_P2SB		0x5a92	Apollo La
 product INTEL APL_PMC		0x5a94	Apollo Lake PMC
 product INTEL APL_FASTSPI	0x5a96	Apollo Lake Fast SPI
 product INTEL APL_HDA		0x5a98	Apollo Lake HD Audio
+product INTEL APL_TXE_HECI_1	0x5a9a	Apollo Lake TXE HECI1
+product INTEL APL_TXE_HECI_2	0x5a9c	Apollo Lake TXE HECI2
+product INTEL APL_TXE_HECI_3	0x5a9e	Apollo Lake TXE HECI3
 product INTEL APL_ISH		0x5aa2	Apollo Lake Integrated Sensor Hub
 product INTEL APL_XHCI		0x5aa8	Apollo Lake USB Host (xHCI)
 product INTEL APL_XDCI		0x5aaa	Apollo Lake USB Device (xDCI)



CVS commit: src/sys/dev/pci

2019-11-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov  8 04:37:45 UTC 2019

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
- Update Intel's NVMe SSDs.
  - Modify 0x0953's description to "750 or DC P3[567]00 SSD"
  - Add DC P4[56]00
- Add Apollo Lake TXE HECI.


To generate a diff of this commit:
cvs rdiff -u -r1.1389 -r1.1390 src/sys/dev/pci/pcidevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-07 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Nov  7 22:00:37 UTC 2019

Modified Files:
src/sys/dev/pci: if_kse.c

Log Message:
comment touchup


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_kse.c
diff -u src/sys/dev/pci/if_kse.c:1.40 src/sys/dev/pci/if_kse.c:1.41
--- src/sys/dev/pci/if_kse.c:1.40	Thu Nov  7 09:05:29 2019
+++ src/sys/dev/pci/if_kse.c	Thu Nov  7 22:00:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_kse.c,v 1.40 2019/11/07 09:05:29 nisimura Exp $	*/
+/*	$NetBSD: if_kse.c,v 1.41 2019/11/07 22:00:37 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -29,8 +29,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+/*
+ * Micrel 8841/8842 10/100 ethernet driver
+ */
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.40 2019/11/07 09:05:29 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.41 2019/11/07 22:00:37 nisimura Exp $");
 
 #include 
 #include 
@@ -519,7 +523,7 @@ kse_attach(device_t parent, device_t sel
 		 * 8842 MAC is tied with a builtin 3 port switch.
 		 * It can do rate control over either of tx / rx direction
 		 * respectively, tough, this driver leaves the rate unlimited
-		 * intending 100Mbps maxinum.
+		 * intending 100Mbps maximum.
 		 * 2 ports behave in AN mode and this driver provides no mean
 		 * to see the exact details.
 		 */
@@ -543,7 +547,7 @@ kse_attach(device_t parent, device_t sel
 	IFQ_SET_READY(>if_snd);
 
 	/*
-	 * KSZ8842 can handle 802.1Q VLAN-sized frames,
+	 * capable of 802.1Q VLAN-sized frames,
 	 * can do IPv4, TCPv4, and UDPv4 checksums in hardware.
 	 */
 	sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;



CVS commit: src/sys/dev/pci

2019-11-07 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Nov  7 22:00:37 UTC 2019

Modified Files:
src/sys/dev/pci: if_kse.c

Log Message:
comment touchup


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-07 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Nov  7 09:05:29 UTC 2019

Modified Files:
src/sys/dev/pci: if_kse.c

Log Message:
clarify 8842 MAC behaves 100FDX only has no alternative media selection
possible.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pci

2019-11-07 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Nov  7 09:05:29 UTC 2019

Modified Files:
src/sys/dev/pci: if_kse.c

Log Message:
clarify 8842 MAC behaves 100FDX only has no alternative media selection
possible.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_kse.c
diff -u src/sys/dev/pci/if_kse.c:1.39 src/sys/dev/pci/if_kse.c:1.40
--- src/sys/dev/pci/if_kse.c:1.39	Wed Nov  6 14:33:52 2019
+++ src/sys/dev/pci/if_kse.c	Thu Nov  7 09:05:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_kse.c,v 1.39 2019/11/06 14:33:52 nisimura Exp $	*/
+/*	$NetBSD: if_kse.c,v 1.40 2019/11/07 09:05:29 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,8 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.39 2019/11/06 14:33:52 nisimura Exp $");
-
+__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.40 2019/11/07 09:05:29 nisimura Exp $");
 
 #include 
 #include 
@@ -328,6 +327,7 @@ static void txreap(struct kse_softc *);
 static void lnkchg(struct kse_softc *);
 static int ksephy_change(struct ifnet *);
 static void ksephy_status(struct ifnet *, struct ifmediareq *);
+static void nopifm_status(struct ifnet *, struct ifmediareq *);
 static void phy_tick(void *);
 #ifdef KSE_EVENT_COUNTERS
 static void stat_tick(void *);
@@ -514,8 +514,16 @@ kse_attach(device_t parent, device_t sel
 		ifmedia_add(ifm, IFM_ETHER | IFM_AUTO, 0, NULL);
 		ifmedia_set(ifm, IFM_ETHER | IFM_AUTO);
 	} else {
-		ifmedia_init(ifm, 0, NULL, NULL);
-		ifmedia_add(ifm, IFM_ETHER | IFM_100_TX, 0, NULL);
+		/*
+		 * pretend 100FDX w/ no alternative media selection.
+		 * 8842 MAC is tied with a builtin 3 port switch.
+		 * It can do rate control over either of tx / rx direction
+		 * respectively, tough, this driver leaves the rate unlimited
+		 * intending 100Mbps maxinum.
+		 * 2 ports behave in AN mode and this driver provides no mean
+		 * to see the exact details.
+		 */
+		ifmedia_init(ifm, 0, NULL, nopifm_status);
 		ifmedia_add(ifm, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL);
 		ifmedia_set(ifm, IFM_ETHER | IFM_100_TX | IFM_FDX);
 	}
@@ -1345,6 +1353,21 @@ printf("P1SR: %04x link %s\n", p1sr, (p1
 }
 
 static void
+nopifm_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+{
+	struct kse_softc *sc = ifp->if_softc;
+	struct ifmedia *ifm = >sc_media;
+
+#if KSE_LINKDEBUG > 1
+printf("p1sr: %04x, p2sr: %04x\n", CSR_READ_2(sc, P1SR), CSR_READ_2(sc, P2SR));
+#endif
+
+	/* 8842 MAC pretends 100FDX all the time */
+	ifmr->ifm_active = ifm->ifm_cur->ifm_media;
+	ifmr->ifm_status = IFM_AVALID | IFM_ACTIVE;
+}
+
+static void
 phy_tick(void *arg)
 {
 	struct kse_softc *sc = arg;



CVS commit: src/sys/dev/pci

2019-11-06 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Wed Nov  6 14:33:52 UTC 2019

Modified Files:
src/sys/dev/pci: if_kse.c

Log Message:
major rework to fix link control breakage


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_kse.c
diff -u src/sys/dev/pci/if_kse.c:1.38 src/sys/dev/pci/if_kse.c:1.39
--- src/sys/dev/pci/if_kse.c:1.38	Wed May 29 10:07:29 2019
+++ src/sys/dev/pci/if_kse.c	Wed Nov  6 14:33:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_kse.c,v 1.38 2019/05/29 10:07:29 msaitoh Exp $	*/
+/*	$NetBSD: if_kse.c,v 1.39 2019/11/06 14:33:52 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.38 2019/05/29 10:07:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.39 2019/11/06 14:33:52 nisimura Exp $");
 
 
 #include 
@@ -58,6 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1
 #include 
 #include 
 
+#define KSE_LINKDEBUG 0
+
 #define CSR_READ_4(sc, off) \
 	bus_space_read_4(sc->sc_st, sc->sc_sh, off)
 #define CSR_WRITE_4(sc, off, val) \
@@ -93,6 +95,17 @@ __KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1
 #define P1SR	0x514	/* port 1 status */
 #define P2CR4	0x532	/* port 2 control 4 */
 #define P2SR	0x534	/* port 2 status */
+#define PxCR_STARTNEG	(1U << 9)	/* restart auto negotiation */
+#define PxCR_AUTOEN	(1U << 7)	/* auto negotiation enable */
+#define PxCR_SPD100	(1U << 6)	/* force speed 100 */
+#define PxCR_USEFDX	(1U << 5)	/* force full duplex */
+#define PxCR_USEFC	(1U << 4)	/* advertise pause flow control */
+#define PxSR_ACOMP	(1U << 6)	/* auto negotiation completed */
+#define PxSR_SPD100	(1U << 10)	/* speed is 100Mbps */
+#define PxSR_FDX	(1U << 9)	/* full duplex */
+#define PxSR_LINKUP	(1U << 5)	/* link is good */
+#define PxSR_RXFLOW	(1U << 12)	/* receive flow control active */
+#define PxSR_TXFLOW	(1U << 11)	/* transmit flow control active */
 
 #define TXC_BS_MSK	0x3f00	/* burst size */
 #define TXC_BS_SFT	(24)		/* 1,2,4,8,16,32 or 0 for unlimited */
@@ -207,8 +220,8 @@ struct kse_softc {
 	void *sc_ih;			/* interrupt cookie */
 
 	struct ifmedia sc_media;	/* ifmedia information */
-	int sc_media_status;		/* PHY */
-	int sc_media_active;		/* PHY */
+	int sc_linkstatus;		/* last P1SR register value */
+
 	callout_t  sc_callout;		/* MII tick callout */
 	callout_t  sc_stat_ch;		/* statistics counter callout */
 
@@ -313,11 +326,9 @@ static int kse_intr(void *);
 static void rxintr(struct kse_softc *);
 static void txreap(struct kse_softc *);
 static void lnkchg(struct kse_softc *);
-static int ifmedia_upd(struct ifnet *);
-static void ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int ksephy_change(struct ifnet *);
+static void ksephy_status(struct ifnet *, struct ifmediareq *);
 static void phy_tick(void *);
-static int ifmedia2_upd(struct ifnet *);
-static void ifmedia2_sts(struct ifnet *, struct ifmediareq *);
 #ifdef KSE_EVENT_COUNTERS
 static void stat_tick(void *);
 static void zerostats(struct kse_softc *);
@@ -493,8 +504,9 @@ kse_attach(device_t parent, device_t sel
 	/* Initialize ifmedia structures. */
 	ifm = >sc_media;
 	sc->sc_ethercom.ec_ifmedia = ifm;
+	sc->sc_linkstatus = 0;
 	if (sc->sc_chip == 0x8841) {
-		ifmedia_init(ifm, 0, ifmedia_upd, ifmedia_sts);
+		ifmedia_init(ifm, 0, ksephy_change, ksephy_status);
 		ifmedia_add(ifm, IFM_ETHER | IFM_10_T, 0, NULL);
 		ifmedia_add(ifm, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL);
 		ifmedia_add(ifm, IFM_ETHER | IFM_100_TX, 0, NULL);
@@ -502,9 +514,10 @@ kse_attach(device_t parent, device_t sel
 		ifmedia_add(ifm, IFM_ETHER | IFM_AUTO, 0, NULL);
 		ifmedia_set(ifm, IFM_ETHER | IFM_AUTO);
 	} else {
-		ifmedia_init(ifm, 0, ifmedia2_upd, ifmedia2_sts);
-		ifmedia_add(ifm, IFM_ETHER | IFM_AUTO, 0, NULL);
-		ifmedia_set(ifm, IFM_ETHER | IFM_AUTO);
+		ifmedia_init(ifm, 0, NULL, NULL);
+		ifmedia_add(ifm, IFM_ETHER | IFM_100_TX, 0, NULL);
+		ifmedia_add(ifm, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL);
+		ifmedia_set(ifm, IFM_ETHER | IFM_100_TX | IFM_FDX);
 	}
 
 	printf("%s: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto\n",
@@ -766,7 +779,8 @@ kse_init(struct ifnet *ifp)
 	kse_set_filter(sc);
 
 	/* set current media */
-	(void)ifmedia_upd(ifp);
+	if (sc->sc_chip == 0x8841)
+		(void)ksephy_change(ifp);
 
 	/* enable transmitter and receiver */
 	CSR_WRITE_4(sc, MDTXC, sc->sc_txc);
@@ -1257,92 +1271,77 @@ lnkchg(struct kse_softc *sc)
 {
 	struct ifmediareq ifmr;
 
-#if 0 /* rambling link status */
-	printf("%s: link %s\n", device_xname(sc->sc_dev),
-	(CSR_READ_2(sc, P1SR) & (1U << 5)) ? "up" : "down");
+#if KSE_LINKDEBUG > 0
+printf("link change detected\n");
 #endif
-	ifmedia_sts(>sc_ethercom.ec_if, );
+	ksephy_status(>sc_ethercom.ec_if, );
 }
 
 static int
-ifmedia_upd(struct ifnet *ifp)

CVS commit: src/sys/dev/pci

2019-11-06 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Wed Nov  6 14:33:52 UTC 2019

Modified Files:
src/sys/dev/pci: if_kse.c

Log Message:
major rework to fix link control breakage


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/pci/if_kse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   3   4   5   6   7   >