Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64/dev sun4v: vnet - reception of ethernet fra...
details: https://anonhg.NetBSD.org/src/rev/01b7d5c6c2ff
branches: trunk
changeset: 960218:01b7d5c6c2ff
user: palle <palle%NetBSD.org@localhost>
date: Thu Mar 11 19:34:11 2021 +0000
description:
sun4v: vnet - reception of ethernet frames seems to work now (WIP and code is still full of debug code)
diffstat:
sys/arch/sparc64/dev/vnet.c | 385 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 343 insertions(+), 42 deletions(-)
diffs (truncated from 1007 to 300 lines):
diff -r 93062b4a9499 -r 01b7d5c6c2ff sys/arch/sparc64/dev/vnet.c
--- a/sys/arch/sparc64/dev/vnet.c Thu Mar 11 18:49:18 2021 +0000
+++ b/sys/arch/sparc64/dev/vnet.c Thu Mar 11 19:34:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnet.c,v 1.2 2021/03/04 20:59:39 palle Exp $ */
+/* $NetBSD: vnet.c,v 1.3 2021/03/11 19:34:11 palle Exp $ */
/* $OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $ */
/*
* Copyright (c) 2009, 2015 Mark Kettenis
@@ -34,6 +34,8 @@
#if 0
FIXME openbsd
#include <sys/timeout.h>
+#else
+#include <sys/callout.h>
#endif
#include <machine/autoconf.h>
@@ -56,6 +58,9 @@
#include <sparc64/dev/ldcvar.h>
#include <sparc64/dev/viovar.h>
+#if 1
+#define VNET_DEBUG
+#endif
#ifdef VNET_DEBUG
#define DPRINTF(x) printf x
#else
@@ -169,6 +174,8 @@
#if 0
FIXME openbsd
struct timeout sc_handshake_to;
+#else
+ struct callout sc_handshake_co;
#endif
uint8_t sc_xfer_mode;
@@ -230,7 +237,7 @@
void vnet_start(struct ifnet *);
void vnet_start_desc(struct ifnet *);
-int vnet_ioctl (struct ifnet *, u_long, void *);
+int vnet_ioctl(struct ifnet *, u_long, void *);
void vnet_watchdog(struct ifnet *);
int vnet_media_change(struct ifnet *);
@@ -240,13 +247,14 @@
void vnet_setmulti(struct vnet_softc *, int);
-void vnet_init(struct ifnet *);
-void vnet_stop(struct ifnet *);
+int vnet_init(struct ifnet *);
+void vnet_stop(struct ifnet *, int);
int vnet_match(device_t parent, cfdata_t match, void *aux)
{
struct cbus_attach_args *ca = aux;
+
if (strcmp(ca->ca_name, "network") == 0)
return (1);
@@ -308,6 +316,9 @@
#if 0
FIXME openbsd
timeout_set(&sc->sc_handshake_to, vnet_handshake, sc);
+#else
+ callout_init(&sc->sc_handshake_co, 0);
+/* netbsd callout do silmilar function...*/
#endif
sc->sc_peer_state = VIO_DP_STOPPED;
@@ -358,9 +369,13 @@
ifp = &sc->sc_ethercom.ec_if;
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+#if 0
ifp->if_link_state = LINK_STATE_DOWN;
+#endif
+ ifp->if_init = vnet_init;
ifp->if_ioctl = vnet_ioctl;
ifp->if_start = vnet_start;
+ ifp->if_stop = vnet_stop;
ifp->if_watchdog = vnet_watchdog;
strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
#if 0
@@ -374,6 +389,7 @@
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);
+#if 0
int error = if_initialize(ifp);
if (error != 0) {
printf(", if_initialize() failed\n");
@@ -381,7 +397,10 @@
}
ether_ifattach(ifp, sc->sc_macaddr);
if_register(ifp);
-
+#else
+ if_attach(ifp);
+ ether_ifattach(ifp, sc->sc_macaddr);
+#endif
printf("\n");
return;
free_txqueue:
@@ -424,7 +443,9 @@
int
vnet_rx_intr(void *arg)
{
+#if 0
DPRINTF(("%s: entry\n", __func__));
+#endif
struct vnet_softc *sc = arg;
struct ldc_conn *lc = &sc->sc_lc;
@@ -433,34 +454,47 @@
int err;
err = hv_ldc_rx_get_state(lc->lc_id, &rx_head, &rx_tail, &rx_state);
- if (err == H_EINVAL)
+ if (err == H_EINVAL) {
+ printf("hv_ldc_rx_get_state failed\n");
return (0);
+ }
if (err != H_EOK) {
printf("hv_ldc_rx_get_state %d\n", err);
return (0);
}
+#if 0
+ DPRINTF(("%s: rx_state %" PRId64 " head %" PRId64 " tail %" PRId64 "\n",
+ __func__, rx_state, rx_head, rx_tail));
+#endif
if (rx_state != lc->lc_rx_state) {
+#if 0
+ DPRINTF(("%s: rx_state %" PRId64 " != lc__rx_state %" PRId64 "\n",
+ __func__, rx_state, lc->lc_rx_state));
+#endif
switch (rx_state) {
case LDC_CHANNEL_DOWN:
- DPRINTF(("%s: Rx link down\n", __func__));
lc->lc_tx_seqid = 0;
lc->lc_state = 0;
lc->lc_reset(lc);
if (rx_head == rx_tail)
break;
/* Discard and ack pending I/O. */
- DPRINTF(("setting rx qhead to %lld\n", rx_tail));
+ DPRINTF(("setting rx qhead to %" PRId64 "\n", rx_tail));
err = hv_ldc_rx_set_qhead(lc->lc_id, rx_tail);
if (err == H_EOK)
break;
printf("%s: hv_ldc_rx_set_qhead %d\n", __func__, err);
break;
case LDC_CHANNEL_UP:
+#if 0
DPRINTF(("%s: Rx link up\n", __func__));
+#endif
#if 0
FIXME openbsd
timeout_add_msec(&sc->sc_handshake_to, 500);
+#else
+ callout_reset(&sc->sc_handshake_co, hz / 2, vnet_handshake, sc);
#endif
break;
case LDC_CHANNEL_RESET:
@@ -471,37 +505,73 @@
#if 0
FIXME openbsd
timeout_add_msec(&sc->sc_handshake_to, 500);
+#else
+ callout_reset(&sc->sc_handshake_co, hz / 2, vnet_handshake, sc);
#endif
- if (rx_head == rx_tail)
+ if (rx_head == rx_tail) {
+#if 0
+ DPRINTF(("%s: rx_head == rx_head\n", __func__));
+#endif
break;
+ }
/* Discard and ack pending I/O. */
- DPRINTF(("setting rx qhead to %lld\n", rx_tail));
+ DPRINTF(("setting rx qhead to %" PRId64 "\n", rx_tail));
err = hv_ldc_rx_set_qhead(lc->lc_id, rx_tail);
if (err == H_EOK)
break;
printf("%s: hv_ldc_rx_set_qhead %d\n", __func__, err);
break;
+ default:
+ DPRINTF(("%s: unhandled rx_state %" PRIx64 "\n", __func__, rx_state));
+ break;
}
lc->lc_rx_state = rx_state;
+#if 0
+ DPRINTF(("%s: setting rx_state %" PRId64 " = lc__rx_state %" PRId64 "\n",
+ __func__, rx_state, lc->lc_rx_state));
+#endif
return (1);
+ } else {
+#if 0
+ DPRINTF(("%s: rx_state %" PRId64 " == lc__rx_state %" PRId64 "\n",
+ __func__, rx_state, lc->lc_rx_state));
+#endif
}
if (rx_head == rx_tail)
+ {
+ DPRINTF(("%s: head eq tail\n", __func__));
return (0);
-
+ }
lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_rxq->lq_va + rx_head);
+#if 0
+ DPRINTF(("%s: lp->type %" PRId8 "\n", __func__, lp->type));
+ DPRINTF(("%s: lp->stype %" PRId8 "\n", __func__, lp->stype));
+ DPRINTF(("%s: lp->ctrl %" PRId8 "\n", __func__, lp->ctrl));
+ DPRINTF(("%s: lp->env %" PRId8 "\n", __func__, lp->env));
+ DPRINTF(("%s: lp->seqid %" PRId32 "\n", __func__, lp->seqid));
+ DPRINTF(("%s: lp->major %" PRId16 "\n", __func__, lp->major));
+ DPRINTF(("%s: lp->minor %" PRId16 "\n", __func__, lp->minor));
+#endif
switch (lp->type) {
case LDC_CTRL:
+#if 0
+ DPRINTF(("%s: LDC_CTRL\n", __func__));
+#endif
ldc_rx_ctrl(lc, lp);
break;
case LDC_DATA:
+#if 0
+ DPRINTF(("%s: LDC_DATA\n", __func__));
+#endif
ldc_rx_data(lc, lp);
break;
default:
- DPRINTF(("%0x02/%0x02/%0x02\n", lp->type, lp->stype,
- lp->ctrl));
+ DPRINTF(("%s: unhandled type %0x02/%0x02/%0x02\n",
+ __func__, lp->type, lp->stype, lp->ctrl));
+ Debugger();
ldc_reset(lc);
break;
}
@@ -514,14 +584,17 @@
err = hv_ldc_rx_set_qhead(lc->lc_id, rx_head);
if (err != H_EOK)
printf("%s: hv_ldc_rx_set_qhead %d\n", __func__, err);
-
+#if 0
DPRINTF(("%s: exit\n", __func__));
+#endif
return (1);
}
void
vnet_handshake(void *arg)
{
+ DPRINTF(("%s: entry\n", __func__));
+
struct vnet_softc *sc = arg;
ldc_send_vers(&sc->sc_lc);
@@ -530,19 +603,27 @@
void
vio_rx_data(struct ldc_conn *lc, struct ldc_pkt *lp)
{
+#if 0
+ DPRINTF(("%s: entry\n", __func__));
+#endif
+
struct vio_msg *vm = (struct vio_msg *)lp;
switch (vm->type) {
case VIO_TYPE_CTRL:
if ((lp->env & LDC_FRAG_START) == 0 &&
- (lp->env & LDC_FRAG_STOP) == 0)
+ (lp->env & LDC_FRAG_STOP) == 0) {
+ DPRINTF(("%s: FRAG_START==0 and FRAG_STOP==0\n", __func__));
return;
+ }
vnet_rx_vio_ctrl(lc->lc_sc, vm);
break;
case VIO_TYPE_DATA:
- if((lp->env & LDC_FRAG_START) == 0)
+ if((lp->env & LDC_FRAG_START) == 0) {
+ DPRINTF(("%s: FRAG_START==0\n", __func__));
return;
+ }
vnet_rx_vio_data(lc->lc_sc, vm);
break;
@@ -556,6 +637,9 @@
void
vnet_rx_vio_ctrl(struct vnet_softc *sc, struct vio_msg *vm)
{
Home |
Main Index |
Thread Index |
Old Index