Commit 964eaf7a authored by Robert Sprowson's avatar Robert Sprowson Committed by ROOL

Minor updates

if_cpsw.c: Updated to NetBSD's revision 1.21
if_cpsw_reg: Updated to NetBSD's revision 1.5
glue.h: Minor fallout from newer if_cpsw.
glue.c: should cpsw_attach() fail for any reason, if_attach() never gets called, so nicifp is undefined, leading to an abort on the 1s callevery. Check nicifp is non-NULL first.

Version 0.04. Tagged as 'EtherCPSW-0_04'
parent f3a888ad
/* (0.03)
/* (0.04)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.03
#define Module_MajorVersion_CMHG 0.04
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 Nov 2016
#define Module_Date_CMHG 02 Apr 2020
#define Module_MajorVersion "0.03"
#define Module_Version 3
#define Module_MajorVersion "0.04"
#define Module_Version 4
#define Module_MinorVersion ""
#define Module_Date "18 Nov 2016"
#define Module_Date "02 Apr 2020"
#define Module_ApplicationDate "18-Nov-16"
#define Module_ApplicationDate "02-Apr-20"
#define Module_ComponentName "EtherCPSW"
#define Module_ComponentPath "bsd/RiscOS/Sources/Networking/Ethernet/EtherCPSW"
#define Module_FullVersion "0.03"
#define Module_HelpVersion "0.03 (18 Nov 2016)"
#define Module_LibraryVersionInfo "0:3"
#define Module_FullVersion "0.04"
#define Module_HelpVersion "0.04 (02 Apr 2020)"
#define Module_LibraryVersionInfo "0:4"
......@@ -609,7 +609,7 @@ void callout_callevery(void)
{
tickfn(tickarg);
}
if (nicifp->if_timer)
if (nicifp && nicifp->if_timer)
{
nicifp->if_timer--;
if (nicifp->if_timer == 0) nicifp->if_watchdog(nicifp);
......
/* $NetBSD: if_cpsw.c,v 1.11 2015/03/26 22:00:45 skrll Exp $ */
/* $NetBSD: if_cpsw.c,v 1.21 2018/06/26 06:47:57 msaitoh Exp $ */
/*
* Copyright (c) 2013 Jonathan A. Kollasch
......@@ -80,7 +80,7 @@
#include "if_cpswreg.h"
#else
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.11 2015/03/26 22:00:45 skrll Exp $");
__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.21 2018/06/26 06:47:57 msaitoh Exp $");
#include <sys/param.h>
#include <sys/bus.h>
......@@ -221,8 +221,8 @@ KERNHIST_DEFINE(cpswhist);
#ifdef KERNHIST
#define KERNHIST_CALLED_5(NAME, i, j, k, l) \
do { \
_kernhist_call = atomic_inc_uint_nv(&_kernhist_cnt); \
KERNHIST_LOG(NAME, "called! %x %x %x %x", i, j, k, l); \
_kernhist_call = atomic_inc_32_nv(&_kernhist_cnt); \
KERNHIST_LOG(NAME, "called! %jx %jx %jx %jx", i, j, k, l); \
} while (/*CONSTCOND*/ 0)
#else
#define KERNHIST_CALLED_5(NAME, i, j, k, l)
......@@ -259,7 +259,7 @@ cpsw_set_txdesc_next(struct cpsw_softc * const sc, const u_int i, uint32_t n)
const bus_size_t o = sizeof(struct cpsw_cpdma_bd) * i + 0;
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, i, n, 0);
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, i, n, 0);
bus_space_write_4(sc->sc_bst, sc->sc_bsh_txdescs, o, n);
}
......@@ -270,7 +270,7 @@ cpsw_set_rxdesc_next(struct cpsw_softc * const sc, const u_int i, uint32_t n)
const bus_size_t o = sizeof(struct cpsw_cpdma_bd) * i + 0;
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, i, n, 0);
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, i, n, 0);
bus_space_write_4(sc->sc_bst, sc->sc_bsh_rxdescs, o, n);
}
......@@ -284,10 +284,10 @@ cpsw_get_txdesc(struct cpsw_softc * const sc, const u_int i,
const bus_size_t c = __arraycount(bdp->word);
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, i, (uintptr_t)bdp, 0);
bus_space_read_region_4(sc->sc_bst, sc->sc_bsh_txdescs, o, dp, c);
KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
KERNHIST_LOG(cpswhist, "%08jx %08jx %08jx %08jx\n",
dp[0], dp[1], dp[2], dp[3]);
}
......@@ -300,8 +300,8 @@ cpsw_set_txdesc(struct cpsw_softc * const sc, const u_int i,
const bus_size_t c = __arraycount(bdp->word);
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, i, (uintptr_t)bdp, 0);
KERNHIST_LOG(cpswhist, "%08jx %08jx %08jx %08jx\n",
dp[0], dp[1], dp[2], dp[3]);
bus_space_write_region_4(sc->sc_bst, sc->sc_bsh_txdescs, o, dp, c);
......@@ -316,11 +316,11 @@ cpsw_get_rxdesc(struct cpsw_softc * const sc, const u_int i,
const bus_size_t c = __arraycount(bdp->word);
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, i, (uintptr_t)bdp, 0);
bus_space_read_region_4(sc->sc_bst, sc->sc_bsh_rxdescs, o, dp, c);
KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
KERNHIST_LOG(cpswhist, "%08jx %08jx %08jx %08jx\n",
dp[0], dp[1], dp[2], dp[3]);
}
......@@ -333,8 +333,8 @@ cpsw_set_rxdesc(struct cpsw_softc * const sc, const u_int i,
const bus_size_t c = __arraycount(bdp->word);
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, i, (uintptr_t)bdp, 0);
KERNHIST_LOG(cpswhist, "%08jx %08jx %08jx %08jx\n",
dp[0], dp[1], dp[2], dp[3]);
bus_space_write_region_4(sc->sc_bst, sc->sc_bsh_rxdescs, o, dp, c);
......@@ -444,7 +444,7 @@ cpsw_attach(device_t parent, device_t self, void *aux)
sc->sc_dev = self;
aprint_normal(": TI CPSW Ethernet\n");
aprint_normal(": TI Layer 2 3-Port Switch\n");
aprint_naive("\n");
callout_init(&sc->sc_tick_ch, 0);
......@@ -531,7 +531,6 @@ cpsw_attach(device_t parent, device_t self, void *aux)
(void *)sc->sc_bsh_rxdescs);
sc->sc_rdp = kmem_alloc(sizeof(*sc->sc_rdp), KM_SLEEP);
KASSERT(sc->sc_rdp != NULL);
for (i = 0; i < CPSW_NTXDESCS; i++) {
if ((error = bus_dmamap_create(sc->sc_bdt, MCLBYTES,
......@@ -553,7 +552,6 @@ cpsw_attach(device_t parent, device_t self, void *aux)
}
sc->sc_txpad = kmem_zalloc(ETHER_MIN_LEN, KM_SLEEP);
KASSERT(sc->sc_txpad != NULL);
bus_dmamap_create(sc->sc_bdt, ETHER_MIN_LEN, 1, ETHER_MIN_LEN, 0,
BUS_DMA_WAITOK, &sc->sc_txpad_dm);
bus_dmamap_load(sc->sc_bdt, sc->sc_txpad_dm, sc->sc_txpad,
......@@ -565,9 +563,6 @@ cpsw_attach(device_t parent, device_t self, void *aux)
ether_sprintf(sc->sc_enaddr));
strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
#ifdef RISCOS
ifp->if_input = glue_receive;
#endif
ifp->if_softc = sc;
ifp->if_capabilities = 0;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
......@@ -620,6 +615,7 @@ cpsw_attach(device_t parent, device_t self, void *aux)
}
if_attach(ifp);
if_deferred_start_init(ifp, NULL);
ether_ifattach(ifp, sc->sc_enaddr);
/* The attach is successful. */
......@@ -646,7 +642,7 @@ cpsw_start(struct ifnet *ifp)
u_int mlen;
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, 0, 0, 0);
if (__predict_false((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) !=
IFF_RUNNING)) {
......@@ -658,7 +654,7 @@ cpsw_start(struct ifnet *ifp)
else
txfree = sc->sc_txhead - sc->sc_txnext - 1;
KERNHIST_LOG(cpswhist, "start txf %x txh %x txn %x txr %x\n",
KERNHIST_LOG(cpswhist, "start txf %jx txh %jx txn %jx txr %jx\n",
txfree, sc->sc_txhead, sc->sc_txnext, sc->sc_txrun);
while (txfree > 0) {
......@@ -748,7 +744,7 @@ cpsw_start(struct ifnet *ifp)
sc->sc_txnext = TXDESC_NEXT(sc->sc_txnext);
}
bpf_mtap(ifp, m);
bpf_mtap(ifp, m, BPF_D_OUT);
}
if (txstart >= 0) {
......@@ -756,7 +752,7 @@ cpsw_start(struct ifnet *ifp)
/* terminate the new chain */
KASSERT(eopi == TXDESC_PREV(sc->sc_txnext));
cpsw_set_txdesc_next(sc, TXDESC_PREV(sc->sc_txnext), 0);
KERNHIST_LOG(cpswhist, "CP %x HDP %x s %x e %x\n",
KERNHIST_LOG(cpswhist, "CP %jx HDP %jx s %jx e %jx\n",
cpsw_read_4(sc, CPSW_CPDMA_TX_CP(0)),
cpsw_read_4(sc, CPSW_CPDMA_TX_HDP(0)), txstart, eopi);
/* link the new chain on */
......@@ -769,7 +765,7 @@ cpsw_start(struct ifnet *ifp)
cpsw_txdesc_paddr(sc, txstart));
}
}
KERNHIST_LOG(cpswhist, "end txf %x txh %x txn %x txr %x\n",
KERNHIST_LOG(cpswhist, "end txf %jx txh %jx txn %jx txr %jx\n",
txfree, sc->sc_txhead, sc->sc_txnext, sc->sc_txrun);
}
......@@ -860,7 +856,7 @@ cpsw_mii_wait(struct cpsw_softc * const sc, int reg)
{
u_int tries;
for(tries = 0; tries < 1000; tries++) {
for (tries = 0; tries < 1000; tries++) {
if ((cpsw_read_4(sc, reg) & __BIT(31)) == 0)
return 0;
delay(1);
......@@ -1085,6 +1081,9 @@ cpsw_init(struct ifnet *ifp)
}
sc->sc_rxhead = 0;
/* turn off flow control */
cpsw_write_4(sc, CPSW_SS_FLOW_CONTROL, 0);
/* align layer 3 header to 32-bit */
cpsw_write_4(sc, CPSW_CPDMA_RX_BUFFER_OFFSET, ETHER_ALIGN);
......@@ -1260,13 +1259,13 @@ cpsw_rxintr(void *arg)
u_int len, off;
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, 0, 0, 0);
for (;;) {
KASSERT(sc->sc_rxhead < CPSW_NRXDESCS);
i = sc->sc_rxhead;
KERNHIST_LOG(cpswhist, "rxhead %x CP %x\n", i,
KERNHIST_LOG(cpswhist, "rxhead %jx CP %jx\n", i,
cpsw_read_4(sc, CPSW_CPDMA_RX_CP(0)), 0, 0);
dm = rdp->rx_dm[i];
m = rdp->rx_mb[i];
......@@ -1312,11 +1311,11 @@ cpsw_rxintr(void *arg)
len -= ETHER_CRC_LEN;
#ifndef RISCOS
m->m_pkthdr.rcvif = ifp;
m_set_rcvif(m, ifp);
m->m_pkthdr.len = m->m_len = len;
m->m_data += off;
ifp->if_ipackets++;
if_percpuq_enqueue(ifp->if_percpuq, m);
#else
/* Get a single for the header so it's easier to ditch later */
top = ALLOC_S(ETHER_HDR_LEN, NULL);
......@@ -1337,11 +1336,10 @@ cpsw_rxintr(void *arg)
/* Copy data from the uncached memory into the mbufs */
IMPORT(top, len, (void *)(off + (uintptr_t)dm->dm_segs[0].ds_logical));
m = top;
#endif
bpf_mtap(ifp, m);
(*ifp->if_input)(ifp, m);
/* Hand off to filtering */
glue_receive(ifp, m);
#endif
next:
sc->sc_rxhead = RXDESC_NEXT(sc->sc_rxhead);
......@@ -1378,11 +1376,11 @@ cpsw_txintr(void *arg)
u_int cpi;
KERNHIST_FUNC(__func__);
KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
KERNHIST_CALLED_5(cpswhist, (uintptr_t)sc, 0, 0, 0);
KASSERT(sc->sc_txrun);
KERNHIST_LOG(cpswhist, "before txnext %x txhead %x txrun %x\n",
KERNHIST_LOG(cpswhist, "before txnext %jx txhead %jx txrun %jx\n",
sc->sc_txnext, sc->sc_txhead, sc->sc_txrun, 0);
tx0_cp = cpsw_read_4(sc, CPSW_CPDMA_TX_CP(0));
......@@ -1400,7 +1398,8 @@ cpsw_txintr(void *arg)
cpi = (tx0_cp - sc->sc_txdescs_pa) / sizeof(struct cpsw_cpdma_bd);
KASSERT(sc->sc_txhead < CPSW_NTXDESCS);
KERNHIST_LOG(cpswhist, "txnext %x txhead %x txrun %x cpi %x\n",
KERNHIST_LOG(cpswhist, "txnext %jx txhead %jx txrun %jx "
"cpi %jx\n",
sc->sc_txnext, sc->sc_txhead, sc->sc_txrun, cpi);
cpsw_get_txdesc(sc, sc->sc_txhead, &bd);
......@@ -1471,9 +1470,9 @@ next:
}
}
KERNHIST_LOG(cpswhist, "after txnext %x txhead %x txrun %x\n",
KERNHIST_LOG(cpswhist, "after txnext %jx txhead %jx txrun %jx\n",
sc->sc_txnext, sc->sc_txhead, sc->sc_txrun, 0);
KERNHIST_LOG(cpswhist, "CP %x HDP %x\n",
KERNHIST_LOG(cpswhist, "CP %jx HDP %jx\n",
cpsw_read_4(sc, CPSW_CPDMA_TX_CP(0)),
cpsw_read_4(sc, CPSW_CPDMA_TX_HDP(0)), 0, 0);
......@@ -1481,7 +1480,11 @@ next:
ifp->if_timer = 0;
if (handled)
#ifndef RISCOS
if_schedule_deferred_start(ifp);
#else
cpsw_start(ifp);
#endif
return handled;
}
......
......@@ -40,10 +40,12 @@ struct ifnet
{
void *if_softc;
char if_xname[4]; /* Unused by RISC OS */
uint32_t if_flags; /* Unused by RISC OS */
char if_xname[4]; /* Unused by RISC OS */
uint32_t if_flags; /* Unused by RISC OS */
uint32_t if_capabilities; /* Unused by RISC OS */
int (*if_init) /* Initialise */
(struct ifnet *);
int (*if_ioctl) /* I/O control */
(struct ifnet *, u_long, void *);
void (*if_watchdog) /* Watchdog */
......@@ -52,10 +54,6 @@ struct ifnet
(struct ifnet *);
void (*if_stop) /* Stop interface */
(struct ifnet *, int);
void (*if_input) /* Input routine (from h/w driver) */
(struct ifnet *, struct mbuf *);
int (*if_init) /* Initialise */
(struct ifnet *);
/* The bits kept per MAC/PHY pair */
struct
......@@ -135,6 +133,7 @@ struct ethercom
#define ifmedia_delete_instance(a,b) /* Nothing */
#define if_attach(a) glue_attachif(a)
#define if_detach(a) /* Nothing */
#define if_deferred_start_init(a,b) /* Nothing */
#define ether_ifattach(a,b) /* Nothing */
#define ether_ifdetach(a) /* Nothing */
#define ether_sprintf(k) "Unused"
......@@ -142,7 +141,7 @@ struct ethercom
#define __predict_false(k) k
#define __diagused /* Nothing */
#define __arraycount(a) (sizeof((a))/sizeof((a[0])))
#define bpf_mtap(a,b) /* No Berkeley packet filter */
#define bpf_mtap(a,b,c) /* No Berkeley packet filter */
typedef int cfdata_t; /* Unused type */
typedef int *prop_dictionary_t; /* Unused type */
#define device_properties(k) NULL
......
......@@ -37,6 +37,7 @@
#define CPSW_SS_SOFT_RESET (CPSW_SS_OFFSET + 0x08)
#define CPSW_SS_STAT_PORT_EN (CPSW_SS_OFFSET + 0x0C)
#define CPSW_SS_PTYPE (CPSW_SS_OFFSET + 0x10)
#define CPSW_SS_FLOW_CONTROL (CPSW_SS_OFFSET + 0x24)
#define CPSW_SS_RGMII_CTL (CPSW_SS_OFFSET + 0x88)
#define CPSW_PORT_OFFSET 0x0100
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment