]> git.baikalelectronics.ru Git - kernel.git/commitdiff
page_pool: Store the XDP mem id
authorToke Høiland-Jørgensen <toke@redhat.com>
Mon, 3 Jan 2022 15:08:08 +0000 (16:08 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 6 Jan 2022 03:46:32 +0000 (19:46 -0800)
Store the XDP mem ID inside the page_pool struct so it can be retrieved
later for use in bpf_prog_run().

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Link: https://lore.kernel.org/bpf/20220103150812.87914-4-toke@redhat.com
include/net/page_pool.h
net/core/page_pool.c
net/core/xdp.c

index d807b6800a4a38e24714e6340464198c5d115b77..79a805542d0fe55f2b1f139ef0bcc3e53e4c7f2c 100644 (file)
@@ -96,6 +96,7 @@ struct page_pool {
        unsigned int frag_offset;
        struct page *frag_page;
        long frag_users;
+       u32 xdp_mem_id;
 
        /*
         * Data structure for allocation side
@@ -170,9 +171,12 @@ bool page_pool_return_skb_page(struct page *page);
 
 struct page_pool *page_pool_create(const struct page_pool_params *params);
 
+struct xdp_mem_info;
+
 #ifdef CONFIG_PAGE_POOL
 void page_pool_destroy(struct page_pool *pool);
-void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *));
+void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *),
+                          struct xdp_mem_info *mem);
 void page_pool_release_page(struct page_pool *pool, struct page *page);
 void page_pool_put_page_bulk(struct page_pool *pool, void **data,
                             int count);
@@ -182,7 +186,8 @@ static inline void page_pool_destroy(struct page_pool *pool)
 }
 
 static inline void page_pool_use_xdp_mem(struct page_pool *pool,
-                                        void (*disconnect)(void *))
+                                        void (*disconnect)(void *),
+                                        struct xdp_mem_info *mem)
 {
 }
 static inline void page_pool_release_page(struct page_pool *pool,
index f53786f6666ddd489a0f9e4e6ce19a479b2dd9d5..7347d5c7dbe090a94b26239757386d216df00ca0 100644 (file)
@@ -693,10 +693,12 @@ static void page_pool_release_retry(struct work_struct *wq)
        schedule_delayed_work(&pool->release_dw, DEFER_TIME);
 }
 
-void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *))
+void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *),
+                          struct xdp_mem_info *mem)
 {
        refcount_inc(&pool->user_cnt);
        pool->disconnect = disconnect;
+       pool->xdp_mem_id = mem->id;
 }
 
 void page_pool_destroy(struct page_pool *pool)
index 58089f6d2c7a132e89ad5dfe4f6c8582a680453b..7aba355049862d79e1a31d2990b76fe1c1ca318f 100644 (file)
@@ -320,7 +320,7 @@ static struct xdp_mem_allocator *__xdp_reg_mem_model(struct xdp_mem_info *mem,
        }
 
        if (type == MEM_TYPE_PAGE_POOL)
-               page_pool_use_xdp_mem(allocator, mem_allocator_disconnect);
+               page_pool_use_xdp_mem(allocator, mem_allocator_disconnect, mem);
 
        mutex_unlock(&mem_id_lock);