Module Name:    src
Committed By:   simonb
Date:           Fri Jun  5 09:18:35 UTC 2020

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

Log Message:
Rework CVMSEG LM usage a litte:
 - remove unused LM slots
 - use #defines for defining the size of CVMSEG LM users

XXX: Need to dynamically set CVMMEMCTL[LMEMSZ] during startup so we can
     both adapt to any future increase in CVMSEG LM usage and not waste
     any more L2 that we need to.
XXX: Still need to move general IOBDMA conf to a different (new?) header.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/cavium/octeonvar.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/mips/cavium/dev/if_cnmac.c
cvs rdiff -u -r1.9 -r1.10 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/octeonvar.h
diff -u src/sys/arch/mips/cavium/octeonvar.h:1.8 src/sys/arch/mips/cavium/octeonvar.h:1.9
--- src/sys/arch/mips/cavium/octeonvar.h:1.8	Sun May 31 06:27:06 2020
+++ src/sys/arch/mips/cavium/octeonvar.h	Fri Jun  5 09:18:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeonvar.h,v 1.8 2020/05/31 06:27:06 simonb Exp $	*/
+/*	$NetBSD: octeonvar.h,v 1.9 2020/06/05 09:18:35 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -148,26 +148,18 @@ struct cpu_softc {
 /*
  * CVMSEG (``scratch'') memory map
  */
+
+#define CVMSEG_LM_RNM_SIZE	16	/* limited by CN70XX hardware (why?) */
+#define CVMSEG_LM_ETHER_COUNT	4	/* limits number of cnmac devices */
+
 struct octeon_cvmseg_map {
-	/* 0-3 */
-	uint64_t		csm_xxx_0;
-	uint64_t		csm_xxx_1;
-	uint64_t		csm_xxx_2;
 	uint64_t		csm_pow_intr;
 
-	/* 4-19 */
 	struct octeon_cvmseg_ether_map {
-		uint64_t	csm_ether_fau_req;
 		uint64_t	csm_ether_fau_done;
-		uint64_t	csm_ether_fau_cmdptr;
-		uint64_t	csm_ether_xxx_3;
-	} csm_ether[4/* XXX */];
-
-	/* 20-31 */
-	uint64_t	xxx_20_32[32 - 20];
+	} csm_ether[CVMSEG_LM_ETHER_COUNT];
 
-	/* 32-63 */
-	uint64_t	csm_rnm[32];
+	uint64_t	csm_rnm[CVMSEG_LM_RNM_SIZE];
 } __packed;
 #define	OCTEON_CVMSEG_OFFSET(entry) \
 	offsetof(struct octeon_cvmseg_map, entry)

Index: src/sys/arch/mips/cavium/dev/if_cnmac.c
diff -u src/sys/arch/mips/cavium/dev/if_cnmac.c:1.19 src/sys/arch/mips/cavium/dev/if_cnmac.c:1.20
--- src/sys/arch/mips/cavium/dev/if_cnmac.c:1.19	Sun May 31 06:27:06 2020
+++ src/sys/arch/mips/cavium/dev/if_cnmac.c	Fri Jun  5 09:18:35 2020
@@ -1,8 +1,8 @@
-/*	$NetBSD: if_cnmac.c,v 1.19 2020/05/31 06:27:06 simonb Exp $	*/
+/*	$NetBSD: if_cnmac.c,v 1.20 2020/06/05 09:18:35 simonb Exp $	*/
 
 #include <sys/cdefs.h>
 #if 0
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.19 2020/05/31 06:27:06 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.20 2020/06/05 09:18:35 simonb Exp $");
 #endif
 
 #include "opt_octeon.h"
@@ -295,6 +295,16 @@ cnmac_attach(device_t parent, device_t s
 	sc->sc_gmx = ga->ga_gmx;
 	sc->sc_gmx_port = ga->ga_gmx_port;
 
+	if (sc->sc_port >= CVMSEG_LM_ETHER_COUNT) {
+		/*
+		 * If we got here, increase CVMSEG_LM_ETHER_COUNT
+		 * in octeonvar.h .
+		 */
+		printf("%s: ERROR out of CVMSEG LM buffers\n",
+		    device_xname(self));
+		return;
+	}
+
 	sc->sc_init_flag = 0;
 	/*
 	 * XXXUEBAYASI

Index: src/sys/arch/mips/cavium/dev/octeon_rnm.c
diff -u src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.9 src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.10
--- src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.9	Sun May 31 06:27:06 2020
+++ src/sys/arch/mips/cavium/dev/octeon_rnm.c	Fri Jun  5 09:18:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_rnm.c,v 1.9 2020/05/31 06:27:06 simonb Exp $	*/
+/*	$NetBSD: octeon_rnm.c,v 1.10 2020/06/05 09:18:35 simonb Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -99,7 +99,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.9 2020/05/31 06:27:06 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.10 2020/06/05 09:18:35 simonb Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -368,8 +368,8 @@ octrnm_iobdma(struct octrnm_softc *sc, u
 	    __SHIFTIN(RNM_IOBDMA_MAJORDID, IOBDMA_MAJORDID) |
 	    __SHIFTIN(RNM_IOBDMA_SUBDID, IOBDMA_SUBDID);
 
-	KASSERT(nwords < 128);	/* iobdma address restriction */
-	KASSERT(nwords <= 32);	/* octeon_cvmseg_map limitation */
+	KASSERT(nwords < 128);			/* iobdma address restriction */
+	KASSERT(nwords <= CVMSEG_LM_RNM_SIZE);	/* size of CVMSEM LM buffer */
 
 	octeon_iobdma_write_8(iobdma);
 	OCTEON_SYNCIOBDMA;

Reply via email to