Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips/cavium General code cleanup:
details: https://anonhg.NetBSD.org/src/rev/3f13bb841cff
branches: trunk
changeset: 1011092:3f13bb841cff
user: simonb <simonb%NetBSD.org@localhost>
date: Thu Jun 18 13:52:08 2020 +0000
description:
General code cleanup:
- use generic macros for building IO and IOBDMA addresses instead
of many different variations of the same theme.
- use #define's for CVMSEG addresses instead of magic numbers.
- use __BIT/__BITS/__SHIFTIN/__SHIFTOUT in most places, instead of
foo_SHIFT defines or (worse) shifting by magic numbers.
No functional changes.
diffstat:
sys/arch/mips/cavium/dev/if_cnmac.c | 13 +-
sys/arch/mips/cavium/dev/octeon_asxvar.h | 4 +-
sys/arch/mips/cavium/dev/octeon_cop2reg.h | 8 +-
sys/arch/mips/cavium/dev/octeon_cop2var.h | 8 +-
sys/arch/mips/cavium/dev/octeon_fau.c | 41 ++---
sys/arch/mips/cavium/dev/octeon_faureg.h | 27 +++-
sys/arch/mips/cavium/dev/octeon_fauvar.h | 34 ++---
sys/arch/mips/cavium/dev/octeon_fpa.c | 6 +-
sys/arch/mips/cavium/dev/octeon_fpareg.h | 33 +----
sys/arch/mips/cavium/dev/octeon_fpavar.h | 30 ++--
sys/arch/mips/cavium/dev/octeon_gmx.c | 55 ++++----
sys/arch/mips/cavium/dev/octeon_gmxreg.h | 33 ++---
sys/arch/mips/cavium/dev/octeon_gmxvar.h | 18 +-
sys/arch/mips/cavium/dev/octeon_ipd.c | 10 +-
sys/arch/mips/cavium/dev/octeon_ipdreg.h | 11 +-
sys/arch/mips/cavium/dev/octeon_ipdvar.h | 4 +-
sys/arch/mips/cavium/dev/octeon_l2creg.h | 8 +-
sys/arch/mips/cavium/dev/octeon_mpireg.h | 5 +-
sys/arch/mips/cavium/dev/octeon_pip.c | 16 +-
sys/arch/mips/cavium/dev/octeon_pipreg.h | 57 ++++-----
sys/arch/mips/cavium/dev/octeon_pipvar.h | 5 +-
sys/arch/mips/cavium/dev/octeon_pko.c | 7 +-
sys/arch/mips/cavium/dev/octeon_pkoreg.h | 18 +-
sys/arch/mips/cavium/dev/octeon_pkovar.h | 62 ++++-----
sys/arch/mips/cavium/dev/octeon_pow.c | 32 +---
sys/arch/mips/cavium/dev/octeon_powreg.h | 182 ++++++++---------------------
sys/arch/mips/cavium/dev/octeon_powvar.h | 117 ++++++++----------
sys/arch/mips/cavium/dev/octeon_rnm.c | 20 +-
sys/arch/mips/cavium/dev/octeon_rnmreg.h | 32 +----
sys/arch/mips/cavium/dev/octeon_smi.c | 18 +-
sys/arch/mips/cavium/dev/octeon_smireg.h | 6 +-
sys/arch/mips/cavium/dev/octeon_smivar.h | 4 +-
sys/arch/mips/cavium/dev/octeon_twsi.c | 46 ++++---
sys/arch/mips/cavium/dev/octeon_twsireg.h | 32 ++--
sys/arch/mips/cavium/dev/octeon_uart.c | 7 +-
sys/arch/mips/cavium/octeonreg.h | 67 ++++++++++-
sys/arch/mips/cavium/octeonvar.h | 11 +-
37 files changed, 494 insertions(+), 593 deletions(-)
diffs (truncated from 2448 to 300 lines):
diff -r ff81174f88ad -r 3f13bb841cff sys/arch/mips/cavium/dev/if_cnmac.c
--- a/sys/arch/mips/cavium/dev/if_cnmac.c Thu Jun 18 11:50:44 2020 +0000
+++ b/sys/arch/mips/cavium/dev/if_cnmac.c Thu Jun 18 13:52:08 2020 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: if_cnmac.c,v 1.21 2020/06/10 07:34:19 simonb Exp $ */
+/* $NetBSD: if_cnmac.c,v 1.22 2020/06/18 13:52:08 simonb Exp $ */
#include <sys/cdefs.h>
#if 0
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.21 2020/06/10 07:34:19 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.22 2020/06/18 13:52:08 simonb Exp $");
#endif
#include "opt_octeon.h"
@@ -63,18 +63,15 @@
#include <mips/cpuregs.h>
-#include <mips/cavium/dev/octeon_asxreg.h>
+#include <mips/cavium/octeonreg.h>
+#include <mips/cavium/include/iobusvar.h>
+
#include <mips/cavium/dev/octeon_ciureg.h>
-#include <mips/cavium/dev/octeon_npireg.h>
#include <mips/cavium/dev/octeon_gmxreg.h>
-#include <mips/cavium/dev/octeon_ipdreg.h>
#include <mips/cavium/dev/octeon_pipreg.h>
#include <mips/cavium/dev/octeon_powreg.h>
#include <mips/cavium/dev/octeon_faureg.h>
#include <mips/cavium/dev/octeon_fpareg.h>
-#include <mips/cavium/dev/octeon_bootbusreg.h>
-#include <mips/cavium/include/iobusvar.h>
-#include <mips/cavium/octeonvar.h>
#include <mips/cavium/dev/octeon_fpavar.h>
#include <mips/cavium/dev/octeon_gmxvar.h>
#include <mips/cavium/dev/octeon_fauvar.h>
diff -r ff81174f88ad -r 3f13bb841cff sys/arch/mips/cavium/dev/octeon_asxvar.h
--- a/sys/arch/mips/cavium/dev/octeon_asxvar.h Thu Jun 18 11:50:44 2020 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_asxvar.h Thu Jun 18 13:52:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_asxvar.h,v 1.2 2020/05/31 06:27:06 simonb Exp $ */
+/* $NetBSD: octeon_asxvar.h,v 1.3 2020/06/18 13:52:08 simonb Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -53,4 +53,4 @@
int octasx_clk_set(struct octasx_softc *, int, int);
uint64_t octasx_int_summary(struct octasx_softc *sc);
-#endif
+#endif /* _OCTEON_ASXVAR_H_ */
diff -r ff81174f88ad -r 3f13bb841cff sys/arch/mips/cavium/dev/octeon_cop2reg.h
--- a/sys/arch/mips/cavium/dev/octeon_cop2reg.h Thu Jun 18 11:50:44 2020 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_cop2reg.h Thu Jun 18 13:52:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_cop2reg.h,v 1.1 2015/04/29 08:32:01 hikaru Exp $ */
+/* $NetBSD: octeon_cop2reg.h,v 1.2 2020/06/18 13:52:08 simonb Exp $ */
/*
* Copyright (c) 2008 Internet Initiative Japan, Inc.
@@ -33,8 +33,8 @@
* DMFC2 / DMTC2 instructions
*/
-#ifndef _CN30XXCOP2REG_H_
-#define _CN30XXCOP2REG_H_
+#ifndef _OCTEON_COP2REG_H_
+#define _OCTEON_COP2REG_H_
/* 3DES */
@@ -125,4 +125,4 @@
#define CVM_MT_KAS_KEY 0x0080 /* Load Key into KASUMI Unit */
#define CVM_MT_KAS_RESULT 0x0098 /* Load Result into KASUMI Unit */
-#endif /* _CN30XXCOP2REG_H_ */
+#endif /* _OCTEON_COP2REG_H_ */
diff -r ff81174f88ad -r 3f13bb841cff sys/arch/mips/cavium/dev/octeon_cop2var.h
--- a/sys/arch/mips/cavium/dev/octeon_cop2var.h Thu Jun 18 11:50:44 2020 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_cop2var.h Thu Jun 18 13:52:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_cop2var.h,v 1.1 2015/04/29 08:32:01 hikaru Exp $ */
+/* $NetBSD: octeon_cop2var.h,v 1.2 2020/06/18 13:52:08 simonb Exp $ */
/*
* TODO:
@@ -12,8 +12,8 @@
* direction argument (int dir, 0 => encrypt, 1 => decrypt) then branch.
*/
-#ifndef _CN30XXCOP2VAR_H_
-#define _CN30XXCOP2VAR_H_
+#ifndef _OCTEON_COP2VAR_H_
+#define _OCTEON_COP2VAR_H_
#ifdef __OCTEON_USEUN__
#define CNASM_ULD(r, o, b) "uld %["#r"], "#o"(%["#b"]) \n\t"
@@ -1035,4 +1035,4 @@
/* XXX */
-#endif /* _CN30XXCOP2VAR_H_ */
+#endif /* _OCTEON_COP2VAR_H_ */
diff -r ff81174f88ad -r 3f13bb841cff sys/arch/mips/cavium/dev/octeon_fau.c
--- a/sys/arch/mips/cavium/dev/octeon_fau.c Thu Jun 18 11:50:44 2020 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_fau.c Thu Jun 18 13:52:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_fau.c,v 1.2 2020/05/31 06:27:06 simonb Exp $ */
+/* $NetBSD: octeon_fau.c,v 1.3 2020/06/18 13:52:08 simonb Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: octeon_fau.c,v 1.2 2020/05/31 06:27:06 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_fau.c,v 1.3 2020/06/18 13:52:08 simonb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -49,26 +49,18 @@
static inline int64_t
octfau_op_load(uint64_t args)
{
- paddr_t addr;
+ paddr_t addr = OCTEON_ADDR_IO_DID(FAU_MAJOR_DID, FAU_SUB_DID) |
+ __SHIFTIN(args, OCTEON_ADDR_OFFSET);
- addr =
- ((uint64_t)1 << 48) |
- ((uint64_t)(CN30XXFAU_MAJORDID & 0x1f) << 43) |
- ((uint64_t)(CN30XXFAU_SUBDID & 0x7) << 40) |
- ((uint64_t)(args & 0xfffffffffULL) << 0);
return octeon_read_csr(addr);
}
static inline void
octfau_op_store(uint64_t args, int64_t value)
{
- paddr_t addr;
+ paddr_t addr = OCTEON_ADDR_IO_DID(FAU_MAJOR_DID, FAU_SUB_DID) |
+ __SHIFTIN(args, OCTEON_ADDR_OFFSET);
- addr =
- ((uint64_t)1 << 48) |
- ((uint64_t)(CN30XXFAU_MAJORDID & 0x1f) << 43) |
- ((uint64_t)(CN30XXFAU_SUBDID & 0x7) << 40) |
- ((uint64_t)(args & 0xfffffffffULL) << 0);
octeon_write_csr(addr, value);
}
@@ -85,12 +77,11 @@
static inline int64_t
octfau_op_load_paddr(int incval, int tagwait, int reg)
{
- uint64_t args;
+ uint64_t args =
+ __SHIFTIN(incval, POW_LOAD_INCVAL) |
+ __SHIFTIN(tagwait, POW_LOAD_TAGWAIT) |
+ __SHIFTIN(reg, POW_LOAD_REG);
- args =
- ((uint64_t)(incval & 0x3fffff) << 14) |
- ((uint64_t)(tagwait & 0x1) << 13) |
- ((uint64_t)(reg & 0x7ff) << 0);
return octfau_op_load(args);
}
@@ -101,11 +92,8 @@
static inline void
octfau_op_store_paddr(int noadd, int reg, int64_t value)
{
- uint64_t args;
+ uint64_t args = POW_STORE_NOADD | __SHIFTIN(reg, POW_STORE_REG);
- args =
- ((uint64_t)(noadd & 0x1) << 13) |
- ((uint64_t)(reg & 0x7ff) << 0);
octfau_op_store(args, value);
}
@@ -114,6 +102,7 @@
void
octfau_op_init(struct octfau_desc *fd, size_t scroff, size_t regno)
{
+
fd->fd_scroff = scroff;
fd->fd_regno = regno;
}
@@ -121,6 +110,7 @@
uint64_t
octfau_op_save(struct octfau_desc *fd)
{
+
OCTEON_SYNCIOBDMA/* XXX */;
return octeon_cvmseg_read_8(fd->fd_scroff);
}
@@ -128,12 +118,14 @@
void
octfau_op_restore(struct octfau_desc *fd, uint64_t backup)
{
+
octeon_cvmseg_write_8(fd->fd_scroff, backup);
}
int64_t
octfau_op_inc_8(struct octfau_desc *fd, int64_t v)
{
+
octfau_op_iobdma_store_data(fd->fd_scroff, v, 0, OCT_FAU_OP_SIZE_64/* XXX */,
fd->fd_regno);
OCTEON_SYNCIOBDMA/* XXX */;
@@ -143,6 +135,7 @@
int64_t
octfau_op_incwait_8(struct octfau_desc *fd, int v)
{
+
octfau_op_iobdma_store_data(fd->fd_scroff, v, 1, OCT_FAU_OP_SIZE_64/* XXX */,
fd->fd_regno);
/* XXX */
@@ -154,11 +147,13 @@
void
octfau_op_add_8(struct octfau_desc *fd, int64_t v)
{
+
octfau_op_store_paddr(0, fd->fd_regno, v);
}
void
octfau_op_set_8(struct octfau_desc *fd, int64_t v)
{
+
octfau_op_store_paddr(1, fd->fd_regno, v);
}
diff -r ff81174f88ad -r 3f13bb841cff sys/arch/mips/cavium/dev/octeon_faureg.h
--- a/sys/arch/mips/cavium/dev/octeon_faureg.h Thu Jun 18 11:50:44 2020 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_faureg.h Thu Jun 18 13:52:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_faureg.h,v 1.1 2015/04/29 08:32:01 hikaru Exp $ */
+/* $NetBSD: octeon_faureg.h,v 1.2 2020/06/18 13:52:08 simonb Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -33,9 +33,30 @@
#ifndef _OCTEON_FAUREG_H_
#define _OCTEON_FAUREG_H_
+
+#define FAU_MAJOR_DID 0x1e
+#define FAU_SUB_DID 0
+
/* ---- operations */
-#define CN30XXFAU_MAJORDID 0x1e
-#define CN30XXFAU_SUBDID 0
+/* -- load operations */
+#define POW_LOAD_INCVAL __BITS(35,14)
+#define POW_LOAD_TAGWAIT __BIT(13)
+/* reserved __BiTS(12,11) */
+#define POW_LOAD_REG __BITS(10,0)
+
+/* -- iobdma store operations */
+
+#define POW_IOBDMA_LEN 1 /* always 1 for POW */
+#define POW_IOBDMA_INCVAL POW_LOAD_INCVAL
+#define POW_IOBDMA_TAGWAIT POW_LOAD_TAGWAIT
+#define POW_IOBDMA_SIZE __BITS(12,11)
+#define POW_IOBDMA_REG POW_LOAD_REG
+
+/* -- store operations */
+/* reserved __BiTS(35,14) */
+#define POW_STORE_NOADD __BIT(13)
+/* reserved __BiTS(12,11) */
+#define POW_STORE_REG __BITS(10,0)
#endif /* _OCTEON_FAUREG_H_ */
diff -r ff81174f88ad -r 3f13bb841cff sys/arch/mips/cavium/dev/octeon_fauvar.h
--- a/sys/arch/mips/cavium/dev/octeon_fauvar.h Thu Jun 18 11:50:44 2020 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_fauvar.h Thu Jun 18 13:52:08 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_fauvar.h,v 1.2 2020/05/31 06:27:06 simonb Exp $ */
+/* $NetBSD: octeon_fauvar.h,v 1.3 2020/06/18 13:52:08 simonb Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -29,6 +29,8 @@
#ifndef _OCTEON_FAUVAR_H_
#define _OCTEON_FAUVAR_H_
+#include <mips/cavium/octeonreg.h>
+
/* ---- API */
struct octfau_desc {
@@ -89,14 +91,9 @@
static inline void
octfau_op_iobdma(int index, uint64_t args)
{
- uint64_t value;
Home |
Main Index |
Thread Index |
Old Index