MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vhost_user_iotlb_cache_insert

Function vhost_user_iotlb_cache_insert

dpdk/lib/vhost/iotlb.c:248–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248void
249vhost_user_iotlb_cache_insert(struct virtio_net *dev, uint64_t iova, uint64_t uaddr,
250 uint64_t uoffset, uint64_t size, uint64_t page_size, uint8_t perm)
251{
252 struct vhost_iotlb_entry *node, *new_node;
253
254 new_node = vhost_user_iotlb_pool_get(dev);
255 if (new_node == NULL) {
256 VHOST_LOG_CONFIG(dev->ifname, DEBUG,
257 "IOTLB pool empty, clear entries for cache insertion\n");
258 if (!TAILQ_EMPTY(&dev->iotlb_list))
259 vhost_user_iotlb_cache_random_evict(dev);
260 else
261 vhost_user_iotlb_pending_remove_all(dev);
262 new_node = vhost_user_iotlb_pool_get(dev);
263 if (new_node == NULL) {
264 VHOST_LOG_CONFIG(dev->ifname, ERR,
265 "IOTLB pool still empty, cache insertion failed\n");
266 return;
267 }
268 }
269
270 new_node->iova = iova;
271 new_node->uaddr = uaddr;
272 new_node->uoffset = uoffset;
273 new_node->size = size;
274 new_node->page_shift = rte_ctz64(page_size);
275 new_node->perm = perm;
276
277 vhost_user_iotlb_wr_lock_all(dev);
278
279 TAILQ_FOREACH(node, &dev->iotlb_list, next) {
280 /*
281 * Entries must be invalidated before being updated.
282 * So if iova already in list, assume identical.
283 */
284 if (node->iova == new_node->iova) {
285 vhost_user_iotlb_pool_put(dev, new_node);
286 goto unlock;
287 } else if (node->iova > new_node->iova) {
288 vhost_user_iotlb_set_dump(new_node);
289
290 TAILQ_INSERT_BEFORE(node, new_node, next);
291 dev->iotlb_cache_nr++;
292 goto unlock;
293 }
294 }
295
296 vhost_user_iotlb_set_dump(new_node);
297
298 TAILQ_INSERT_TAIL(&dev->iotlb_list, new_node, next);
299 dev->iotlb_cache_nr++;
300
301unlock:
302 vhost_user_iotlb_pending_remove(dev, iova, size, perm);
303
304 vhost_user_iotlb_wr_unlock_all(dev);
305}

Callers 2

vduse_iotlb_missFunction · 0.85
vhost_user_iotlb_msgFunction · 0.85

Tested by

no test coverage detected