Skip to content

Commit

Permalink
Compact feature display
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
  • Loading branch information
xl0 committed Jun 20, 2011
1 parent 0c539bb commit bfff365
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
6 changes: 3 additions & 3 deletions virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ virtio_negotiate_features(struct virtio_softc *sc, uint32_t guest_features)
return (host_features);
}

char *
size_t
virtio_show_features(struct virtio_softc *sc, uint32_t features,
char *buf, size_t len)
{

char *orig_buf = buf;
char *bufend = buf + len;

buf += snprintf(buf, bufend - buf, "Generic ( ");
Expand All @@ -115,7 +115,7 @@ virtio_show_features(struct virtio_softc *sc, uint32_t features,

buf += snprintf(buf, bufend - buf, ") ");

return buf;
return buf - orig_buf;
}

boolean_t
Expand Down
2 changes: 1 addition & 1 deletion virtio/virtiovar.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ struct virtio_int_handler {

void virtio_init(struct virtio_softc *sc);
uint32_t virtio_negotiate_features(struct virtio_softc*, uint32_t);
char *virtio_show_features(struct virtio_softc *sc, uint32_t features,
size_t virtio_show_features(struct virtio_softc *sc, uint32_t features,
char *buffer, size_t len);
boolean_t virtio_has_feature(struct virtio_softc *sc, uint32_t feature);
void virtio_set_status(struct virtio_softc *sc, int );
Expand Down
18 changes: 9 additions & 9 deletions virtio_blk/vioblk.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,14 +682,17 @@ vioblk_match(dev_info_t *devinfo, ddi_acc_handle_t pconf)
}

static void
vioblk_show_features(struct vioblk_softc *sc, uint32_t features)
vioblk_show_features(struct vioblk_softc *sc, const char *prefix,
uint32_t features)
{
char buf[512];
char *bufp;
char *bufp = buf;
char *bufend = buf + sizeof(buf);

bufp = virtio_show_features(&sc->sc_virtio,
features, buf, sizeof(buf));
bufp += snprintf(bufp, bufend - bufp, prefix);

bufp += virtio_show_features(&sc->sc_virtio,
features, bufp, bufend - bufp);


bufp += snprintf(bufp, bufend - bufp, "Vioblk ( ");
Expand Down Expand Up @@ -738,11 +741,8 @@ vioblk_dev_features(struct vioblk_softc *sc)
return (DDI_FAILURE);
}

dev_err(sc->sc_dev, CE_NOTE, "Host features:");
vioblk_show_features(sc, host_features);

dev_err(sc->sc_dev, CE_NOTE, "Negotiated features:");
vioblk_show_features(sc, sc->sc_virtio.sc_features);
vioblk_show_features(sc, "Host features: ", host_features);
vioblk_show_features(sc, "Negotiated features: ", sc->sc_virtio.sc_features);

return (DDI_SUCCESS);
}
Expand Down
19 changes: 8 additions & 11 deletions virtio_net/vioif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,15 +1049,17 @@ vioif_match(dev_info_t *devinfo, ddi_acc_handle_t pconf)
}

static void
vioif_show_features(struct vioif_softc *sc, uint32_t features)
vioif_show_features(struct vioif_softc *sc, const char *prefix,
uint32_t features)
{
char buf[512];
char *bufp;
char *bufp = buf;
char *bufend = buf + sizeof(buf);

bufp = virtio_show_features(&sc->sc_virtio,
features, buf, sizeof(buf));
bufp += snprintf(bufp, bufend - bufp, prefix);

bufp += virtio_show_features(&sc->sc_virtio,
features, bufp, bufend - bufp);

bufp += snprintf(bufp, bufend - bufp, "Vioif ( ");

Expand Down Expand Up @@ -1113,20 +1115,15 @@ vioif_dev_features(struct vioif_softc *sc)
{
uint32_t host_features;


host_features = virtio_negotiate_features(&sc->sc_virtio,
VIRTIO_NET_F_CSUM |
VIRTIO_NET_F_MAC |
VIRTIO_NET_F_STATUS |
VIRTIO_NET_F_MRG_RXBUF |
VIRTIO_F_NOTIFY_ON_EMPTY);

dev_err(sc->sc_dev, CE_NOTE, "Host features:");
vioif_show_features(sc, host_features);

dev_err(sc->sc_dev, CE_NOTE, "Negotiated features:");
vioif_show_features(sc, sc->sc_virtio.sc_features);

vioif_show_features(sc, "Host features: ", host_features);
vioif_show_features(sc, "Negotiated features: ", sc->sc_virtio.sc_features);

sc->sc_rxbuf_size = VIOIF_RX_SIZE;
if (sc->sc_virtio.sc_features & VIRTIO_NET_F_MRG_RXBUF) {
Expand Down

0 comments on commit bfff365

Please sign in to comment.