Skip to content

Commit c0b709b

Browse files
committed
net: pass queue rx page size from memory provider
Allow memory providers to configure rx queues with a custom receive page size. It's passed in struct pp_memory_provider_params, which is copied into the queue, so it's preserved across queue restarts. Then, it's propagated to the driver in a new queue config parameter. Drivers should explicitly opt into using it by setting QCFG_RX_PAGE_SIZE, in which case they should implement ndo_default_qcfg, validate the size on queue restart and honour the current config in case of a reset. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
1 parent efcb9a4 commit c0b709b

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

include/net/netdev_queues.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct netdev_config {
1515
};
1616

1717
struct netdev_queue_config {
18+
u32 rx_page_size;
1819
};
1920

2021
/* See the netdev.yaml spec for definition of each statistic */
@@ -114,6 +115,11 @@ void netdev_stat_queue_sum(struct net_device *netdev,
114115
int tx_start, int tx_end,
115116
struct netdev_queue_stats_tx *tx_sum);
116117

118+
enum {
119+
/* The queue checks and honours the page size qcfg parameter */
120+
QCFG_RX_PAGE_SIZE = 0x1,
121+
};
122+
117123
/**
118124
* struct netdev_queue_mgmt_ops - netdev ops for queue management
119125
*
@@ -135,6 +141,8 @@ void netdev_stat_queue_sum(struct net_device *netdev,
135141
*
136142
* @ndo_default_qcfg: Populate queue config struct with defaults. Optional.
137143
*
144+
* @supported_params: Bitmask of supported parameters, see QCFG_*.
145+
*
138146
* Note that @ndo_queue_mem_alloc and @ndo_queue_mem_free may be called while
139147
* the interface is closed. @ndo_queue_start and @ndo_queue_stop will only
140148
* be called for an interface which is open.
@@ -158,6 +166,8 @@ struct netdev_queue_mgmt_ops {
158166
struct netdev_queue_config *qcfg);
159167
struct device * (*ndo_queue_get_dma_dev)(struct net_device *dev,
160168
int idx);
169+
170+
unsigned int supported_params;
161171
};
162172

163173
bool netif_rxq_has_unreadable_mp(struct net_device *dev, int idx);

include/net/page_pool/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ struct memory_provider_ops;
161161
struct pp_memory_provider_params {
162162
void *mp_priv;
163163
const struct memory_provider_ops *mp_ops;
164+
u32 rx_page_size;
164165
};
165166

166167
struct page_pool {

net/core/netdev_rx_queue.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,21 @@ int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq_idx)
3030
!qops->ndo_queue_mem_alloc || !qops->ndo_queue_start)
3131
return -EOPNOTSUPP;
3232

33+
if (WARN_ON_ONCE(qops->supported_params && !qops->ndo_default_qcfg))
34+
return -EINVAL;
35+
3336
netdev_assert_locked(dev);
3437

3538
memset(&qcfg, 0, sizeof(qcfg));
3639
if (qops->ndo_default_qcfg)
3740
qops->ndo_default_qcfg(dev, &qcfg);
3841

42+
if (rxq->mp_params.rx_page_size) {
43+
if (!(qops->supported_params & QCFG_RX_PAGE_SIZE))
44+
return -EOPNOTSUPP;
45+
qcfg.rx_page_size = rxq->mp_params.rx_page_size;
46+
}
47+
3948
new_mem = kvzalloc(qops->ndo_queue_mem_size, GFP_KERNEL);
4049
if (!new_mem)
4150
return -ENOMEM;

0 commit comments

Comments
 (0)