OSDN Git Service

xdp: allow page_pool as an allocator type in xdp_return_frame
authorJesper Dangaard Brouer <brouer@redhat.com>
Tue, 17 Apr 2018 14:46:22 +0000 (16:46 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 17 Apr 2018 14:50:29 +0000 (10:50 -0400)
commit57d0a1c1ac9e6a836bbab4698ba2a2e03f64bf1b
tree95b4f994d510df73d33388612778bfdcd433bb79
parentff7d6b27f894f1469dc51ccb828b7363ccd9799f
xdp: allow page_pool as an allocator type in xdp_return_frame

New allocator type MEM_TYPE_PAGE_POOL for page_pool usage.

The registered allocator page_pool pointer is not available directly
from xdp_rxq_info, but it could be (if needed).  For now, the driver
should keep separate track of the page_pool pointer, which it should
use for RX-ring page allocation.

As suggested by Saeed, to maintain a symmetric API it is the drivers
responsibility to allocate/create and free/destroy the page_pool.
Thus, after the driver have called xdp_rxq_info_unreg(), it is drivers
responsibility to free the page_pool, but with a RCU free call.  This
is done easily via the page_pool helper page_pool_destroy() (which
avoids touching any driver code during the RCU callback, which could
happen after the driver have been unloaded).

V8: address issues found by kbuild test robot
 - Address sparse should be static warnings
 - Allow xdp.o to be compiled without page_pool.o

V9: Remove inline from .c file, compiler knows best

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/page_pool.h
include/net/xdp.h
net/core/xdp.c