summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64/dev
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2014-09-15 08:16:22 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2014-09-15 08:16:22 +0000
commit9e6fb0887b2d319c3a96817a536789c7ca236675 (patch)
tree061b0cc7e975c8fd809db7197efa41337977499d /sys/arch/sparc64/dev
parente158725fa25fd8df580ac2e6d6a32bbf42e6e2f8 (diff)
Call ldc_send_unreliable() insteaf of duplicating the code to send an ldc
packet. Rename vio_sendmsg() to vnet_sendmsg().
Diffstat (limited to 'sys/arch/sparc64/dev')
-rw-r--r--sys/arch/sparc64/dev/vdsk.c25
-rw-r--r--sys/arch/sparc64/dev/vnet.c61
2 files changed, 26 insertions, 60 deletions
diff --git a/sys/arch/sparc64/dev/vdsk.c b/sys/arch/sparc64/dev/vdsk.c
index a097db72afd..e2eade040c6 100644
--- a/sys/arch/sparc64/dev/vdsk.c
+++ b/sys/arch/sparc64/dev/vdsk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vdsk.c,v 1.39 2014/07/12 18:44:43 tedu Exp $ */
+/* $OpenBSD: vdsk.c,v 1.40 2014/09/15 08:16:21 kettenis Exp $ */
/*
* Copyright (c) 2009, 2011 Mark Kettenis
*
@@ -760,28 +760,11 @@ void
vdsk_sendmsg(struct vdsk_softc *sc, void *msg, size_t len)
{
struct ldc_conn *lc = &sc->sc_lc;
- struct ldc_pkt *lp;
- uint64_t tx_head, tx_tail, tx_state;
int err;
- err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state);
- if (err != H_EOK)
- return;
-
- lp = (struct ldc_pkt *)(lc->lc_txq->lq_va + tx_tail);
- bzero(lp, sizeof(struct ldc_pkt));
- lp->type = LDC_DATA;
- lp->stype = LDC_INFO;
- KASSERT((len & ~LDC_LEN_MASK) == 0);
- lp->env = len | LDC_FRAG_STOP | LDC_FRAG_START;
- lp->seqid = lc->lc_tx_seqid++;
- bcopy(msg, &lp->major, len);
-
- tx_tail += sizeof(*lp);
- tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1);
- err = hv_ldc_tx_set_qtail(lc->lc_id, tx_tail);
- if (err != H_EOK)
- printf("%s: hv_ldc_tx_set_qtail: %d\n", __func__, err);
+ err = ldc_send_unreliable(lc, msg, len);
+ if (err)
+ printf("%s: ldc_send_unreliable: %d\n", __func__, err);
}
void
diff --git a/sys/arch/sparc64/dev/vnet.c b/sys/arch/sparc64/dev/vnet.c
index 033db5aad9a..f2d1bd1c31a 100644
--- a/sys/arch/sparc64/dev/vnet.c
+++ b/sys/arch/sparc64/dev/vnet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnet.c,v 1.34 2014/08/18 13:29:13 dlg Exp $ */
+/* $OpenBSD: vnet.c,v 1.35 2014/09/15 08:16:21 kettenis Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
*
@@ -210,7 +210,7 @@ void vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *);
void vnet_ldc_reset(struct ldc_conn *);
void vnet_ldc_start(struct ldc_conn *);
-void vio_sendmsg(struct vnet_softc *, void *, size_t);
+void vnet_sendmsg(struct vnet_softc *, void *, size_t);
void vnet_send_ver_info(struct vnet_softc *, uint16_t, uint16_t);
void vnet_send_attr_info(struct vnet_softc *);
void vnet_send_dring_reg(struct vnet_softc *);
@@ -502,7 +502,7 @@ vnet_rx_vio_ver_info(struct vnet_softc *sc, struct vio_msg_tag *tag)
/* Huh, we're not talking to a network device? */
printf("Not a network device\n");
vi->tag.stype = VIO_SUBTYPE_NACK;
- vio_sendmsg(sc, vi, sizeof(*vi));
+ vnet_sendmsg(sc, vi, sizeof(*vi));
return;
}
@@ -510,14 +510,14 @@ vnet_rx_vio_ver_info(struct vnet_softc *sc, struct vio_msg_tag *tag)
vi->tag.stype = VIO_SUBTYPE_NACK;
vi->major = VNET_MAJOR;
vi->minor = VNET_MINOR;
- vio_sendmsg(sc, vi, sizeof(*vi));
+ vnet_sendmsg(sc, vi, sizeof(*vi));
return;
}
vi->tag.stype = VIO_SUBTYPE_ACK;
vi->tag.sid = sc->sc_local_sid;
vi->minor = VNET_MINOR;
- vio_sendmsg(sc, vi, sizeof(*vi));
+ vnet_sendmsg(sc, vi, sizeof(*vi));
sc->sc_vio_state |= VIO_RCV_VER_INFO;
break;
@@ -552,7 +552,7 @@ vnet_rx_vio_attr_info(struct vnet_softc *sc, struct vio_msg_tag *tag)
ai->tag.stype = VIO_SUBTYPE_ACK;
ai->tag.sid = sc->sc_local_sid;
- vio_sendmsg(sc, ai, sizeof(*ai));
+ vnet_sendmsg(sc, ai, sizeof(*ai));
sc->sc_vio_state |= VIO_RCV_ATTR_INFO;
break;
@@ -594,7 +594,7 @@ vnet_rx_vio_dring_reg(struct vnet_softc *sc, struct vio_msg_tag *tag)
dr->tag.stype = VIO_SUBTYPE_ACK;
dr->tag.sid = sc->sc_local_sid;
- vio_sendmsg(sc, dr, sizeof(*dr));
+ vnet_sendmsg(sc, dr, sizeof(*dr));
sc->sc_vio_state |= VIO_RCV_DRING_REG;
break;
@@ -632,7 +632,7 @@ vnet_rx_vio_rdx(struct vnet_softc *sc, struct vio_msg_tag *tag)
tag->stype = VIO_SUBTYPE_ACK;
tag->sid = sc->sc_local_sid;
- vio_sendmsg(sc, tag, sizeof(*tag));
+ vnet_sendmsg(sc, tag, sizeof(*tag));
sc->sc_vio_state |= VIO_RCV_RDX;
break;
@@ -740,7 +740,7 @@ vnet_rx_vio_desc_data(struct vnet_softc *sc, struct vio_msg_tag *tag)
skip:
dm->tag.stype = VIO_SUBTYPE_ACK;
dm->tag.sid = sc->sc_local_sid;
- vio_sendmsg(sc, dm, sizeof(*dm));
+ vnet_sendmsg(sc, dm, sizeof(*dm));
break;
case VIO_SUBTYPE_ACK:
@@ -852,7 +852,7 @@ vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *tag)
}
dm->tag.sid = sc->sc_local_sid;
dm->proc_state = VIO_DP_STOPPED;
- vio_sendmsg(sc, dm, sizeof(*dm));
+ vnet_sendmsg(sc, dm, sizeof(*dm));
break;
}
@@ -919,31 +919,14 @@ vnet_ldc_start(struct ldc_conn *lc)
}
void
-vio_sendmsg(struct vnet_softc *sc, void *msg, size_t len)
+vnet_sendmsg(struct vnet_softc *sc, void *msg, size_t len)
{
struct ldc_conn *lc = &sc->sc_lc;
- struct ldc_pkt *lp;
- uint64_t tx_head, tx_tail, tx_state;
int err;
- err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state);
- if (err != H_EOK)
- return;
-
- lp = (struct ldc_pkt *)(lc->lc_txq->lq_va + tx_tail);
- bzero(lp, sizeof(struct ldc_pkt));
- lp->type = LDC_DATA;
- lp->stype = LDC_INFO;
- KASSERT((len & ~LDC_LEN_MASK) == 0);
- lp->env = len | LDC_FRAG_STOP | LDC_FRAG_START;
- lp->seqid = lc->lc_tx_seqid++;
- bcopy(msg, &lp->major, len);
-
- tx_tail += sizeof(*lp);
- tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1);
- err = hv_ldc_tx_set_qtail(lc->lc_id, tx_tail);
- if (err != H_EOK)
- printf("%s: hv_ldc_tx_set_qtail: %d\n", __func__, err);
+ err = ldc_send_unreliable(lc, msg, len);
+ if (err)
+ printf("%s: ldc_send_unreliable: %d\n", __func__, err);
}
void
@@ -959,7 +942,7 @@ vnet_send_ver_info(struct vnet_softc *sc, uint16_t major, uint16_t minor)
vi.major = major;
vi.minor = minor;
vi.dev_class = VDEV_NETWORK;
- vio_sendmsg(sc, &vi, sizeof(vi));
+ vnet_sendmsg(sc, &vi, sizeof(vi));
sc->sc_vio_state |= VIO_SND_VER_INFO;
}
@@ -984,7 +967,7 @@ vnet_send_attr_info(struct vnet_softc *sc)
ai.addr |= sc->sc_ac.ac_enaddr[i];
}
ai.mtu = ETHER_MAX_LEN - ETHER_CRC_LEN;
- vio_sendmsg(sc, &ai, sizeof(ai));
+ vnet_sendmsg(sc, &ai, sizeof(ai));
sc->sc_vio_state |= VIO_SND_ATTR_INFO;
}
@@ -1006,7 +989,7 @@ vnet_send_dring_reg(struct vnet_softc *sc)
dr.ncookies = 1;
dr.cookie[0].addr = 0;
dr.cookie[0].size = PAGE_SIZE;
- vio_sendmsg(sc, &dr, sizeof(dr));
+ vnet_sendmsg(sc, &dr, sizeof(dr));
sc->sc_vio_state |= VIO_SND_DRING_REG;
};
@@ -1020,7 +1003,7 @@ vio_send_rdx(struct vnet_softc *sc)
tag.stype = VIO_SUBTYPE_INFO;
tag.stype_env = VIO_RDX;
tag.sid = sc->sc_local_sid;
- vio_sendmsg(sc, &tag, sizeof(tag));
+ vnet_sendmsg(sc, &tag, sizeof(tag));
sc->sc_vio_state |= VIO_SND_RDX;
}
@@ -1039,7 +1022,7 @@ vnet_send_dring_data(struct vnet_softc *sc, uint32_t start_idx)
dm.dring_ident = sc->sc_dring_ident;
dm.start_idx = start_idx;
dm.end_idx = -1;
- vio_sendmsg(sc, &dm, sizeof(dm));
+ vnet_sendmsg(sc, &dm, sizeof(dm));
sc->sc_peer_state = VIO_DP_ACTIVE;
}
@@ -1217,7 +1200,7 @@ vnet_start_desc(struct ifnet *ifp)
dm.cookie[0].addr =
map->lm_next << PAGE_SHIFT | (pa & PAGE_MASK);
dm.cookie[0].size = 2048;
- vio_sendmsg(sc, &dm, sizeof(dm));
+ vnet_sendmsg(sc, &dm, sizeof(dm));
sc->sc_tx_prod++;
sc->sc_tx_prod &= (sc->sc_vd->vd_nentries - 1);
@@ -1351,13 +1334,13 @@ vnet_setmulti(struct vnet_softc *sc, int set)
continue;
mi.count = VNET_NUM_MCAST;
- vio_sendmsg(sc, &mi, sizeof(mi));
+ vnet_sendmsg(sc, &mi, sizeof(mi));
count = 0;
}
if (count > 0) {
mi.count = count;
- vio_sendmsg(sc, &mi, sizeof(mi));
+ vnet_sendmsg(sc, &mi, sizeof(mi));
}
}