Commit 50e74c01 authored by Björn Töpel's avatar Björn Töpel Committed by Daniel Borkmann

xsk: add id to umem

This commit adds an id to the umem structure. The id uniquely
identifies a umem instance, and will be exposed to user-space via the
socket monitoring interface.
Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 1d0dc069
...@@ -42,6 +42,7 @@ struct xdp_umem { ...@@ -42,6 +42,7 @@ struct xdp_umem {
struct work_struct work; struct work_struct work;
struct page **pgs; struct page **pgs;
u32 npgs; u32 npgs;
int id;
struct net_device *dev; struct net_device *dev;
struct xdp_umem_fq_reuse *fq_reuse; struct xdp_umem_fq_reuse *fq_reuse;
u16 queue_id; u16 queue_id;
......
...@@ -13,12 +13,15 @@ ...@@ -13,12 +13,15 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/idr.h>
#include "xdp_umem.h" #include "xdp_umem.h"
#include "xsk_queue.h" #include "xsk_queue.h"
#define XDP_UMEM_MIN_CHUNK_SIZE 2048 #define XDP_UMEM_MIN_CHUNK_SIZE 2048
static DEFINE_IDA(umem_ida);
void xdp_add_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs) void xdp_add_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs)
{ {
unsigned long flags; unsigned long flags;
...@@ -183,6 +186,8 @@ static void xdp_umem_release(struct xdp_umem *umem) ...@@ -183,6 +186,8 @@ static void xdp_umem_release(struct xdp_umem *umem)
xdp_umem_clear_dev(umem); xdp_umem_clear_dev(umem);
ida_simple_remove(&umem_ida, umem->id);
if (umem->fq) { if (umem->fq) {
xskq_destroy(umem->fq); xskq_destroy(umem->fq);
umem->fq = NULL; umem->fq = NULL;
...@@ -389,8 +394,16 @@ struct xdp_umem *xdp_umem_create(struct xdp_umem_reg *mr) ...@@ -389,8 +394,16 @@ struct xdp_umem *xdp_umem_create(struct xdp_umem_reg *mr)
if (!umem) if (!umem)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
err = ida_simple_get(&umem_ida, 0, 0, GFP_KERNEL);
if (err < 0) {
kfree(umem);
return ERR_PTR(err);
}
umem->id = err;
err = xdp_umem_reg(umem, mr); err = xdp_umem_reg(umem, mr);
if (err) { if (err) {
ida_simple_remove(&umem_ida, umem->id);
kfree(umem); kfree(umem);
return ERR_PTR(err); return ERR_PTR(err);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment