CVS commit: src/sys/arch/mips/cavium/dev

2023-07-20 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Thu Jul 20 23:31:28 UTC 2023

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_gmx.c

Log Message:
octeon_gmx.c: fix spelling in (default disabled) error messages


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/mips/cavium/dev/octeon_gmx.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/arch/mips/cavium/dev/octeon_gmx.c
diff -u src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.22 src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.23
--- src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.22	Fri Jun  3 12:10:50 2022
+++ src/sys/arch/mips/cavium/dev/octeon_gmx.c	Thu Jul 20 23:31:27 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_gmx.c,v 1.22 2022/06/03 12:10:50 andvar Exp $	*/
+/*	$NetBSD: octeon_gmx.c,v 1.23 2023/07/20 23:31:27 gutteridge Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.22 2022/06/03 12:10:50 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.23 2023/07/20 23:31:27 gutteridge Exp $");
 
 #include 
 #include 
@@ -585,10 +585,10 @@ octgmx_set_filter(struct octgmx_port_sof
 		SET(ctl, RXN_ADR_CTL_BCST);
 	}
 	if (ISSET(ifp->if_flags, IFF_PROMISC)) {
-		dprintf("promiscas(reject cam)\n");
+		dprintf("promiscuous (reject cam)\n");
 		CLR(ctl, RXN_ADR_CTL_CAM_MODE);
 	} else {
-		dprintf("not promiscas(accept cam)\n");
+		dprintf("not promiscuous (accept cam)\n");
 		SET(ctl, RXN_ADR_CTL_CAM_MODE);
 	}
 



CVS commit: src/sys/arch/mips/cavium/dev

2023-07-20 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Thu Jul 20 23:31:28 UTC 2023

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_gmx.c

Log Message:
octeon_gmx.c: fix spelling in (default disabled) error messages


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/mips/cavium/dev/octeon_gmx.c

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



CVS commit: src/sys/arch/mips/cavium/dev

2023-03-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 21 22:07:29 UTC 2023

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_rnm.c

Log Message:
octrnm(4): Raise delay on startup.

According to CN50XX-HRM-V0.99E and CN78XX-HM-0.99E:

   The entropy is provided by the jitter of 125 of 128 free-running
   oscillators XORed into a 128-bit LFSR.  The LFSR accumulates entropy
   over 81 cycles, after which it is fed into a SHA-1 engine.
   [...]
   The SHA-1 engine runs once every 81 cycles.
   [...]
   The hardware produces new 64-bit random number every 81 cycles.

The last sentence means that we only need to wait 81 cycles _between_
consecutive SHA-1 outputs (which isn't relevant anyway because we
reconfigure it into raw mode later), but the first two quotes might
mean that we need to wait 81+81 cycles for the _first_ output to be
produced on boot when running the self-test.

Now, in this case, the self-test is run with the LFSR unhooked, by
clearing the RNM_CTL_STATUS[ENT_EN] bit, so that SHA-1 is computed
from a known input -- this is really just paranoia to make sure that
_some_ functions of the device (which is conjured out of thin air at
a fixed virtual address, with no firmware bindings to guide us)
behave as we expect.

And it's not clear if it really does take 81+81 cycles for the first
SHA-1 output to appear when the LFSR isn't feeding into it anyway.
But experimentally, delay of 81+81 cycles seems to work whereas a
delay of only 81 cycles crashes.

PR kern/57280

XXX pullup-10
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/mips/cavium/dev/octeon_rnm.c

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



CVS commit: src/sys/arch/mips/cavium/dev

2023-03-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 21 22:07:29 UTC 2023

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_rnm.c

Log Message:
octrnm(4): Raise delay on startup.

According to CN50XX-HRM-V0.99E and CN78XX-HM-0.99E:

   The entropy is provided by the jitter of 125 of 128 free-running
   oscillators XORed into a 128-bit LFSR.  The LFSR accumulates entropy
   over 81 cycles, after which it is fed into a SHA-1 engine.
   [...]
   The SHA-1 engine runs once every 81 cycles.
   [...]
   The hardware produces new 64-bit random number every 81 cycles.

The last sentence means that we only need to wait 81 cycles _between_
consecutive SHA-1 outputs (which isn't relevant anyway because we
reconfigure it into raw mode later), but the first two quotes might
mean that we need to wait 81+81 cycles for the _first_ output to be
produced on boot when running the self-test.

Now, in this case, the self-test is run with the LFSR unhooked, by
clearing the RNM_CTL_STATUS[ENT_EN] bit, so that SHA-1 is computed
from a known input -- this is really just paranoia to make sure that
_some_ functions of the device (which is conjured out of thin air at
a fixed virtual address, with no firmware bindings to guide us)
behave as we expect.

And it's not clear if it really does take 81+81 cycles for the first
SHA-1 output to appear when the LFSR isn't feeding into it anyway.
But experimentally, delay of 81+81 cycles seems to work whereas a
delay of only 81 cycles crashes.

PR kern/57280

XXX pullup-10
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/mips/cavium/dev/octeon_rnm.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/arch/mips/cavium/dev/octeon_rnm.c
diff -u src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.15 src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.16
--- src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.15	Sat Mar 19 11:55:03 2022
+++ src/sys/arch/mips/cavium/dev/octeon_rnm.c	Tue Mar 21 22:07:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_rnm.c,v 1.15 2022/03/19 11:55:03 riastradh Exp $	*/
+/*	$NetBSD: octeon_rnm.c,v 1.16 2023/03/21 22:07:29 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -99,7 +99,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.15 2022/03/19 11:55:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.16 2023/03/21 22:07:29 riastradh Exp $");
 
 #include 
 #include 
@@ -119,7 +119,8 @@ __KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c
 //#define	OCTRNM_DEBUG
 
 #define	ENT_DELAY_CLOCK 8	/* cycles for each 64-bit RO sample batch */
-#define	RNG_DELAY_CLOCK 81	/* cycles for each SHA-1 output */
+#define	LFSR_DELAY_CLOCK 81	/* cycles to fill LFSR buffer */
+#define	SHA1_DELAY_CLOCK 81	/* cycles to compute SHA-1 output */
 #define	NROGROUPS	16
 #define	RNG_FIFO_WORDS	(512/sizeof(uint64_t))
 
@@ -193,7 +194,7 @@ octrnm_attach(device_t parent, device_t 
 	 */
 	octrnm_reset(sc);
 	octrnm_conditioned_deterministic(sc);
-	octrnm_delay(RNG_DELAY_CLOCK*1);
+	octrnm_delay(LFSR_DELAY_CLOCK + SHA1_DELAY_CLOCK);
 	sample = octrnm_load(sc);
 	if (sample != expected)
 		aprint_error_dev(self, "self-test: read %016"PRIx64","



CVS commit: src/sys/arch/mips/cavium/dev

2022-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 29 06:59:02 UTC 2022

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c octeon_smi.c octeon_xhci.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/mips/cavium/dev/if_cnmac.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/cavium/dev/octeon_smi.c \
src/sys/arch/mips/cavium/dev/octeon_xhci.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/arch/mips/cavium/dev/if_cnmac.c
diff -u src/sys/arch/mips/cavium/dev/if_cnmac.c:1.27 src/sys/arch/mips/cavium/dev/if_cnmac.c:1.28
--- src/sys/arch/mips/cavium/dev/if_cnmac.c:1.27	Sun Sep 18 11:38:48 2022
+++ src/sys/arch/mips/cavium/dev/if_cnmac.c	Thu Sep 29 06:59:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cnmac.c,v 1.27 2022/09/18 11:38:48 thorpej Exp $	*/
+/*	$NetBSD: if_cnmac.c,v 1.28 2022/09/29 06:59:01 skrll Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.27 2022/09/18 11:38:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.28 2022/09/29 06:59:01 skrll Exp $");
 
 /*
  * If no free send buffer is available, free all the sent buffers and bail out.
@@ -318,7 +318,7 @@ cnmac_attach(device_t parent, device_t s
 	IFQ_SET_MAXLEN(>if_snd, uimax(GATHER_QUEUE_SIZE, IFQ_MAXLEN));
 	IFQ_SET_READY(>if_snd);
 
-	
+
 	ifp->if_capabilities =
 #if 0	/* XXX: no tx checksum yet */
 	IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx |

Index: src/sys/arch/mips/cavium/dev/octeon_smi.c
diff -u src/sys/arch/mips/cavium/dev/octeon_smi.c:1.7 src/sys/arch/mips/cavium/dev/octeon_smi.c:1.8
--- src/sys/arch/mips/cavium/dev/octeon_smi.c:1.7	Wed Jan 27 03:10:21 2021
+++ src/sys/arch/mips/cavium/dev/octeon_smi.c	Thu Sep 29 06:59:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_smi.c,v 1.7 2021/01/27 03:10:21 thorpej Exp $	*/
+/*	$NetBSD: octeon_smi.c,v 1.8 2022/09/29 06:59:01 skrll Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_smi.c,v 1.7 2021/01/27 03:10:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_smi.c,v 1.8 2022/09/29 06:59:01 skrll Exp $");
 
 #include 
 #include 
@@ -198,7 +198,7 @@ octsmi_read(struct octsmi_softc *sc, int
 	uint64_t smi_rd;
 	int timo;
 
-	_SMI_WR8(sc, SMI_CMD_OFFSET, 
+	_SMI_WR8(sc, SMI_CMD_OFFSET,
 	__SHIFTIN(SMI_CMD_PHY_OP_READ, SMI_CMD_PHY_OP) |
 	__SHIFTIN(phy_addr, SMI_CMD_PHY_ADR) |
 	__SHIFTIN(reg, SMI_CMD_REG_ADR));
Index: src/sys/arch/mips/cavium/dev/octeon_xhci.c
diff -u src/sys/arch/mips/cavium/dev/octeon_xhci.c:1.7 src/sys/arch/mips/cavium/dev/octeon_xhci.c:1.8
--- src/sys/arch/mips/cavium/dev/octeon_xhci.c:1.7	Wed Nov 10 17:19:29 2021
+++ src/sys/arch/mips/cavium/dev/octeon_xhci.c	Thu Sep 29 06:59:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_xhci.c,v 1.7 2021/11/10 17:19:29 msaitoh Exp $ */
+/*	$NetBSD: octeon_xhci.c,v 1.8 2022/09/29 06:59:01 skrll Exp $ */
 /*	$OpenBSD: octxhci.c,v 1.4 2019/09/29 04:32:23 visa Exp $	*/
 
 /*
@@ -380,7 +380,7 @@ octxhci_dwc3_init(struct xhci_softc *sc)
 }
 
 /*  bus_space(9) */
-#define CHIP			octxhci 
+#define CHIP			octxhci
 #define CHIP_IO
 #define	CHIP_LITTLE_ENDIAN
 



CVS commit: src/sys/arch/mips/cavium/dev

2022-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 29 06:59:02 UTC 2022

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c octeon_smi.c octeon_xhci.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/mips/cavium/dev/if_cnmac.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/cavium/dev/octeon_smi.c \
src/sys/arch/mips/cavium/dev/octeon_xhci.c

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



CVS commit: src/sys/arch/mips/cavium/dev

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 11:38:48 UTC 2022

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c if_cnmacvar.h

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mips/cavium/dev/if_cnmac.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/cavium/dev/if_cnmacvar.h

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



CVS commit: src/sys/arch/mips/cavium/dev

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 11:38:48 UTC 2022

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c if_cnmacvar.h

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mips/cavium/dev/if_cnmac.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/cavium/dev/if_cnmacvar.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/arch/mips/cavium/dev/if_cnmac.c
diff -u src/sys/arch/mips/cavium/dev/if_cnmac.c:1.26 src/sys/arch/mips/cavium/dev/if_cnmac.c:1.27
--- src/sys/arch/mips/cavium/dev/if_cnmac.c:1.26	Thu May 27 03:23:29 2021
+++ src/sys/arch/mips/cavium/dev/if_cnmac.c	Sun Sep 18 11:38:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cnmac.c,v 1.26 2021/05/27 03:23:29 simonb Exp $	*/
+/*	$NetBSD: if_cnmac.c,v 1.27 2022/09/18 11:38:48 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.26 2021/05/27 03:23:29 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.27 2022/09/18 11:38:48 thorpej Exp $");
 
 /*
  * If no free send buffer is available, free all the sent buffers and bail out.
@@ -546,7 +546,6 @@ cnmac_send_queue_flush_fetch(struct cnma
 static inline void
 cnmac_send_queue_flush(struct cnmac_softc *sc)
 {
-	struct ifnet *ifp = >sc_ethercom.ec_if;
 	const int64_t sent_count = sc->sc_hard_done_cnt;
 	int i;
 
@@ -563,7 +562,7 @@ cnmac_send_queue_flush(struct cnmac_soft
 
 		m_freem(m);
 
-		CLR(ifp->if_flags, IFF_OACTIVE);
+		sc->sc_txbusy = false;
 	}
 
 	octfau_op_inc_fetch_8(>sc_fau_done, i);
@@ -996,7 +995,10 @@ cnmac_start(struct ifnet *ifp)
 	 */
 	cnmac_send_queue_flush_prefetch(sc);
 
-	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
+		goto last;
+
+	if (sc->sc_txbusy)
 		goto last;
 
 	if (__predict_false(!octgmx_link_status(sc->sc_gmx_port)))
@@ -1015,7 +1017,7 @@ cnmac_start(struct ifnet *ifp)
 		 * buffers and bail out.
 		 */
 		if (cnmac_send_queue_is_full(sc)) {
-			SET(ifp->if_flags, IFF_OACTIVE);
+			sc->sc_txbusy = true;
 			if (wdc > 0)
 octpko_op_doorbell_write(sc->sc_port,
 sc->sc_port, wdc);
@@ -1066,7 +1068,7 @@ cnmac_watchdog(struct ifnet *ifp)
 	cnmac_configure(sc);
 
 	SET(ifp->if_flags, IFF_RUNNING);
-	CLR(ifp->if_flags, IFF_OACTIVE);
+	sc->sc_txbusy = false;
 	ifp->if_timer = 0;
 
 	cnmac_start(ifp);
@@ -1100,7 +1102,7 @@ cnmac_init(struct ifnet *ifp)
 	callout_schedule(>sc_tick_free_ch, hz);
 
 	SET(ifp->if_flags, IFF_RUNNING);
-	CLR(ifp->if_flags, IFF_OACTIVE);
+	sc->sc_txbusy = false;
 
 	return 0;
 }
@@ -1118,7 +1120,8 @@ cnmac_stop(struct ifnet *ifp, int disabl
 	octgmx_port_enable(sc->sc_gmx_port, 0);
 
 	/* Mark the interface as down and cancel the watchdog timer. */
-	CLR(ifp->if_flags, IFF_RUNNING | IFF_OACTIVE);
+	CLR(ifp->if_flags, IFF_RUNNING);
+	sc->sc_txbusy = false;
 	ifp->if_timer = 0;
 }
 

Index: src/sys/arch/mips/cavium/dev/if_cnmacvar.h
diff -u src/sys/arch/mips/cavium/dev/if_cnmacvar.h:1.4 src/sys/arch/mips/cavium/dev/if_cnmacvar.h:1.5
--- src/sys/arch/mips/cavium/dev/if_cnmacvar.h:1.4	Tue Jun 23 05:17:13 2020
+++ src/sys/arch/mips/cavium/dev/if_cnmacvar.h	Sun Sep 18 11:38:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cnmacvar.h,v 1.4 2020/06/23 05:17:13 simonb Exp $	*/
+/*	$NetBSD: if_cnmacvar.h,v 1.5 2022/09/18 11:38:48 thorpej Exp $	*/
 
 #undef DEBUG
 #ifdef DEBUG
@@ -64,6 +64,7 @@ struct cnmac_softc {
 	SIMPLEQ_HEAD(, _send_queue_entry)
 sc_sendq;
 	uint64_t		sc_ext_callback_cnt;
+	bool			sc_txbusy;
 
 	uint32_t		sc_port;
 	uint32_t		sc_port_type;



CVS commit: src/sys/arch/mips/cavium/dev

2022-01-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 26 18:57:56 UTC 2022

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_uart.c

Log Message:
Fix initialization of the register map by using the com_init_regs()
helper function. Pointed out by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mips/cavium/dev/octeon_uart.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/arch/mips/cavium/dev/octeon_uart.c
diff -u src/sys/arch/mips/cavium/dev/octeon_uart.c:1.9 src/sys/arch/mips/cavium/dev/octeon_uart.c:1.10
--- src/sys/arch/mips/cavium/dev/octeon_uart.c:1.9	Tue Jun 23 05:18:43 2020
+++ src/sys/arch/mips/cavium/dev/octeon_uart.c	Wed Jan 26 18:57:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_uart.c,v 1.9 2020/06/23 05:18:43 simonb Exp $	*/
+/*	$NetBSD: octeon_uart.c,v 1.10 2022/01/26 18:57:55 martin Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_uart.c,v 1.9 2020/06/23 05:18:43 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_uart.c,v 1.10 2022/01/26 18:57:55 martin Exp $");
 
 #include 
 #include 
@@ -68,7 +68,6 @@ const bus_addr_t octuart_com_bases[] = {
 	MIO_UART1_BASE
 };
 const struct com_regs octuart_com_regs = {
-	.cr_nports = COM_NPORTS,
 	.cr_map = {
 		[COM_REG_RXDATA] =	MIO_UART_RBR_OFFSET,
 		[COM_REG_TXDATA] =	MIO_UART_THR_OFFSET,
@@ -117,9 +116,9 @@ octuart_iobus_attach(device_t parent, de
 	int status;
 
 	sc_com->sc_dev = self;
-	sc_com->sc_regs = octuart_com_regs;
-	sc_com->sc_regs.cr_iot = aa->aa_bust;
-	sc_com->sc_regs.cr_iobase = aa->aa_unit->addr;
+	com_init_regs(_com->sc_regs, aa->aa_bust, 0, aa->aa_unit->addr);
+	memcpy(sc_com->sc_regs.cr_map, octuart_com_regs.cr_map,
+	sizeof(octuart_com_regs.cr_map));
 
 	sc->sc_irq = aa->aa_unit->irq;
 
@@ -183,9 +182,9 @@ octuart_com_cnattach(bus_space_tag_t bus
 {
 	struct com_regs regs;
 
-	(void)memcpy(, _com_regs, sizeof(regs));
-	regs.cr_iot = bust;
-	regs.cr_iobase = octuart_com_bases[portno];
+	com_init_regs(, bust, 0, octuart_com_bases[portno]);
+	memcpy(regs.cr_map, octuart_com_regs.cr_map,
+	sizeof(octuart_com_regs.cr_map));
 
 	return comcnattach1(
 		,



CVS commit: src/sys/arch/mips/cavium/dev

2022-01-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 26 18:57:56 UTC 2022

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_uart.c

Log Message:
Fix initialization of the register map by using the com_init_regs()
helper function. Pointed out by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mips/cavium/dev/octeon_uart.c

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



Re: CVS commit: src/sys/arch/mips/cavium/dev

2020-06-26 Thread Simon Burge
Hi Rin,

Rin Okuyama wrote:

> Hi,
>
> On 2020/06/23 14:18, Simon Burge wrote:
> > Module Name:src
> > Committed By:   simonb
> > Date:   Tue Jun 23 05:18:43 UTC 2020
> > 
> > Modified Files:
> > src/sys/arch/mips/cavium/dev: octeon_uart.c
> > 
> > Log Message:
> > Add support for a very simple output-only console so early printf() can 
> > work.
> > Minor tweaks, remove some unused code.
> > 
> > 
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/cavium/dev/octeon_uart.c
>
> Didn't you forget to ``cvs add octeon_uartvar.h''? Periodic build fails as:

Yep, indeed!  Added, thanks for pointing this out.

Cheers,
Simon.


Re: CVS commit: src/sys/arch/mips/cavium/dev

2020-06-26 Thread Rin Okuyama

Hi,

On 2020/06/23 14:18, Simon Burge wrote:

Module Name:src
Committed By:   simonb
Date:   Tue Jun 23 05:18:43 UTC 2020

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_uart.c

Log Message:
Add support for a very simple output-only console so early printf() can work.
Minor tweaks, remove some unused code.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/cavium/dev/octeon_uart.c


Didn't you forget to ``cvs add octeon_uartvar.h''? Periodic build fails as:

|/home/source/ab/HEAD/src/sys/arch/mips/cavium/dev/octeon_uart.c:48:10: fatal 
error: mips/cavium/dev/octeon_uartvar.h: No such file or directory
| #include 
|  ^~

Thanks,
rin


CVS commit: src/sys/arch/mips/cavium/dev

2019-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jun  7 07:41:22 UTC 2019

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c

Log Message:
Delay setting of the filters at attach time a bit to avoid using an
unitialized mutex. From msaitoh@.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/mips/cavium/dev/if_cnmac.c

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



CVS commit: src/sys/arch/mips/cavium/dev

2019-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jun  7 07:41:22 UTC 2019

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c

Log Message:
Delay setting of the filters at attach time a bit to avoid using an
unitialized mutex. From msaitoh@.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/mips/cavium/dev/if_cnmac.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/arch/mips/cavium/dev/if_cnmac.c
diff -u src/sys/arch/mips/cavium/dev/if_cnmac.c:1.13 src/sys/arch/mips/cavium/dev/if_cnmac.c:1.14
--- src/sys/arch/mips/cavium/dev/if_cnmac.c:1.13	Wed May 29 07:46:08 2019
+++ src/sys/arch/mips/cavium/dev/if_cnmac.c	Fri Jun  7 07:41:22 2019
@@ -1,8 +1,8 @@
-/*	$NetBSD: if_cnmac.c,v 1.13 2019/05/29 07:46:08 msaitoh Exp $	*/
+/*	$NetBSD: if_cnmac.c,v 1.14 2019/06/07 07:41:22 martin Exp $	*/
 
 #include 
 #if 0
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.13 2019/05/29 07:46:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.14 2019/06/07 07:41:22 martin Exp $");
 #endif
 
 #include "opt_octeon.h"
@@ -372,10 +372,10 @@ octeon_eth_attach(device_t parent, devic
 	sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
 
 	octeon_gmx_set_mac_addr(sc->sc_gmx_port, enaddr);
-	octeon_gmx_set_filter(sc->sc_gmx_port);
 
 	if_attach(ifp);
 	ether_ifattach(ifp, enaddr);
+	octeon_gmx_set_filter(sc->sc_gmx_port);
 
 	/* XXX */
 	sc->sc_rate_recv_check_link_cap.tv_sec = 1;



CVS commit: src/sys/arch/mips/cavium/dev

2019-05-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 29 07:46:09 UTC 2019

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c

Log Message:
- Simplify MII structure initialization and reference.
- Use the common path of SIOCGIFMEDIA in sys/net/if_ethersubr.c


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/cavium/dev/if_cnmac.c

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



CVS commit: src/sys/arch/mips/cavium/dev

2019-05-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 29 07:46:09 UTC 2019

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c

Log Message:
- Simplify MII structure initialization and reference.
- Use the common path of SIOCGIFMEDIA in sys/net/if_ethersubr.c


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/cavium/dev/if_cnmac.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/arch/mips/cavium/dev/if_cnmac.c
diff -u src/sys/arch/mips/cavium/dev/if_cnmac.c:1.12 src/sys/arch/mips/cavium/dev/if_cnmac.c:1.13
--- src/sys/arch/mips/cavium/dev/if_cnmac.c:1.12	Fri Apr 26 06:33:33 2019
+++ src/sys/arch/mips/cavium/dev/if_cnmac.c	Wed May 29 07:46:08 2019
@@ -1,8 +1,8 @@
-/*	$NetBSD: if_cnmac.c,v 1.12 2019/04/26 06:33:33 msaitoh Exp $	*/
+/*	$NetBSD: if_cnmac.c,v 1.13 2019/05/29 07:46:08 msaitoh Exp $	*/
 
 #include 
 #if 0
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.12 2019/04/26 06:33:33 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.13 2019/05/29 07:46:08 msaitoh Exp $");
 #endif
 
 #include "opt_octeon.h"
@@ -536,33 +536,36 @@ static int
 octeon_eth_mediainit(struct octeon_eth_softc *sc)
 {
 	struct ifnet *ifp = >sc_ethercom.ec_if;
+	struct mii_data *mii = >sc_mii;
 	prop_object_t phy;
 
-	sc->sc_mii.mii_ifp = ifp;
-	sc->sc_mii.mii_readreg = octeon_eth_mii_readreg;
-	sc->sc_mii.mii_writereg = octeon_eth_mii_writereg;
-	sc->sc_mii.mii_statchg = octeon_eth_mii_statchg;
-	ifmedia_init(>sc_mii.mii_media, 0, octeon_eth_mediachange,
+	mii->mii_ifp = ifp;
+	mii->mii_readreg = octeon_eth_mii_readreg;
+	mii->mii_writereg = octeon_eth_mii_writereg;
+	mii->mii_statchg = octeon_eth_mii_statchg;
+	sc->sc_ethercom.ec_mii = mii;
+
+	/* Initialize ifmedia structures. */
+	ifmedia_init(>mii_media, 0, octeon_eth_mediachange,
 	octeon_eth_mediastatus);
 
 	phy = prop_dictionary_get(device_properties(sc->sc_dev), "phy-addr");
 	KASSERT(phy != NULL);
 
-	mii_attach(sc->sc_dev, >sc_mii,
-	0x, prop_number_integer_value(phy),
+	mii_attach(sc->sc_dev, mii, 0x, prop_number_integer_value(phy),
 	MII_OFFSET_ANY, MIIF_DOPAUSE);
 
 	/* XXX XXX XXX */
-	if (LIST_FIRST(>sc_mii.mii_phys) != NULL) {
+	if (LIST_FIRST(>mii_phys) != NULL) {
 		/* XXX XXX XXX */
-		ifmedia_set(>sc_mii.mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(>mii_media, IFM_ETHER | IFM_AUTO);
 		/* XXX XXX XXX */
 	} else {
 		/* XXX XXX XXX */
-		ifmedia_add(>sc_mii.mii_media, IFM_ETHER | IFM_NONE,
+		ifmedia_add(>mii_media, IFM_ETHER | IFM_NONE,
 		MII_MEDIA_NONE, NULL);
 		/* XXX XXX XXX */
-		ifmedia_set(>sc_mii.mii_media, IFM_ETHER | IFM_NONE);
+		ifmedia_set(>mii_media, IFM_ETHER | IFM_NONE);
 		/* XXX XXX XXX */
 	}
 	/* XXX XXX XXX */
@@ -827,9 +830,6 @@ octeon_eth_ioctl(struct ifnet *ifp, u_lo
 			sc->sc_gmx_port->sc_port_flowflags =
 ifr->ifr_media & IFM_ETH_FMASK;
 		}
-		/* FALLTHROUGH */
-	case SIOCGIFMEDIA:
-		/* XXX: Flow contorol */
 		error = ifmedia_ioctl(ifp, ifr, >sc_mii.mii_media, cmd);
 		break;
 	default:



CVS commit: src/sys/arch/mips/cavium/dev

2019-05-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue May 28 14:20:09 UTC 2019

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_gmx.c

Log Message:
 Fix compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/cavium/dev/octeon_gmx.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/arch/mips/cavium/dev/octeon_gmx.c
diff -u src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.4 src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.5
--- src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.4	Tue May 28 07:41:47 2019
+++ src/sys/arch/mips/cavium/dev/octeon_gmx.c	Tue May 28 14:20:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_gmx.c,v 1.4 2019/05/28 07:41:47 msaitoh Exp $	*/
+/*	$NetBSD: octeon_gmx.c,v 1.5 2019/05/28 14:20:09 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.4 2019/05/28 07:41:47 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.5 2019/05/28 14:20:09 msaitoh Exp $");
 
 #include "opt_octeon.h"
 
@@ -922,7 +922,7 @@ octeon_gmx_rgmii_set_mac_addr(struct oct
 static int
 octeon_gmx_rgmii_set_filter(struct octeon_gmx_port_softc *sc)
 {
-	struct ethercom *ec = >sc_port_ec;
+	struct ethercom *ec = sc->sc_port_ec;
 	struct ifnet *ifp = >ec_if;
 #ifdef OCTEON_ETH_USE_GMX_CAM
 	struct ether_multi *enm;



CVS commit: src/sys/arch/mips/cavium/dev

2019-05-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue May 28 14:20:09 UTC 2019

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_gmx.c

Log Message:
 Fix compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/cavium/dev/octeon_gmx.c

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