pci_virtio_rnd.c (2b9481465d6ee67ac62c160dbf79c3ec3348c611) pci_virtio_rnd.c (b0de25cb23668fa4535078d18a0618eee442c000)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2014 Nahanni Systems Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 99 unchanged lines hidden (view full) ---

108}
109
110
111static void
112pci_vtrnd_notify(void *vsc, struct vqueue_info *vq)
113{
114 struct iovec iov;
115 struct pci_vtrnd_softc *sc;
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2014 Nahanni Systems Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 99 unchanged lines hidden (view full) ---

108}
109
110
111static void
112pci_vtrnd_notify(void *vsc, struct vqueue_info *vq)
113{
114 struct iovec iov;
115 struct pci_vtrnd_softc *sc;
116 int len;
117 uint16_t idx;
116 struct vi_req req;
117 int len, n;
118
119 sc = vsc;
120
121 if (sc->vrsc_fd < 0) {
122 vq_endchains(vq, 0);
123 return;
124 }
125
126 while (vq_has_descs(vq)) {
118
119 sc = vsc;
120
121 if (sc->vrsc_fd < 0) {
122 vq_endchains(vq, 0);
123 return;
124 }
125
126 while (vq_has_descs(vq)) {
127 vq_getchain(vq, &idx, &iov, 1, NULL);
127 n = vq_getchain(vq, &iov, 1, &req);
128 assert(n == 1);
128
129 len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len);
130
131 DPRINTF(("vtrnd: vtrnd_notify(): %d", len));
132
133 /* Catastrophe if unable to read from /dev/random */
134 assert(len > 0);
135
136 /*
137 * Release this chain and handle more
138 */
129
130 len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len);
131
132 DPRINTF(("vtrnd: vtrnd_notify(): %d", len));
133
134 /* Catastrophe if unable to read from /dev/random */
135 assert(len > 0);
136
137 /*
138 * Release this chain and handle more
139 */
139 vq_relchain(vq, idx, len);
140 vq_relchain(vq, req.idx, len);
140 }
141 vq_endchains(vq, 1); /* Generate interrupt if appropriate. */
142}
143
144
145static int
146pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
147{

--- 63 unchanged lines hidden ---
141 }
142 vq_endchains(vq, 1); /* Generate interrupt if appropriate. */
143}
144
145
146static int
147pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
148{

--- 63 unchanged lines hidden ---