]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/net/page_pool.h
page_pool: Add API to update numa node
[linux.git] / include / net / page_pool.h
index 2cbcdbdec25439adfcdce59898fa664a620af0f9..e2e1b7b1e8ba1697c8b3928b96671e3366c064f9 100644 (file)
@@ -70,7 +70,12 @@ struct page_pool_params {
 struct page_pool {
        struct page_pool_params p;
 
-        u32 pages_state_hold_cnt;
+       struct delayed_work release_dw;
+       void (*disconnect)(void *);
+       unsigned long defer_start;
+       unsigned long defer_warn;
+
+       u32 pages_state_hold_cnt;
 
        /*
         * Data structure for allocation side
@@ -107,6 +112,8 @@ struct page_pool {
         * refcnt serves purpose is to simplify drivers error handling.
         */
        refcount_t user_cnt;
+
+       u64 destroy_cnt;
 };
 
 struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp);
@@ -129,25 +136,19 @@ inline enum dma_data_direction page_pool_get_dma_dir(struct page_pool *pool)
 
 struct page_pool *page_pool_create(const struct page_pool_params *params);
 
-void __page_pool_free(struct page_pool *pool);
-static inline void page_pool_free(struct page_pool *pool)
-{
-       /* When page_pool isn't compiled-in, net/core/xdp.c doesn't
-        * allow registering MEM_TYPE_PAGE_POOL, but shield linker.
-        */
 #ifdef CONFIG_PAGE_POOL
-       __page_pool_free(pool);
-#endif
-}
-
-/* Drivers use this instead of page_pool_free */
+void page_pool_destroy(struct page_pool *pool);
+void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *));
+#else
 static inline void page_pool_destroy(struct page_pool *pool)
 {
-       if (!pool)
-               return;
+}
 
-       page_pool_free(pool);
+static inline void page_pool_use_xdp_mem(struct page_pool *pool,
+                                        void (*disconnect)(void *))
+{
 }
+#endif
 
 /* Never call this directly, use helpers below */
 void __page_pool_put_page(struct page_pool *pool,
@@ -170,24 +171,6 @@ static inline void page_pool_recycle_direct(struct page_pool *pool,
        __page_pool_put_page(pool, page, true);
 }
 
-/* API user MUST have disconnected alloc-side (not allowed to call
- * page_pool_alloc_pages()) before calling this.  The free-side can
- * still run concurrently, to handle in-flight packet-pages.
- *
- * A request to shutdown can fail (with false) if there are still
- * in-flight packet-pages.
- */
-bool __page_pool_request_shutdown(struct page_pool *pool);
-static inline bool page_pool_request_shutdown(struct page_pool *pool)
-{
-       bool safe_to_remove = false;
-
-#ifdef CONFIG_PAGE_POOL
-       safe_to_remove = __page_pool_request_shutdown(pool);
-#endif
-       return safe_to_remove;
-}
-
 /* Disconnects a page (from a page_pool).  API users can have a need
  * to disconnect a page (from a page_pool), to allow it to be used as
  * a regular page (that will eventually be returned to the normal
@@ -216,14 +199,16 @@ static inline bool is_page_pool_compiled_in(void)
 #endif
 }
 
-static inline void page_pool_get(struct page_pool *pool)
-{
-       refcount_inc(&pool->user_cnt);
-}
-
 static inline bool page_pool_put(struct page_pool *pool)
 {
        return refcount_dec_and_test(&pool->user_cnt);
 }
 
+/* Caller must provide appropriate safe context, e.g. NAPI. */
+void page_pool_update_nid(struct page_pool *pool, int new_nid);
+static inline void page_pool_nid_changed(struct page_pool *pool, int new_nid)
+{
+       if (unlikely(pool->p.nid != new_nid))
+               page_pool_update_nid(pool, new_nid);
+}
 #endif /* _NET_PAGE_POOL_H */