Lines Matching refs:ctx

78 	struct xsk_ctx *ctx;
359 struct xsk_ctx *ctx = xsk->ctx;
364 * SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx)
366 * int ret, index = ctx->rx_queue_index;
387 BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd),
399 BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd),
411 BPF_LD_MAP_FD(BPF_REG_1, ctx->xsks_map_fd),
429 err = bpf_set_link_xdp_fd(xsk->ctx->ifindex, prog_fd,
436 ctx->prog_fd = prog_fd;
443 struct xsk_ctx *ctx = xsk->ctx;
452 memcpy(ifr.ifr_name, ctx->ifname, IFNAMSIZ - 1);
480 struct xsk_ctx *ctx = xsk->ctx;
493 ctx->xsks_map_fd = fd;
500 struct xsk_ctx *ctx = xsk->ctx;
502 bpf_map_delete_elem(ctx->xsks_map_fd, &ctx->queue_id);
503 close(ctx->xsks_map_fd);
511 struct xsk_ctx *ctx = xsk->ctx;
515 err = bpf_obj_get_info_by_fd(ctx->prog_fd, &prog_info, &prog_len);
529 err = bpf_obj_get_info_by_fd(ctx->prog_fd, &prog_info, &prog_len);
533 ctx->xsks_map_fd = -1;
548 ctx->xsks_map_fd = fd;
556 if (ctx->xsks_map_fd == -1)
566 struct xsk_ctx *ctx = xsk->ctx;
568 return bpf_map_update_elem(ctx->xsks_map_fd, &ctx->queue_id,
574 struct xsk_ctx *ctx = xsk->ctx;
578 err = bpf_get_link_xdp_id(ctx->ifindex, &prog_id,
594 ctx->prog_fd = bpf_prog_get_fd_by_id(prog_id);
595 if (ctx->prog_fd < 0)
599 close(ctx->prog_fd);
608 close(ctx->prog_fd);
618 struct xsk_ctx *ctx;
623 list_for_each_entry(ctx, &umem->ctx_list, list) {
624 if (ctx->ifindex == ifindex && ctx->queue_id == queue_id) {
625 ctx->refcount++;
626 return ctx;
633 static void xsk_put_ctx(struct xsk_ctx *ctx, bool unmap)
635 struct xsk_umem *umem = ctx->umem;
639 if (--ctx->refcount)
649 munmap(ctx->fill->ring - off.fr.desc, off.fr.desc + umem->config.fill_size *
651 munmap(ctx->comp->ring - off.cr.desc, off.cr.desc + umem->config.comp_size *
655 list_del(&ctx->list);
656 free(ctx);
665 struct xsk_ctx *ctx;
668 ctx = calloc(1, sizeof(*ctx));
669 if (!ctx)
675 free(ctx);
684 ctx->ifindex = ifindex;
685 ctx->refcount = 1;
686 ctx->umem = umem;
687 ctx->queue_id = queue_id;
688 memcpy(ctx->ifname, ifname, IFNAMSIZ - 1);
689 ctx->ifname[IFNAMSIZ - 1] = '\0';
691 ctx->fill = fill;
692 ctx->comp = comp;
693 list_add(&ctx->list, &umem->ctx_list);
694 return ctx;
711 struct xsk_ctx *ctx;
746 ctx = xsk_get_ctx(umem, ifindex, queue_id);
747 if (!ctx) {
753 ctx = xsk_create_ctx(xsk, umem, ifindex, ifname, queue_id,
755 if (!ctx) {
760 xsk->ctx = ctx;
837 sxdp.sxdp_ifindex = ctx->ifindex;
838 sxdp.sxdp_queue_id = ctx->queue_id;
872 xsk_put_ctx(ctx, unmap);
924 struct xsk_ctx *ctx;
930 ctx = xsk->ctx;
931 umem = ctx->umem;
933 if (ctx->refcount == 1) {
935 close(ctx->prog_fd);
938 xsk_put_ctx(ctx, true);