CVS commit: src/sys/dev/cadence

2024-11-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 29 17:37:59 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h

Log Message:
Add some more #define and use __BITS with existing ones.

Same code before and after.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/cadence/cemacreg.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/cadence/cemacreg.h
diff -u src/sys/dev/cadence/cemacreg.h:1.7 src/sys/dev/cadence/cemacreg.h:1.8
--- src/sys/dev/cadence/cemacreg.h:1.7	Thu Aug 29 07:22:36 2024
+++ src/sys/dev/cadence/cemacreg.h	Fri Nov 29 17:37:58 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: cemacreg.h,v 1.7 2024/08/29 07:22:36 skrll Exp $	*/
+/*  $NetBSD: cemacreg.h,v 1.8 2024/11/29 17:37:58 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -155,13 +155,18 @@
 
 #define GEM_CFG_GEN	__BIT(10)
 #define GEM_CFG_CLK	__BITS(20, 18)
-#define  GEM_CFG_CLK_8	__SHIFTIN(0, GEM_CFG_CLK)
-#define  GEM_CFG_CLK_16	__SHIFTIN(1, GEM_CFG_CLK)
-#define  GEM_CFG_CLK_32	__SHIFTIN(2, GEM_CFG_CLK)
-#define  GEM_CFG_CLK_48	__SHIFTIN(3, GEM_CFG_CLK)
-#define  GEM_CFG_CLK_64	__SHIFTIN(4, GEM_CFG_CLK)
-#define  GEM_CFG_CLK_96	__SHIFTIN(5, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_8		__SHIFTIN(0, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_16		__SHIFTIN(1, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_32		__SHIFTIN(2, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_48		__SHIFTIN(3, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_64		__SHIFTIN(4, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_96		__SHIFTIN(5, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_128	__SHIFTIN(6, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_224	__SHIFTIN(7, GEM_CFG_CLK)
 #define GEM_CFG_DBW	__BITS(22, 21)
+#define  GEM_CFG_DBW_32		__SHIFTIN(0, GEM_CFG_DBW)
+#define  GEM_CFG_DBW_64		__SHIFTIN(1, GEM_CFG_DBW)
+#define  GEM_CFG_DBW_128	__SHIFTIN(2, GEM_CFG_DBW)
 #define	GEM_CFG_RXCOEN	__BIT(24)
 
 /* Status Register bits: */
@@ -209,21 +214,20 @@
 
 /* PHY Maintenance Register bits: */
 #define	ETH_MAN_LOW	__BIT(31) /* must not be set			*/
-#define	ETH_MAN_HIGH	__BIT(30) /* must be set			*/
+#define	ETH_MAN_HIGH	__BIT(30) /* must be set for clause 22		*/
 
 #define	ETH_MAN_RW	__BITS(29, 28)
-#define	ETH_MAN_RW_RD	__BIT(29)
-#define	ETH_MAN_RW_WR	__BIT(28)
+#define	ETH_MAN_RW_RD	__SHIFTIN(2, ETH_MAN_RW)
+#define	ETH_MAN_RW_WR	__SHIFTIN(1, ETH_MAN_RW)
 
-#define	ETH_MAN_PHYA	0x0F80U /* PHY address (normally 0)		*/
+#define	ETH_MAN_PHYA	__BITS(27, 23) /* PHY address (normally 0)	*/
 #define	ETH_MAN_PHYA_SHIFT 23U
-#define	ETH_MAN_REGA	0x007CU
+#define	ETH_MAN_REGA	__BITS(22, 18)
 #define	ETH_MAN_REGA_SHIFT 18U
-#define	ETH_MAN_CODE	0x0003U /* must be 10			*/
+#define	ETH_MAN_CODE	__BITS(17, 16) /* must be 0b10			*/
 #define	ETH_MAN_CODE_IEEE802_3 \
-			0x0002U
-#define	ETH_MAN_DATA	0xU /* data to be written to the PHY	*/
-
+			__SHIFTIN(2, ETH_MAN_CODE)
+#define	ETH_MAN_DATA	__BITS(15, 0) /* data to be written to the PHY	*/
 #define	ETH_MAN_VAL	(ETH_MAN_HIGH | ETH_MAN_CODE_IEEE802_3)
 
 



CVS commit: src/sys/dev/cadence

2024-11-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 29 17:37:59 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h

Log Message:
Add some more #define and use __BITS with existing ones.

Same code before and after.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/cadence/cemacreg.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/cadence

2024-10-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct  6 19:18:20 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
fix whitespace from previous


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.43 src/sys/dev/cadence/if_cemac.c:1.44
--- src/sys/dev/cadence/if_cemac.c:1.43	Sat Oct  5 07:37:22 2024
+++ src/sys/dev/cadence/if_cemac.c	Sun Oct  6 19:18:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.43 2024/10/05 07:37:22 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.44 2024/10/06 19:18:20 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -48,7 +48,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.43 2024/10/05 07:37:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.44 2024/10/06 19:18:20 skrll Exp $");
 
 #include 
 #include 
@@ -1083,7 +1083,7 @@ cemac_ifstop(struct ifnet *ifp, int disa
 
 	ifp->if_flags &= ~IFF_RUNNING;
 	sc->sc_txbusy = false;
-	sc->sc_mii.mii_media_status &= ~IFM_ACTIVE;
+	sc->sc_mii.mii_media_status &= ~IFM_ACTIVE;
 }
 
 static void



CVS commit: src/sys/dev/cadence

2024-10-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct  6 19:18:20 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
fix whitespace from previous


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/cadence/if_cemac.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/cadence

2024-10-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct  5 07:37:22 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c if_cemacvar.h

Log Message:
Make cemac(4) MP safe.

Tested with qemu and

qemu-system-arm \
-kernel netbsd.ub \
-dtb zynq-zc702.dtb \
-M xilinx-zynq-a9 \
-sd armv7.img \
-append "root=ld0a -x -v" \
-serial null -serial mon:stdio \
-nographic


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/cadence/if_cemac.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/cadence/if_cemacvar.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.42 src/sys/dev/cadence/if_cemac.c:1.43
--- src/sys/dev/cadence/if_cemac.c:1.42	Sun Sep 29 09:13:14 2024
+++ src/sys/dev/cadence/if_cemac.c	Sat Oct  5 07:37:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.42 2024/09/29 09:13:14 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.43 2024/10/05 07:37:22 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -39,8 +39,16 @@
  * used by arm/at91, arm/zynq SoC
  */
 
+/*
+ * Lock order:
+ *
+ *	IFNET_LOCK -> sc_mcast_lock
+ *	IFNET_LOCK -> sc_intr_lock
+ */
+
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.42 2024/09/29 09:13:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.43 2024/10/05 07:37:22 skrll Exp $");
 
 #include 
 #include 
@@ -73,6 +81,11 @@ __KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v
 #include 
 #include 
 
+#ifndef CEMAC_WATCHDOG_TIMEOUT
+#define CEMAC_WATCHDOG_TIMEOUT 5
+#endif
+static int cemac_watchdog_timeout = CEMAC_WATCHDOG_TIMEOUT;
+
 #define DEFAULT_MDCDIV	32
 
 #define CEMAC_READ(x) \
@@ -97,6 +110,7 @@ static void	cemac_statchg(struct ifnet *
 static void	cemac_tick(void *);
 static int	cemac_ifioctl(struct ifnet *, u_long, void *);
 static void	cemac_ifstart(struct ifnet *);
+static void	cemac_ifstart_locked(struct ifnet *);
 static void	cemac_ifwatchdog(struct ifnet *);
 static int	cemac_ifinit(struct ifnet *);
 static void	cemac_ifstop(struct ifnet *, int);
@@ -109,6 +123,36 @@ int cemac_debug = CEMAC_DEBUG;
 #define	DPRINTFN(n, fmt)
 #endif
 
+/*
+ * Perform an interface watchdog reset.
+ */
+static void
+cemac_handle_reset_work(struct work *work, void *arg)
+{
+	struct cemac_softc * const sc = arg;
+	struct ifnet * const ifp = &sc->sc_ethercom.ec_if;
+
+	printf("%s: watchdog timeout -- resetting\n", ifp->if_xname);
+
+	/* Don't want ioctl operations to happen */
+	IFNET_LOCK(ifp);
+
+	/* reset the interface. */
+	cemac_ifinit(ifp);
+
+	IFNET_UNLOCK(ifp);
+
+	/*
+	 * There are still some upper layer processing which call
+	 * ifp->if_start(). e.g. ALTQ or one CPU system
+	 */
+	/* Try to get more packets going. */
+	ifp->if_start(ifp);
+
+	atomic_store_relaxed(&sc->sc_reset_pending, 0);
+}
+
+
 void
 cemac_attach_common(struct cemac_softc *sc)
 {
@@ -217,16 +261,29 @@ cemac_intr(void *arg)
 #endif
 	int bi;
 
+	mutex_enter(sc->sc_intr_lock);
+	if (sc->sc_stopping) {
+		mutex_exit(sc->sc_intr_lock);
+		return 0;
+	}
+
 	imr = ~CEMAC_READ(ETH_IMR);
 	if (!(imr & (ETH_ISR_RCOM | ETH_ISR_TBRE | ETH_ISR_TIDLE |
 	ETH_ISR_RBNA | ETH_ISR_ROVR | ETH_ISR_TCOM))) {
 		// interrupt not enabled, can't be us
+		mutex_exit(sc->sc_intr_lock);
 		return 0;
 	}
 
 	isr = CEMAC_READ(ETH_ISR);
 	CEMAC_WRITE(ETH_ISR, isr);
 	isr &= imr;
+
+	if (isr == 0) {
+		mutex_exit(sc->sc_intr_lock);
+		return 0;
+	}
+
 #ifdef	CEMAC_DEBUG
 	rsr = CEMAC_READ(ETH_RSR);		// get receive status register
 #endif
@@ -338,10 +395,36 @@ cemac_intr(void *arg)
 		goto begin;
 #endif
 
+	mutex_exit(sc->sc_intr_lock);
+
 	return 1;
 }
 
 
+static int
+cemac_ifflags_cb(struct ethercom *ec)
+{
+	struct ifnet * const ifp = &ec->ec_if;
+	struct cemac_softc * const sc = ifp->if_softc;
+	int ret = 0;
+
+	KASSERT(IFNET_LOCKED(ifp));
+	mutex_enter(sc->sc_mcast_lock);
+
+	u_short change = ifp->if_flags ^ sc->sc_if_flags;
+	sc->sc_if_flags = ifp->if_flags;
+
+	if ((change & ~(IFF_CANTCHANGE | IFF_DEBUG)) != 0) {
+		ret = ENETRESET;
+	} else if ((change & IFF_PROMISC) != 0) {
+		if ((sc->sc_if_flags & IFF_RUNNING) != 0)
+			cemac_setaddr(ifp);
+	}
+	mutex_exit(sc->sc_mcast_lock);
+
+	return ret;
+}
+
 static void
 cemac_init(struct cemac_softc *sc)
 {
@@ -354,7 +437,8 @@ cemac_init(struct cemac_softc *sc)
 	int mdcdiv = DEFAULT_MDCDIV;
 #endif
 
-	callout_init(&sc->cemac_tick_ch, 0);
+	callout_init(&sc->cemac_tick_ch, CALLOUT_MPSAFE);
+	callout_setfunc(&sc->cemac_tick_ch, cemac_tick, sc);
 
 	// ok...
 	CEMAC_WRITE(ETH_CTL, ETH_CTL_MPE);	// disable everything
@@ -401,6 +485,17 @@ cemac_init(struct cemac_softc *sc)
 	CEMAC_GEM_WRITE(SA4L, 0);
 	CEMAC_GEM_WRITE(SA4H, 0);
 
+	char wqname[MAXCOMLEN];
+	snprintf(wqname, sizeof(wqname), "%sReset", device_xname(sc->sc_dev));
+	int error = workqueue_create(&sc->sc_reset

CVS commit: src/sys/dev/cadence

2024-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 29 09:13:14 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c if_cemacvar.h

Log Message:
Rename a softc member. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/cadence/if_cemac.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/cadence/if_cemacvar.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/cadence

2024-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 29 09:13:14 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c if_cemacvar.h

Log Message:
Rename a softc member. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/cadence/if_cemac.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/cadence/if_cemacvar.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.41 src/sys/dev/cadence/if_cemac.c:1.42
--- src/sys/dev/cadence/if_cemac.c:1.41	Sun Sep 29 08:55:21 2024
+++ src/sys/dev/cadence/if_cemac.c	Sun Sep 29 09:13:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.41 2024/09/29 08:55:21 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.42 2024/09/29 09:13:14 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.41 2024/09/29 08:55:21 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.42 2024/09/29 09:13:14 skrll Exp $");
 
 #include 
 #include 
@@ -197,8 +197,8 @@ cemac_gctx(struct cemac_softc *sc)
 	}
 
 	// mark we're free
-	if (sc->tx_busy) {
-		sc->tx_busy = false;
+	if (sc->sc_txbusy) {
+		sc->sc_txbusy = false;
 		/* Disable transmit-buffer-free interrupt */
 		/*CEMAC_WRITE(ETH_IDR, ETH_ISR_TBRE);*/
 	}
@@ -725,7 +725,7 @@ start:
 	if (cemac_gctx(sc) == 0) {
 		/* Enable transmit-buffer-free interrupt */
 		CEMAC_WRITE(ETH_IER, ETH_ISR_TBRE);
-		sc->tx_busy = true;
+		sc->sc_txbusy = true;
 		ifp->if_timer = 10;
 		splx(s);
 		return;
@@ -908,7 +908,7 @@ cemac_ifstop(struct ifnet *ifp, int disa
 
 	ifp->if_flags &= ~IFF_RUNNING;
 	ifp->if_timer = 0;
-	sc->tx_busy = false;
+	sc->sc_txbusy = false;
 	sc->sc_mii.mii_media_status &= ~IFM_ACTIVE;
 }
 

Index: src/sys/dev/cadence/if_cemacvar.h
diff -u src/sys/dev/cadence/if_cemacvar.h:1.4 src/sys/dev/cadence/if_cemacvar.h:1.5
--- src/sys/dev/cadence/if_cemacvar.h:1.4	Sun Aug 25 07:25:00 2024
+++ src/sys/dev/cadence/if_cemacvar.h	Sun Sep 29 09:13:14 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_cemacvar.h,v 1.4 2024/08/25 07:25:00 skrll Exp $	*/
+/*  $NetBSD: if_cemacvar.h,v 1.5 2024/09/29 09:13:14 skrll Exp $	*/
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -68,10 +68,11 @@ struct cemac_softc {
 	int			txqi, txqc;
 	struct cemac_qmeta	txq[TX_QLEN];
 	callout_t		cemac_tick_ch;
-	bool			tx_busy;
 
 	unsigned		cemac_flags;
 #define CEMAC_FLAG_GEM	__BIT(0)
+
+	bool			sc_txbusy;
 };
 
 int cemac_intr(void *);



CVS commit: src/sys/dev/cadence

2024-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 29 08:55:21 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Sprinkle some const


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/cadence/if_cemac.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/cadence

2024-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 29 08:55:21 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Sprinkle some const


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.40 src/sys/dev/cadence/if_cemac.c:1.41
--- src/sys/dev/cadence/if_cemac.c:1.40	Wed Aug 28 06:50:17 2024
+++ src/sys/dev/cadence/if_cemac.c	Sun Sep 29 08:55:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.40 2024/08/28 06:50:17 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.41 2024/09/29 08:55:21 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.40 2024/08/28 06:50:17 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.41 2024/09/29 08:55:21 skrll Exp $");
 
 #include 
 #include 
@@ -210,7 +210,7 @@ int
 cemac_intr(void *arg)
 {
 	struct cemac_softc * const sc = arg;
-	struct ifnet * ifp = &sc->sc_ethercom.ec_if;
+	struct ifnet * const ifp = &sc->sc_ethercom.ec_if;
 	uint32_t imr, isr, ctl;
 #ifdef	CEMAC_DEBUG
 	uint32_t rsr;
@@ -347,7 +347,7 @@ cemac_init(struct cemac_softc *sc)
 {
 	bus_dma_segment_t segs;
 	int rsegs, err, i;
-	struct ifnet * ifp = &sc->sc_ethercom.ec_if;
+	struct ifnet * const ifp = &sc->sc_ethercom.ec_if;
 	struct mii_data * const mii = &sc->sc_mii;
 	uint32_t u;
 #if 0
@@ -660,7 +660,7 @@ static void
 cemac_tick(void *arg)
 {
 	struct cemac_softc * const sc = arg;
-	struct ifnet * ifp = &sc->sc_ethercom.ec_if;
+	struct ifnet * const ifp = &sc->sc_ethercom.ec_if;
 	int s;
 
 	if (ISSET(sc->cemac_flags, CEMAC_FLAG_GEM))



CVS commit: src/sys/dev/cadence

2024-08-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Aug 29 07:22:36 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h

Log Message:
Use more BITS(3)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/cadence/cemacreg.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/cadence

2024-08-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Aug 29 07:22:36 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h

Log Message:
Use more BITS(3)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/cadence/cemacreg.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/cadence/cemacreg.h
diff -u src/sys/dev/cadence/cemacreg.h:1.6 src/sys/dev/cadence/cemacreg.h:1.7
--- src/sys/dev/cadence/cemacreg.h:1.6	Wed Aug 28 06:50:17 2024
+++ src/sys/dev/cadence/cemacreg.h	Thu Aug 29 07:22:36 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: cemacreg.h,v 1.6 2024/08/28 06:50:17 skrll Exp $	*/
+/*  $NetBSD: cemacreg.h,v 1.7 2024/08/29 07:22:36 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -137,32 +137,30 @@
 
 /* Configuration Register bits: */
 #define	ETH_CFG_RMII	__BIT(13)  /* 1 = enable RMII (Reduce MII) (AT91RM9200 only) */
-#define	ETH_CFG_RTY	__BIT(12)	/* 1 = retry test enabled		*/
-
-#define	ETH_CFG_CLK	0x0C00U	/* clock*/
-#define	ETH_CFG_CLK_8	0xU
-#define	ETH_CFG_CLK_16	0x0400U
-#define	ETH_CFG_CLK_32	0x0800U
-#define	ETH_CFG_CLK_64	0x0C00U
-
-#define	ETH_CFG_EAE	__BIT(9)	/* 1 = external address match enable	*/
-#define	ETH_CFG_BIG	__BIT(8)	/* 1 = receive up to 1522 bytes	(VLAN)	*/
-#define	ETH_CFG_UNI	__BIT(7)	/* 1 = enable unicast hash		*/
-#define	ETH_CFG_MTI	__BIT(6)	/* 1 = enable multicast hash		*/
-#define	ETH_CFG_NBC	__BIT(5)	/* 1 = ignore received broadcasts	*/
-#define	ETH_CFG_CAF	__BIT(4)	/* 1 = receive all valid frames		*/
+#define	ETH_CFG_RTY	__BIT(12)  /* 1 = retry test enabled		*/
+#define	ETH_CFG_CLK	__BITS(11, 10)	/* clock*/
+#define	 ETH_CFG_CLK_8	__SHIFTIN(0, ETH_CFG_CLK)
+#define	 ETH_CFG_CLK_16	__SHIFTIN(1, ETH_CFG_CLK)
+#define	 ETH_CFG_CLK_32	__SHIFTIN(2, ETH_CFG_CLK)
+#define	 ETH_CFG_CLK_64	__SHIFTIN(3, ETH_CFG_CLK)
+#define	ETH_CFG_EAE	__BIT(9)  /* 1 = external address match enable	*/
+#define	ETH_CFG_BIG	__BIT(8)  /* 1 = receive up to 1522 bytes	(VLAN)	*/
+#define	ETH_CFG_UNI	__BIT(7)  /* 1 = enable unicast hash		*/
+#define	ETH_CFG_MTI	__BIT(6)  /* 1 = enable multicast hash		*/
+#define	ETH_CFG_NBC	__BIT(5)  /* 1 = ignore received broadcasts	*/
+#define	ETH_CFG_CAF	__BIT(4)  /* 1 = receive all valid frames		*/
 #define	ETH_CFG_BR	__BIT(2)
-#define	ETH_CFG_FD	__BIT(1)	/* 1 = force full duplex		*/
-#define	ETH_CFG_SPD	__BIT(0)	/* 1 = 100 Mbps*/
+#define	ETH_CFG_FD	__BIT(1)  /* 1 = force full duplex		*/
+#define	ETH_CFG_SPD	__BIT(0)  /* 1 = 100 Mbps*/
 
 #define GEM_CFG_GEN	__BIT(10)
 #define GEM_CFG_CLK	__BITS(20, 18)
-#define GEM_CFG_CLK_8	__SHIFTIN(0, GEM_CFG_CLK)
-#define GEM_CFG_CLK_16	__SHIFTIN(1, GEM_CFG_CLK)
-#define GEM_CFG_CLK_32	__SHIFTIN(2, GEM_CFG_CLK)
-#define GEM_CFG_CLK_48	__SHIFTIN(3, GEM_CFG_CLK)
-#define GEM_CFG_CLK_64	__SHIFTIN(4, GEM_CFG_CLK)
-#define GEM_CFG_CLK_96	__SHIFTIN(5, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_8	__SHIFTIN(0, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_16	__SHIFTIN(1, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_32	__SHIFTIN(2, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_48	__SHIFTIN(3, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_64	__SHIFTIN(4, GEM_CFG_CLK)
+#define  GEM_CFG_CLK_96	__SHIFTIN(5, GEM_CFG_CLK)
 #define GEM_CFG_DBW	__BITS(22, 21)
 #define	GEM_CFG_RXCOEN	__BIT(24)
 
@@ -178,35 +176,35 @@
 
 
 /* Transmit Status Register bits: */
-#define	ETH_TSR_UND	__BIT(6)	/* 1 = transmit underrun detected	*/
-#define	ETH_TSR_COMP	__BIT(5)	/* 1 = transmit complete		*/
-#define	ETH_TSR_BNQ	__BIT(4)	/* 1 = transmit buffer not queued (at91rm9200 only)	*/
-#define	ETH_TSR_IDLE	__BIT(3)	/* 1 = transmitter idle			*/
-#define	ETH_TSR_RLE	__BIT(2)	/* 1 = retry limit exceeded		*/
-#define	ETH_TSR_COL	__BIT(1)	/* 1 = collision occurred		*/
-#define	ETH_TSR_OVR	__BIT(0)	/* 1 = transmit buffer overrun		*/
+#define	ETH_TSR_UND	__BIT(6)  /* 1 = transmit underrun detected	*/
+#define	ETH_TSR_COMP	__BIT(5)  /* 1 = transmit complete		*/
+#define	ETH_TSR_BNQ	__BIT(4)  /* 1 = transmit buffer not queued (at91rm9200 only)	*/
+#define	ETH_TSR_IDLE	__BIT(3)  /* 1 = transmitter idle			*/
+#define	ETH_TSR_RLE	__BIT(2)  /* 1 = retry limit exceeded		*/
+#define	ETH_TSR_COL	__BIT(1)  /* 1 = collision occurred		*/
+#define	ETH_TSR_OVR	__BIT(0)  /* 1 = transmit buffer overrun		*/
 
 #define	GEM_TSR_TXGO	__BIT(3)
 
 /* Receive Status Register bits: */
-#define	ETH_RSR_OVR	__BIT(2)	/* 1 = RX overrun			*/
-#define	ETH_RSR_REC	__BIT(1)	/* 1 = frame received			*/
-#define	ETH_RSR_BNA	__BIT(0)	/* 1 = buffer not available		*/
+#define	ETH_RSR_OVR	__BIT(2)  /* 1 = RX overrun			*/
+#define	ETH_RSR_REC	__BIT(1)  /* 1 = frame received			*/
+#define	ETH_RSR_BNA	__BIT(0)  /* 1 = buffer not available		*/
 
 
 /* Interrupt bits: */
-#define	ETH_ISR_ABT	__BIT(11)	/* 1 = abort during DMA transfer	*/
-#define	ETH_ISR_ROVR	__BIT(10)	/* 1 = RX overrun			*/
-#define	ETH_ISR_LINK	__BIT(9)	/* 1 = link pin changed			*/
-#define	ETH_ISR

CVS commit: src/sys/dev/cadence

2024-08-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug 28 06:50:18 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h if_cemac.c

Log Message:
Shorten a bit definition name.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/cadence/cemacreg.h
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/cadence/if_cemac.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/cadence/cemacreg.h
diff -u src/sys/dev/cadence/cemacreg.h:1.5 src/sys/dev/cadence/cemacreg.h:1.6
--- src/sys/dev/cadence/cemacreg.h:1.5	Sun Aug 25 21:15:46 2024
+++ src/sys/dev/cadence/cemacreg.h	Wed Aug 28 06:50:17 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: cemacreg.h,v 1.5 2024/08/25 21:15:46 skrll Exp $	*/
+/*  $NetBSD: cemacreg.h,v 1.6 2024/08/28 06:50:17 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -164,7 +164,7 @@
 #define GEM_CFG_CLK_64	__SHIFTIN(4, GEM_CFG_CLK)
 #define GEM_CFG_CLK_96	__SHIFTIN(5, GEM_CFG_CLK)
 #define GEM_CFG_DBW	__BITS(22, 21)
-#define	GEM_CFG_RX_CHKSUM_OFFLD_EN	__BIT(24)
+#define	GEM_CFG_RXCOEN	__BIT(24)
 
 /* Status Register bits: */
 #define	ETH_SR_IDLE	__BIT(2)	/* 1 = PHY logic is running		*/

Index: src/sys/dev/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.39 src/sys/dev/cadence/if_cemac.c:1.40
--- src/sys/dev/cadence/if_cemac.c:1.39	Tue Aug 27 07:53:20 2024
+++ src/sys/dev/cadence/if_cemac.c	Wed Aug 28 06:50:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.39 2024/08/27 07:53:20 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.40 2024/08/28 06:50:17 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.39 2024/08/27 07:53:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.40 2024/08/28 06:50:17 skrll Exp $");
 
 #include 
 #include 
@@ -855,7 +855,7 @@ cemac_ifinit(struct ifnet *ifp)
 			IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Rx |
 			IFCAP_CSUM_TCPv6_Rx | IFCAP_CSUM_UDPv6_Rx)) {
 			cfg = CEMAC_READ(ETH_CFG);
-			cfg |= GEM_CFG_RX_CHKSUM_OFFLD_EN;
+			cfg |= GEM_CFG_RXCOEN;
 			CEMAC_WRITE(ETH_CFG, cfg);
 		}
 	}



CVS commit: src/sys/dev/cadence

2024-08-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug 28 06:50:18 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h if_cemac.c

Log Message:
Shorten a bit definition name.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/cadence/cemacreg.h
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 27 07:53:20 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Wrap long lines


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 27 07:53:20 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Wrap long lines


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.38 src/sys/dev/cadence/if_cemac.c:1.39
--- src/sys/dev/cadence/if_cemac.c:1.38	Tue Aug 27 07:28:59 2024
+++ src/sys/dev/cadence/if_cemac.c	Tue Aug 27 07:53:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.38 2024/08/27 07:28:59 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.39 2024/08/27 07:53:20 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.38 2024/08/27 07:28:59 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.39 2024/08/27 07:53:20 skrll Exp $");
 
 #include 
 #include 
@@ -80,12 +80,12 @@ __KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v
 #define CEMAC_WRITE(x, y) \
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, (x), (y))
 #define CEMAC_GEM_WRITE(x, y)		  \
-	do {  \
-		if (ISSET(sc->cemac_flags, CEMAC_FLAG_GEM))		  \
-			bus_space_write_4(sc->sc_iot, sc->sc_ioh, (GEM_##x), (y)); \
-		else			  \
-			bus_space_write_4(sc->sc_iot, sc->sc_ioh, (ETH_##x), (y)); \
-	} while(0)
+do {  \
+	if (ISSET(sc->cemac_flags, CEMAC_FLAG_GEM))			  \
+		bus_space_write_4(sc->sc_iot, sc->sc_ioh, (GEM_##x), (y));\
+	else  \
+		bus_space_write_4(sc->sc_iot, sc->sc_ioh, (ETH_##x), (y));\
+} while(0)
 
 static void	cemac_init(struct cemac_softc *);
 static int	cemac_gctx(struct cemac_softc *);
@@ -230,29 +230,40 @@ cemac_intr(void *arg)
 #ifdef	CEMAC_DEBUG
 	rsr = CEMAC_READ(ETH_RSR);		// get receive status register
 #endif
-	DPRINTFN(2, ("%s: isr=0x%08X rsr=0x%08X imr=0x%08X\n", __FUNCTION__, isr, rsr, imr));
+	DPRINTFN(2, ("%s: isr=0x%08X rsr=0x%08X imr=0x%08X\n", __FUNCTION__,
+	isr, rsr, imr));
 
 	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
-	if (isr & ETH_ISR_RBNA) {		// out of receive buffers
-		CEMAC_WRITE(ETH_RSR, ETH_RSR_BNA);	// clear interrupt
-		ctl = CEMAC_READ(ETH_CTL);		// get current control register value
-		CEMAC_WRITE(ETH_CTL, ctl & ~ETH_CTL_RE);	// disable receiver
-		CEMAC_WRITE(ETH_RSR, ETH_RSR_BNA);	// clear BNA bit
-		CEMAC_WRITE(ETH_CTL, ctl |  ETH_CTL_RE);	// re-enable receiver
+	// out of receive buffers
+	if (isr & ETH_ISR_RBNA) {
+		// clear interrupt
+		CEMAC_WRITE(ETH_RSR, ETH_RSR_BNA);
+
+		ctl = CEMAC_READ(ETH_CTL);
+		// disable receiver
+		CEMAC_WRITE(ETH_CTL, ctl & ~ETH_CTL_RE);
+		// clear BNA bit
+		CEMAC_WRITE(ETH_RSR, ETH_RSR_BNA);
+		// re-enable receiver
+		CEMAC_WRITE(ETH_CTL, ctl |  ETH_CTL_RE);
+
 		if_statinc_ref(ifp, nsr, if_ierrors);
 		if_statinc_ref(ifp, nsr, if_ipackets);
 		DPRINTFN(1,("%s: out of receive buffers\n", __FUNCTION__));
 	}
 	if (isr & ETH_ISR_ROVR) {
-		CEMAC_WRITE(ETH_RSR, ETH_RSR_OVR);	// clear interrupt
+		// clear interrupt
+		CEMAC_WRITE(ETH_RSR, ETH_RSR_OVR);
 		if_statinc_ref(ifp, nsr, if_ierrors);
 		if_statinc_ref(ifp, nsr, if_ipackets);
 		DPRINTFN(1,("%s: receive overrun\n", __FUNCTION__));
 	}
 
-	if (isr & ETH_ISR_RCOM) {			// packet has been received!
+	// packet has been received!
+	if (isr & ETH_ISR_RCOM) {
 		uint32_t nfo;
-		DPRINTFN(2,("#2 RDSC[%i].INFO=0x%08X\n", sc->rxqi % RX_QLEN, sc->RDSC[sc->rxqi % RX_QLEN].Info));
+		DPRINTFN(2,("#2 RDSC[%i].INFO=0x%08X\n", sc->rxqi % RX_QLEN,
+		sc->RDSC[sc->rxqi % RX_QLEN].Info));
 		while (sc->RDSC[(bi = sc->rxqi % RX_QLEN)].Addr & ETH_RDSC_F_USED) {
 			int fl, csum;
 			struct mbuf *m;
@@ -265,8 +276,9 @@ cemac_intr(void *arg)
 			if (m != NULL)
 MCLGET(m, M_DONTWAIT);
 			if (m != NULL && (m->m_flags & M_EXT)) {
-bus_dmamap_sync(sc->sc_dmat, sc->rxq[bi].m_dmamap, 0,
-		MCLBYTES, BUS_DMASYNC_POSTREAD);
+bus_dmamap_sync(sc->sc_dmat,
+sc->rxq[bi].m_dmamap, 0, MCLBYTES,
+BUS_DMASYNC_POSTREAD);
 bus_dmamap_unload(sc->sc_dmat,
 	sc->rxq[bi].m_dmamap);
 m_set_rcvif(sc->rxq[bi].m, ifp);
@@ -296,15 +308,15 @@ cemac_intr(void *arg)
 	m_adj(m, mtod(m, intptr_t) & 3);
 sc->rxq[bi].m = m;
 bus_dmamap_load(sc->sc_dmat,
-	sc->rxq[bi].m_dmamap,
-	m->m_ext.ext_buf, MCLBYTES,
-	NULL, BUS_DMA_NOWAIT);
-bus_dmamap_sync(sc->sc_dmat, sc->rxq[bi].m_dmamap, 0,
-		MCLBYTES, BUS_DMASYNC_PREREAD);
+sc->rxq[bi].m_dmamap, m->m_ext.ext_buf,
+	MCLBYTES, NULL, BUS_DMA_NOWAIT);
+bus_dmamap_sync(sc->sc_dmat,
+sc->rxq[bi].m_dmamap, 0, MCLBYTES,
+BUS_DMASYNC_PREREAD);
 sc->RDSC[bi].Info = 0;
 sc->RDSC[bi].Addr =
-	sc->rxq[bi].m_dmamap->dm_segs[0].ds_addr
-	| (bi == (RX_QLEN-1) ? ETH_RDSC_F_WRAP : 0);
+sc->rxq[bi].m_dmamap->dm_segs[0].ds

CVS commit: src/sys/dev/cadence

2024-08-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 27 07:29:00 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.37 src/sys/dev/cadence/if_cemac.c:1.38
--- src/sys/dev/cadence/if_cemac.c:1.37	Sun Aug 25 16:27:33 2024
+++ src/sys/dev/cadence/if_cemac.c	Tue Aug 27 07:28:59 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.37 2024/08/25 16:27:33 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.38 2024/08/27 07:28:59 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.37 2024/08/25 16:27:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.38 2024/08/27 07:28:59 skrll Exp $");
 
 #include 
 #include 
@@ -263,7 +263,7 @@ cemac_intr(void *arg)
 
 			MGETHDR(m, M_DONTWAIT, MT_DATA);
 			if (m != NULL)
- MCLGET(m, M_DONTWAIT);
+MCLGET(m, M_DONTWAIT);
 			if (m != NULL && (m->m_flags & M_EXT)) {
 bus_dmamap_sync(sc->sc_dmat, sc->rxq[bi].m_dmamap, 0,
 		MCLBYTES, BUS_DMASYNC_POSTREAD);
@@ -739,7 +739,7 @@ start:
 
 		MGETHDR(mn, M_DONTWAIT, MT_DATA);
 		if (mn == NULL)
-			 goto stop;
+			goto stop;
 		if (m->m_pkthdr.len > MHLEN) {
 			MCLGET(mn, M_DONTWAIT);
 			if ((mn->m_flags & M_EXT) == 0) {



CVS commit: src/sys/dev/cadence

2024-08-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 27 07:29:00 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 21:15:46 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h

Log Message:
Use __BIT{,S}


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/cadence/cemacreg.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/cadence/cemacreg.h
diff -u src/sys/dev/cadence/cemacreg.h:1.4 src/sys/dev/cadence/cemacreg.h:1.5
--- src/sys/dev/cadence/cemacreg.h:1.4	Sun Aug 25 16:32:59 2024
+++ src/sys/dev/cadence/cemacreg.h	Sun Aug 25 21:15:46 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: cemacreg.h,v 1.4 2024/08/25 16:32:59 skrll Exp $	*/
+/*  $NetBSD: cemacreg.h,v 1.5 2024/08/25 21:15:46 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -124,20 +124,20 @@
 #define GEM_CTL_HALTTX		__BIT(10)
 #define GEM_CTL_STARTTX		__BIT(9)
 
-#define	ETH_CTL_BP	0x100U	/* 1 = back pressure enabled		*/
-#define	ETH_CTL_WES	0x080U	/* 1 = statistics registers writeable	*/
-#define	ETH_CTL_ISR	0x040U	/* 1 = increment statistics registers	*/
-#define	ETH_CTL_CSR	0x020U	/* 1 = clear statistics registers	*/
-#define	ETH_CTL_MPE	0x010U	/* 1 = management port enabled		*/
-#define	ETH_CTL_TE	0x008U	/* 1 = transmit enable			*/
-#define	ETH_CTL_RE	0x004U	/* 1 = receive enable			*/
-#define	ETH_CTL_LBL	0x002U	/* 1 = local loopback enabled		*/
-#define	ETH_CTL_LB	0x001U	/* 1 = loopback signal is at high level	*/
+#define	ETH_CTL_BP	__BIT(8)  /* 1 = back pressure enabled		  */
+#define	ETH_CTL_WES	__BIT(7)  /* 1 = statistics registers writeable	  */
+#define	ETH_CTL_ISR	__BIT(6)  /* 1 = increment statistics registers	  */
+#define	ETH_CTL_CSR	__BIT(5)  /* 1 = clear statistics registers	  */
+#define	ETH_CTL_MPE	__BIT(4)  /* 1 = management port enabled	  */
+#define	ETH_CTL_TE	__BIT(3)  /* 1 = transmit enable		  */
+#define	ETH_CTL_RE	__BIT(2)  /* 1 = receive enable			  */
+#define	ETH_CTL_LBL	__BIT(1)  /* 1 = local loopback enabled		  */
+#define	ETH_CTL_LB	__BIT(0)  /* 1 = loopback signal is at high level */
 
 
 /* Configuration Register bits: */
-#define	ETH_CFG_RMII	0x2000U	/* 1 = enable RMII (Reduce MII)	(AT91RM9200 only) */
-#define	ETH_CFG_RTY	0x1000U	/* 1 = retry test enabled		*/
+#define	ETH_CFG_RMII	__BIT(13)  /* 1 = enable RMII (Reduce MII) (AT91RM9200 only) */
+#define	ETH_CFG_RTY	__BIT(12)	/* 1 = retry test enabled		*/
 
 #define	ETH_CFG_CLK	0x0C00U	/* clock*/
 #define	ETH_CFG_CLK_8	0xU
@@ -145,15 +145,15 @@
 #define	ETH_CFG_CLK_32	0x0800U
 #define	ETH_CFG_CLK_64	0x0C00U
 
-#define	ETH_CFG_EAE	0x0200U	/* 1 = external address match enable	*/
-#define	ETH_CFG_BIG	0x0100U	/* 1 = receive up to 1522 bytes	(VLAN)	*/
-#define	ETH_CFG_UNI	0x0080U	/* 1 = enable unicast hash		*/
-#define	ETH_CFG_MTI	0x0040U	/* 1 = enable multicast hash		*/
-#define	ETH_CFG_NBC	0x0020U	/* 1 = ignore received broadcasts	*/
-#define	ETH_CFG_CAF	0x0010U	/* 1 = receive all valid frames		*/
-#define	ETH_CFG_BR	0x0004U
-#define	ETH_CFG_FD	0x0002U	/* 1 = force full duplex		*/
-#define	ETH_CFG_SPD	0x0001U	/* 1 = 100 Mbps*/
+#define	ETH_CFG_EAE	__BIT(9)	/* 1 = external address match enable	*/
+#define	ETH_CFG_BIG	__BIT(8)	/* 1 = receive up to 1522 bytes	(VLAN)	*/
+#define	ETH_CFG_UNI	__BIT(7)	/* 1 = enable unicast hash		*/
+#define	ETH_CFG_MTI	__BIT(6)	/* 1 = enable multicast hash		*/
+#define	ETH_CFG_NBC	__BIT(5)	/* 1 = ignore received broadcasts	*/
+#define	ETH_CFG_CAF	__BIT(4)	/* 1 = receive all valid frames		*/
+#define	ETH_CFG_BR	__BIT(2)
+#define	ETH_CFG_FD	__BIT(1)	/* 1 = force full duplex		*/
+#define	ETH_CFG_SPD	__BIT(0)	/* 1 = 100 Mbps*/
 
 #define GEM_CFG_GEN	__BIT(10)
 #define GEM_CFG_CLK	__BITS(20, 18)
@@ -167,9 +167,9 @@
 #define	GEM_CFG_RX_CHKSUM_OFFLD_EN	__BIT(24)
 
 /* Status Register bits: */
-#define	ETH_SR_IDLE	0x0004U	/* 1 = PHY logic is running		*/
-#define	ETH_SR_MDIO	0x0002U	/* 1 = MDIO pin set			*/
-#define	ETH_SR_LINK	0x0001U
+#define	ETH_SR_IDLE	__BIT(2)	/* 1 = PHY logic is running		*/
+#define	ETH_SR_MDIO	__BIT(1)	/* 1 = MDIO pin set			*/
+#define	ETH_SR_LINK	__BIT(0)
 
 
 /* Transmit Control Register bits: */
@@ -178,44 +178,44 @@
 
 
 /* Transmit Status Register bits: */
-#define	ETH_TSR_UND	0x40U	/* 1 = transmit underrun detected	*/
-#define	ETH_TSR_COMP	0x20U	/* 1 = transmit complete		*/
-#define	ETH_TSR_BNQ	0x10U	/* 1 = transmit buffer not queued (at91rm9200 only)	*/
-#define	ETH_TSR_IDLE	0x08U	/* 1 = transmitter idle			*/
-#define	ETH_TSR_RLE	0x04U	/* 1 = retry limit exceeded		*/
-#define	ETH_TSR_COL	0x02U	/* 1 = collision occurred		*/
-#define	ETH_TSR_OVR	0x01U	/* 1 = transmit buffer overrun		*/
+#define	ETH_TSR_UND	__BIT(6)	/* 1 = transmit underrun detected	*/
+#define	ETH_TSR_COMP	__BIT(5)	/* 1 = transmit complete		*/
+#define	ETH_TSR_BNQ	__BIT(4)	/* 1 = transmit buffer not queued (at91rm9200 only)	*/
+#define	ETH_TSR_IDLE	__BIT(3)	/* 1 = transmitter idle

CVS commit: src/sys/dev/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 21:15:46 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h

Log Message:
Use __BIT{,S}


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/cadence/cemacreg.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/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 16:32:59 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h

Log Message:
Remove redundant register offsets in the comments.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/cadence/cemacreg.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/cadence/cemacreg.h
diff -u src/sys/dev/cadence/cemacreg.h:1.3 src/sys/dev/cadence/cemacreg.h:1.4
--- src/sys/dev/cadence/cemacreg.h:1.3	Mon Aug 24 18:51:37 2015
+++ src/sys/dev/cadence/cemacreg.h	Sun Aug 25 16:32:59 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: cemacreg.h,v 1.3 2015/08/24 18:51:37 rjs Exp $	*/
+/*  $NetBSD: cemacreg.h,v 1.4 2024/08/25 16:32:59 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -36,53 +36,53 @@
 /* Ethernet MAC (EMAC),
  * at91rm9200.pdf, page 573 */
 
-#define	ETH_CTL		0x00U	/* 0x00: Control Register		*/
-#define	ETH_CFG		0x04U	/* 0x04: Configuration Register		*/
-#define	ETH_SR		0x08U	/* 0x08: Status Register		*/
-#define	ETH_TAR		0x0CU	/* 0x0C: Transmit Address Register (at91rm9200 only)	*/
-#define	ETH_TCR		0x10U	/* 0x10: Transmit Control Register (at91rm9200 only)	*/
-#define	ETH_TSR		0x14U	/* 0x14: Transmit Status Register	*/
-#define	ETH_RBQP	0x18U	/* 0x18: Receive Buffer Queue Pointer	*/
-#define ETH_TBQP	0x1CU	/* 0x1C: Transmit Buffer Queue Pointer	*/
-#define	ETH_RSR		0x20U	/* 0x20: Receive Status Register	*/
-#define	ETH_ISR		0x24U	/* 0x24: Interrupt Status Register	*/
-#define	ETH_IER		0x28U	/* 0x28: Interrupt Enable Register	*/
-#define	ETH_IDR		0x2CU	/* 0x2C: Interrupt Disable Register	*/
-#define	ETH_IMR		0x30U	/* 0x30: Interrupt Mask Register	*/
-#define	ETH_MAN		0x34U	/* 0x34: PHY Maintenance Register	*/
-
-#define	ETH_FRA		0x40U	/* 0x40: Frames Transmitted OK		*/
-#define	ETH_SCOL	0x44U	/* 0x44: Single Collision Frames	*/
-#define	ETH_MCOL	0x48U	/* 0x48: Multiple Collision Frames	*/
-#define	ETH_OK		0x4CU	/* 0x4C: Frames Received OK		*/
-#define	ETH_SEQE	0x50U	/* 0x50: Frame Check Sequence Errors	*/
-#define	ETH_ALE		0x54U	/* 0x54: Alignment Errors		*/
-#define	ETH_DTE		0x58U	/* 0x58: Deferred Transmission Frame	*/
-#define	ETH_LCOL	0x5CU	/* 0x5C: Late Collisions		*/
-#define	ETH_ECOL	0x60U	/* 0x60: Excessive Collisions		*/
-#define	ETH_CSE		0x64U	/* 0x64: Carrier Sense Errors		*/
-#define	ETH_TUE		0x68U	/* 0x68: Transmit Underrun Errors	*/
-#define	ETH_CDE		0x6CU	/* 0x6C: Code Errors			*/
-#define	ETH_ELR		0x70U	/* 0x70: Excessive Length Errors	*/
-#define	ETH_RJB		0x74U	/* 0x74: Receive Jabbers		*/
-#define	ETH_USF		0x78U	/* 0x78: Undersize Frames		*/
-#define	ETH_SQEE	0x7CU	/* 0x7C: SQE Test Errors		*/
-#define	ETH_DRFC	0x80U	/* 0x80: Discarded RX Frames		*/
-
-#define	ETH_HSH		0x90U	/* 0x90: Hash Address High		*/
-#define	ETH_HSL		0x94U	/* 0x94: Hash Address Low		*/
-
-#define	ETH_SA1L	0x98U	/* 0x98: Specific Address 1 Low		*/
-#define	ETH_SA1H	0x9CU	/* 0x9C: Specific Address 1 High	*/
+#define	ETH_CTL		0x00U	/* Control Register			*/
+#define	ETH_CFG		0x04U	/* Configuration Register		*/
+#define	ETH_SR		0x08U	/* Status Register			*/
+#define	ETH_TAR		0x0CU	/* Transmit Address Register (at91rm9200 only)	*/
+#define	ETH_TCR		0x10U	/* Transmit Control Register (at91rm9200 only)	*/
+#define	ETH_TSR		0x14U	/* Transmit Status Register		*/
+#define	ETH_RBQP	0x18U	/* Receive Buffer Queue Pointer		*/
+#define	ETH_TBQP	0x1CU	/* Transmit Buffer Queue Pointer	*/
+#define	ETH_RSR		0x20U	/* Receive Status Register		*/
+#define	ETH_ISR		0x24U	/* Interrupt Status Register		*/
+#define	ETH_IER		0x28U	/* Interrupt Enable Register		*/
+#define	ETH_IDR		0x2CU	/* Interrupt Disable Register		*/
+#define	ETH_IMR		0x30U	/* Interrupt Mask Register		*/
+#define	ETH_MAN		0x34U	/* PHY Maintenance Register		*/
+
+#define	ETH_FRA		0x40U	/* Frames Transmitted OK		*/
+#define	ETH_SCOL	0x44U	/* Single Collision Frames		*/
+#define	ETH_MCOL	0x48U	/* Multiple Collision Frames		*/
+#define	ETH_OK		0x4CU	/* Frames Received OK			*/
+#define	ETH_SEQE	0x50U	/* Frame Check Sequence Errors		*/
+#define	ETH_ALE		0x54U	/* Alignment Errors			*/
+#define	ETH_DTE		0x58U	/* Deferred Transmission Frame		*/
+#define	ETH_LCOL	0x5CU	/* Late Collisions			*/
+#define	ETH_ECOL	0x60U	/* Excessive Collisions			*/
+#define	ETH_CSE		0x64U	/* Carrier Sense Errors			*/
+#define	ETH_TUE		0x68U	/* Transmit Underrun Errors		*/
+#define	ETH_CDE		0x6CU	/* Code Errors*/
+#define	ETH_ELR		0x70U	/* Excessive Length Errors		*/
+#define	ETH_RJB		0x74U	/* Receive Jabbers			*/
+#define	ETH_USF		0x78U	/* Undersize Frames			*/
+#define	ETH_SQEE	0x7CU	/* SQE Test Errors			*/
+#define	ETH_DRFC	0x80U	/* Discarded RX Frames			*/
+
+#define	ETH_HSH		0x90U	/* Hash Address High			*/
+#define	ETH_HSL		0x94U	/* Hash Address Low			*/
+
+#define	ETH_SA1L	0x98U	/* Specific Address 1 Low		*/
+#define	ETH_SA1H	0x9CU	/* Specific Address 1 High		*/
 
-#defin

CVS commit: src/sys/dev/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 16:32:59 UTC 2024

Modified Files:
src/sys/dev/cadence: cemacreg.h

Log Message:
Remove redundant register offsets in the comments.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/cadence/cemacreg.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/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 16:27:33 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Comment fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.36 src/sys/dev/cadence/if_cemac.c:1.37
--- src/sys/dev/cadence/if_cemac.c:1.36	Sun Aug 25 16:25:29 2024
+++ src/sys/dev/cadence/if_cemac.c	Sun Aug 25 16:27:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.36 2024/08/25 16:25:29 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.37 2024/08/25 16:27:33 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.36 2024/08/25 16:25:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.37 2024/08/25 16:27:33 skrll Exp $");
 
 #include 
 #include 
@@ -389,7 +389,7 @@ cemac_init(struct cemac_softc *sc)
 	CEMAC_GEM_WRITE(SA4L, 0);
 	CEMAC_GEM_WRITE(SA4H, 0);
 
-	/* Allocate a page of memory for receive queue descriptors */
+	/* Allocate memory for receive queue descriptors */
 	sc->rbqlen = roundup(ETH_DSC_SIZE * (RX_QLEN + 1) * 2, PAGE_SIZE);
 	DPRINTFN(1,("%s: rbqlen=%i\n", __FUNCTION__, sc->rbqlen));
 
@@ -418,7 +418,7 @@ cemac_init(struct cemac_softc *sc)
 	sc->rbqpage_dsaddr = sc->rbqpage_dmamap->dm_segs[0].ds_addr;
 	memset(sc->rbqpage, 0, sc->rbqlen);
 
-	/* Allocate a page of memory for transmit queue descriptors */
+	/* Allocate memory for transmit queue descriptors */
 	sc->tbqlen = roundup(ETH_DSC_SIZE * (TX_QLEN + 1) * 2, PAGE_SIZE);
 	DPRINTFN(1,("%s: tbqlen=%i\n", __FUNCTION__, sc->tbqlen));
 



CVS commit: src/sys/dev/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 16:27:33 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Comment fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 16:25:29 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Use roundup - same code before and after.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.35 src/sys/dev/cadence/if_cemac.c:1.36
--- src/sys/dev/cadence/if_cemac.c:1.35	Sun Aug 25 16:06:46 2024
+++ src/sys/dev/cadence/if_cemac.c	Sun Aug 25 16:25:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.35 2024/08/25 16:06:46 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.36 2024/08/25 16:25:29 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.35 2024/08/25 16:06:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.36 2024/08/25 16:25:29 skrll Exp $");
 
 #include 
 #include 
@@ -390,8 +390,7 @@ cemac_init(struct cemac_softc *sc)
 	CEMAC_GEM_WRITE(SA4H, 0);
 
 	/* Allocate a page of memory for receive queue descriptors */
-	sc->rbqlen = (ETH_DSC_SIZE * (RX_QLEN + 1) * 2 + PAGE_SIZE - 1) / PAGE_SIZE;
-	sc->rbqlen *= PAGE_SIZE;
+	sc->rbqlen = roundup(ETH_DSC_SIZE * (RX_QLEN + 1) * 2, PAGE_SIZE);
 	DPRINTFN(1,("%s: rbqlen=%i\n", __FUNCTION__, sc->rbqlen));
 
 	err = bus_dmamem_alloc(sc->sc_dmat, sc->rbqlen, 0,
@@ -420,8 +419,7 @@ cemac_init(struct cemac_softc *sc)
 	memset(sc->rbqpage, 0, sc->rbqlen);
 
 	/* Allocate a page of memory for transmit queue descriptors */
-	sc->tbqlen = (ETH_DSC_SIZE * (TX_QLEN + 1) * 2 + PAGE_SIZE - 1) / PAGE_SIZE;
-	sc->tbqlen *= PAGE_SIZE;
+	sc->tbqlen = roundup(ETH_DSC_SIZE * (TX_QLEN + 1) * 2, PAGE_SIZE);
 	DPRINTFN(1,("%s: tbqlen=%i\n", __FUNCTION__, sc->tbqlen));
 
 	err = bus_dmamem_alloc(sc->sc_dmat, sc->tbqlen, 0,



CVS commit: src/sys/dev/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 16:25:29 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Use roundup - same code before and after.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 16:06:46 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Sprinkle const and remove unnecessary casts.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.34 src/sys/dev/cadence/if_cemac.c:1.35
--- src/sys/dev/cadence/if_cemac.c:1.34	Sun Aug 25 15:49:36 2024
+++ src/sys/dev/cadence/if_cemac.c	Sun Aug 25 16:06:46 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.34 2024/08/25 15:49:36 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.35 2024/08/25 16:06:46 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.34 2024/08/25 15:49:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.35 2024/08/25 16:06:46 skrll Exp $");
 
 #include 
 #include 
@@ -209,7 +209,7 @@ cemac_gctx(struct cemac_softc *sc)
 int
 cemac_intr(void *arg)
 {
-	struct cemac_softc *sc = (struct cemac_softc *)arg;
+	struct cemac_softc * const sc = arg;
 	struct ifnet * ifp = &sc->sc_ethercom.ec_if;
 	uint32_t imr, isr, ctl;
 #ifdef	CEMAC_DEBUG
@@ -570,7 +570,7 @@ cemac_mediachange(struct ifnet *ifp)
 static void
 cemac_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
 {
-	struct cemac_softc *sc = ifp->if_softc;
+	struct cemac_softc * const sc = ifp->if_softc;
 
 	mii_pollstat(&sc->sc_mii);
 	ifmr->ifm_active = sc->sc_mii.mii_media_active;
@@ -581,9 +581,7 @@ cemac_mediastatus(struct ifnet *ifp, str
 static int
 cemac_mii_readreg(device_t self, int phy, int reg, uint16_t *val)
 {
-	struct cemac_softc *sc;
-
-	sc = device_private(self);
+	struct cemac_softc * const sc = device_private(self);
 
 	CEMAC_WRITE(ETH_MAN, (ETH_MAN_HIGH | ETH_MAN_RW_RD
 			 | ((phy << ETH_MAN_PHYA_SHIFT) & ETH_MAN_PHYA)
@@ -599,9 +597,7 @@ cemac_mii_readreg(device_t self, int phy
 static int
 cemac_mii_writereg(device_t self, int phy, int reg, uint16_t val)
 {
-	struct cemac_softc *sc;
-
-	sc = device_private(self);
+	struct cemac_softc * const sc = device_private(self);
 
 	CEMAC_WRITE(ETH_MAN, (ETH_MAN_HIGH | ETH_MAN_RW_WR
 			 | ((phy << ETH_MAN_PHYA_SHIFT) & ETH_MAN_PHYA)
@@ -618,7 +614,7 @@ cemac_mii_writereg(device_t self, int ph
 static void
 cemac_statchg(struct ifnet *ifp)
 {
-	struct cemac_softc *sc = ifp->if_softc;
+	struct cemac_softc * const sc = ifp->if_softc;
 	struct mii_data *mii = &sc->sc_mii;
 	uint32_t reg;
 
@@ -652,7 +648,7 @@ cemac_statchg(struct ifnet *ifp)
 static void
 cemac_tick(void *arg)
 {
-	struct cemac_softc *sc = (struct cemac_softc *)arg;
+	struct cemac_softc * const sc = arg;
 	struct ifnet * ifp = &sc->sc_ethercom.ec_if;
 	int s;
 
@@ -708,7 +704,7 @@ cemac_ifioctl(struct ifnet *ifp, u_long 
 static void
 cemac_ifstart(struct ifnet *ifp)
 {
-	struct cemac_softc *sc = (struct cemac_softc *)ifp->if_softc;
+	struct cemac_softc * const sc = ifp->if_softc;
 	struct mbuf *m;
 	bus_dma_segment_t *segs;
 	int s, bi, err, nsegs;
@@ -814,7 +810,7 @@ stop:
 static void
 cemac_ifwatchdog(struct ifnet *ifp)
 {
-	struct cemac_softc *sc = (struct cemac_softc *)ifp->if_softc;
+	struct cemac_softc * const sc = ifp->if_softc;
 
 	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
@@ -825,7 +821,7 @@ cemac_ifwatchdog(struct ifnet *ifp)
 static int
 cemac_ifinit(struct ifnet *ifp)
 {
-	struct cemac_softc *sc = ifp->if_softc;
+	struct cemac_softc * const sc = ifp->if_softc;
 	uint32_t dma, cfg;
 	int s = splnet();
 
@@ -871,7 +867,7 @@ static void
 cemac_ifstop(struct ifnet *ifp, int disable)
 {
 //	uint32_t u;
-	struct cemac_softc *sc = ifp->if_softc;
+	struct cemac_softc * const sc = ifp->if_softc;
 
 #if 0
 	CEMAC_WRITE(ETH_CTL, ETH_CTL_MPE);	// disable everything
@@ -906,7 +902,7 @@ cemac_ifstop(struct ifnet *ifp, int disa
 static void
 cemac_setaddr(struct ifnet *ifp)
 {
-	struct cemac_softc *sc = ifp->if_softc;
+	struct cemac_softc * const sc = ifp->if_softc;
 	struct ethercom *ec = &sc->sc_ethercom;
 	struct ether_multi *enm;
 	struct ether_multistep step;



CVS commit: src/sys/dev/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 16:06:46 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Sprinkle const and remove unnecessary casts.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 15:49:36 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.33 src/sys/dev/cadence/if_cemac.c:1.34
--- src/sys/dev/cadence/if_cemac.c:1.33	Sun Aug 25 07:25:00 2024
+++ src/sys/dev/cadence/if_cemac.c	Sun Aug 25 15:49:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.33 2024/08/25 07:25:00 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.34 2024/08/25 15:49:36 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.33 2024/08/25 07:25:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.34 2024/08/25 15:49:36 skrll Exp $");
 
 #include 
 #include 
@@ -262,7 +262,8 @@ cemac_intr(void *arg)
 			DPRINTFN(2,("## nfo=0x%08X\n", nfo));
 
 			MGETHDR(m, M_DONTWAIT, MT_DATA);
-			if (m != NULL) MCLGET(m, M_DONTWAIT);
+			if (m != NULL)
+ MCLGET(m, M_DONTWAIT);
 			if (m != NULL && (m->m_flags & M_EXT)) {
 bus_dmamap_sync(sc->sc_dmat, sc->rxq[bi].m_dmamap, 0,
 		MCLBYTES, BUS_DMASYNC_POSTREAD);
@@ -743,7 +744,8 @@ start:
 			bus_dmamap_unload(sc->sc_dmat, sc->txq[bi].m_dmamap);
 
 		MGETHDR(mn, M_DONTWAIT, MT_DATA);
-		if (mn == NULL) goto stop;
+		if (mn == NULL)
+			 goto stop;
 		if (m->m_pkthdr.len > MHLEN) {
 			MCLGET(mn, M_DONTWAIT);
 			if ((mn->m_flags & M_EXT) == 0) {



CVS commit: src/sys/dev/cadence

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 15:49:36 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 11:55:45 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Header inclusion maintenance and KNF


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.31 src/sys/dev/cadence/if_cemac.c:1.32
--- src/sys/dev/cadence/if_cemac.c:1.31	Sat Aug 24 10:11:40 2024
+++ src/sys/dev/cadence/if_cemac.c	Sat Aug 24 11:55:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.31 2024/08/24 10:11:40 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.32 2024/08/24 11:55:45 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,23 +40,17 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.31 2024/08/24 10:11:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.32 2024/08/24 11:55:45 skrll Exp $");
 
-#include 
 #include 
-#include 
-#include 
+#include 
+
+#include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include 
-
-#include 
-#include 
-
-#include 
 
 #include 
 #include 



CVS commit: src/sys/dev/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 11:55:45 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Header inclusion maintenance and KNF


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 10:13:19 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemacvar.h

Log Message:
G/C


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/cadence/if_cemacvar.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/cadence/if_cemacvar.h
diff -u src/sys/dev/cadence/if_cemacvar.h:1.2 src/sys/dev/cadence/if_cemacvar.h:1.3
--- src/sys/dev/cadence/if_cemacvar.h:1.2	Sat Aug 24 10:02:55 2024
+++ src/sys/dev/cadence/if_cemacvar.h	Sat Aug 24 10:13:19 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_cemacvar.h,v 1.2 2024/08/24 10:02:55 skrll Exp $	*/
+/*  $NetBSD: if_cemacvar.h,v 1.3 2024/08/24 10:13:19 skrll Exp $	*/
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -32,7 +32,6 @@ int cemac_match(device_t, cfdata_t, void
 void cemac_attach(device_t, device_t, void *);
 int cemac_intr(void *);
 
-int cemac_match_common(device_t, cfdata_t, void *);
 void cemac_attach_common(device_t, bus_space_tag_t, bus_space_handle_t,
 bus_dma_tag_t, int);
 



CVS commit: src/sys/dev/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 10:13:19 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemacvar.h

Log Message:
G/C


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/cadence/if_cemacvar.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/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 10:11:40 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.30 src/sys/dev/cadence/if_cemac.c:1.31
--- src/sys/dev/cadence/if_cemac.c:1.30	Sat Aug 24 10:09:02 2024
+++ src/sys/dev/cadence/if_cemac.c	Sat Aug 24 10:11:40 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.30 2024/08/24 10:09:02 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.31 2024/08/24 10:11:40 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.30 2024/08/24 10:09:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.31 2024/08/24 10:11:40 skrll Exp $");
 
 #include 
 #include 
@@ -708,7 +708,7 @@ cemac_statchg(struct ifnet *ifp)
 static void
 cemac_tick(void *arg)
 {
-	struct cemac_softc* sc = (struct cemac_softc *)arg;
+	struct cemac_softc *sc = (struct cemac_softc *)arg;
 	struct ifnet * ifp = &sc->sc_ethercom.ec_if;
 	int s;
 
@@ -830,7 +830,7 @@ start:
 	sc->txqc++;
 
 	DPRINTFN(2,("%s: start sending idx #%i mbuf %p (txqc=%i, phys %p), len=%u\n",
-		__FUNCTION__, bi, sc->txq[bi].m, sc->txqc, (void*)segs->ds_addr,
+		__FUNCTION__, bi, sc->txq[bi].m, sc->txqc, (void *)segs->ds_addr,
 		(unsigned)m->m_pkthdr.len));
 #ifdef	DIAGNOSTIC
 	if (sc->txqc > TX_QLEN)



CVS commit: src/sys/dev/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 10:11:40 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 10:09:03 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
G/C


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.29 src/sys/dev/cadence/if_cemac.c:1.30
--- src/sys/dev/cadence/if_cemac.c:1.29	Sat Aug 24 07:24:34 2024
+++ src/sys/dev/cadence/if_cemac.c	Sat Aug 24 10:09:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.29 2024/08/24 07:24:34 skrll Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.30 2024/08/24 10:09:02 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.29 2024/08/24 07:24:34 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.30 2024/08/24 10:09:02 skrll Exp $");
 
 #include 
 #include 
@@ -156,13 +156,6 @@ int cemac_debug = CEMAC_DEBUG;
 CFATTACH_DECL_NEW(cemac, sizeof(struct cemac_softc),
 cemac_match, cemac_attach, NULL, NULL);
 
-int
-cemac_match_common(device_t parent, cfdata_t match, void *aux)
-{
-	if (strcmp(match->cf_name, "cemac") == 0)
-		return 1;
-	return 0;
-}
 
 void
 cemac_attach_common(device_t self, bus_space_tag_t iot,



CVS commit: src/sys/dev/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 10:09:03 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
G/C


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/cadence/if_cemac.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/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 10:02:55 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemacvar.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/cadence/if_cemacvar.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/cadence/if_cemacvar.h
diff -u src/sys/dev/cadence/if_cemacvar.h:1.1 src/sys/dev/cadence/if_cemacvar.h:1.2
--- src/sys/dev/cadence/if_cemacvar.h:1.1	Fri Jan 23 12:34:09 2015
+++ src/sys/dev/cadence/if_cemacvar.h	Sat Aug 24 10:02:55 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_cemacvar.h,v 1.1 2015/01/23 12:34:09 hkenken Exp $	*/
+/*  $NetBSD: if_cemacvar.h,v 1.2 2024/08/24 10:02:55 skrll Exp $	*/
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -30,7 +30,7 @@
 
 int cemac_match(device_t, cfdata_t, void *);
 void cemac_attach(device_t, device_t, void *);
-int cemac_intr(void*);
+int cemac_intr(void *);
 
 int cemac_match_common(device_t, cfdata_t, void *);
 void cemac_attach_common(device_t, bus_space_tag_t, bus_space_handle_t,



CVS commit: src/sys/dev/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 10:02:55 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemacvar.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/cadence/if_cemacvar.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/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 07:24:35 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.28 src/sys/dev/cadence/if_cemac.c:1.29
--- src/sys/dev/cadence/if_cemac.c:1.28	Fri Jul  5 04:31:50 2024
+++ src/sys/dev/cadence/if_cemac.c	Sat Aug 24 07:24:34 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.28 2024/07/05 04:31:50 rin Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.29 2024/08/24 07:24:34 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.28 2024/07/05 04:31:50 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.29 2024/08/24 07:24:34 skrll Exp $");
 
 #include 
 #include 
@@ -389,7 +389,7 @@ cemac_intr(void *arg)
 		goto begin;
 #endif
 
-	return (1);
+	return 1;
 }
 
 
@@ -627,7 +627,7 @@ cemac_mediachange(struct ifnet *ifp)
 {
 	if (ifp->if_flags & IFF_UP)
 		cemac_ifinit(ifp);
-	return (0);
+	return 0;
 }
 
 static void



CVS commit: src/sys/dev/cadence

2024-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 24 07:24:35 UTC 2024

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/cadence/if_cemac.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/cadence

2022-11-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 12 16:54:36 UTC 2022

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Skip the first PHY found to remove the shadow PHY that appears at
the broadcast address 0.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.25 src/sys/dev/cadence/if_cemac.c:1.26
--- src/sys/dev/cadence/if_cemac.c:1.25	Sun Sep 18 16:54:30 2022
+++ src/sys/dev/cadence/if_cemac.c	Sat Nov 12 16:54:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.25 2022/09/18 16:54:30 thorpej Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.26 2022/11/12 16:54:36 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.25 2022/09/18 16:54:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.26 2022/11/12 16:54:36 jmcneill Exp $");
 
 #include 
 #include 
@@ -579,8 +579,7 @@ cemac_init(struct cemac_softc *sc)
 	mii->mii_statchg = cemac_statchg;
 	ifmedia_init(&mii->mii_media, IFM_IMASK, cemac_mediachange,
 	cemac_mediastatus);
-	mii_attach(sc->sc_dev, mii, 0x, MII_PHY_ANY,
-	MII_OFFSET_ANY, 0);
+	mii_attach(sc->sc_dev, mii, 0x, MII_PHY_ANY, 1, 0);
 	ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
 
 #if 0



CVS commit: src/sys/dev/cadence

2022-11-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 12 16:54:36 UTC 2022

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Skip the first PHY found to remove the shadow PHY that appears at
the broadcast address 0.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/cadence/if_cemac.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/cadence

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 16:54:30 UTC 2022

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c
diff -u src/sys/dev/cadence/if_cemac.c:1.24 src/sys/dev/cadence/if_cemac.c:1.25
--- src/sys/dev/cadence/if_cemac.c:1.24	Fri Dec 31 14:25:22 2021
+++ src/sys/dev/cadence/if_cemac.c	Sun Sep 18 16:54:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cemac.c,v 1.24 2021/12/31 14:25:22 riastradh Exp $	*/
+/*	$NetBSD: if_cemac.c,v 1.25 2022/09/18 16:54:30 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.24 2021/12/31 14:25:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cemac.c,v 1.25 2022/09/18 16:54:30 thorpej Exp $");
 
 #include 
 #include 
@@ -126,6 +126,7 @@ struct cemac_softc {
 	int			txqi, txqc;
 	struct cemac_qmeta	txq[TX_QLEN];
 	callout_t		cemac_tick_ch;
+	bool			tx_busy;
 
 	int			cemac_flags;
 };
@@ -225,7 +226,6 @@ cemac_attach_common(device_t self, bus_s
 static int
 cemac_gctx(struct cemac_softc *sc)
 {
-	struct ifnet * ifp = &sc->sc_ethercom.ec_if;
 	uint32_t tsr;
 
 	tsr = CEMAC_READ(ETH_TSR);
@@ -261,8 +261,8 @@ cemac_gctx(struct cemac_softc *sc)
 	}
 
 	// mark we're free
-	if (ifp->if_flags & IFF_OACTIVE) {
-		ifp->if_flags &= ~IFF_OACTIVE;
+	if (sc->tx_busy) {
+		sc->tx_busy = false;
 		/* Disable transmit-buffer-free interrupt */
 		/*CEMAC_WRITE(ETH_IDR, ETH_ISR_TBRE);*/
 	}
@@ -783,7 +783,7 @@ start:
 	if (cemac_gctx(sc) == 0) {
 		/* Enable transmit-buffer-free interrupt */
 		CEMAC_WRITE(ETH_IER, ETH_ISR_TBRE);
-		ifp->if_flags |= IFF_OACTIVE;
+		sc->tx_busy = true;
 		ifp->if_timer = 10;
 		splx(s);
 		return;
@@ -961,8 +961,9 @@ cemac_ifstop(struct ifnet *ifp, int disa
 	/* Down the MII. */
 	mii_down(&sc->sc_mii);
 
-	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+	ifp->if_flags &= ~IFF_RUNNING;
 	ifp->if_timer = 0;
+	sc->tx_busy = false;
 	sc->sc_mii.mii_media_status &= ~IFM_ACTIVE;
 }
 



CVS commit: src/sys/dev/cadence

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 16:54:30 UTC 2022

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/cadence/if_cemac.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/cadence/if_cemac.c

2019-05-19 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 19 13:32:00 UTC 2019

Modified Files:
src/sys/dev/cadence: if_cemac.c

Log Message:
Kill unused sc variable and fix the build.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/cadence/if_cemac.c

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