net: ethernet: Allow drivers to reserve net_pkt headroom
Add new Ethernet driver config option, ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM, which allows Ethernet drivers to inform L2 about the extra net_pkt headroom they need to be allocated. This is only supported when CONFIG_NET_L2_ETHERNET_RESERVE_HEADER is enabled, so that it's possible to fit entire packet into a single net_buf, which is needed for zero-copy transmission. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
e35cb93afa
commit
78c3996b59
2 changed files with 13 additions and 3 deletions
|
|
@ -234,7 +234,8 @@ enum ethernet_config_type {
|
||||||
ETHERNET_CONFIG_TYPE_T1S_PARAM,
|
ETHERNET_CONFIG_TYPE_T1S_PARAM,
|
||||||
ETHERNET_CONFIG_TYPE_TXINJECTION_MODE,
|
ETHERNET_CONFIG_TYPE_TXINJECTION_MODE,
|
||||||
ETHERNET_CONFIG_TYPE_RX_CHECKSUM_SUPPORT,
|
ETHERNET_CONFIG_TYPE_RX_CHECKSUM_SUPPORT,
|
||||||
ETHERNET_CONFIG_TYPE_TX_CHECKSUM_SUPPORT
|
ETHERNET_CONFIG_TYPE_TX_CHECKSUM_SUPPORT,
|
||||||
|
ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ethernet_qav_param_type {
|
enum ethernet_qav_param_type {
|
||||||
|
|
@ -529,6 +530,8 @@ struct ethernet_config {
|
||||||
enum ethernet_checksum_support chksum_support;
|
enum ethernet_checksum_support chksum_support;
|
||||||
|
|
||||||
struct ethernet_filter filter;
|
struct ethernet_filter filter;
|
||||||
|
|
||||||
|
uint16_t extra_tx_pkt_headroom;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -862,8 +862,15 @@ static int ethernet_l2_alloc(struct net_if *iface, struct net_pkt *pkt,
|
||||||
size_t size, enum net_ip_protocol proto,
|
size_t size, enum net_ip_protocol proto,
|
||||||
k_timeout_t timeout)
|
k_timeout_t timeout)
|
||||||
{
|
{
|
||||||
return net_pkt_alloc_buffer_with_reserve(pkt, size,
|
size_t reserve = get_reserve_ll_header_size(iface);
|
||||||
get_reserve_ll_header_size(iface),
|
struct ethernet_config config;
|
||||||
|
|
||||||
|
if (net_eth_get_hw_config(iface, ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM,
|
||||||
|
&config) == 0) {
|
||||||
|
reserve += config.extra_tx_pkt_headroom;
|
||||||
|
}
|
||||||
|
|
||||||
|
return net_pkt_alloc_buffer_with_reserve(pkt, size, reserve,
|
||||||
proto, timeout);
|
proto, timeout);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue