Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct ixgbevf_ring {
dma_addr_t dma; /* phys. address of descriptor ring */
unsigned int size; /* length in bytes */
u32 truesize; /* Rx buffer full size */
u32 hdr_truesize; /* Rx header buffer full size */
u16 count; /* amount of descriptors */
u16 next_to_use;
u16 next_to_clean;
Expand All @@ -104,6 +105,8 @@ struct ixgbevf_ring {
struct ixgbevf_tx_queue_stats tx_stats;
struct ixgbevf_rx_queue_stats rx_stats;
};
struct libeth_fqe *hdr_fqes;
struct page_pool *hdr_pp;
struct xdp_rxq_info xdp_rxq;
u64 hw_csum_rx_error;
u8 __iomem *tail;
Expand All @@ -113,6 +116,7 @@ struct ixgbevf_ring {
*/
u16 reg_idx;
int queue_index; /* needed for multiqueue queue management */
u32 hdr_buf_len;
u32 rx_buf_len;
struct libeth_xdp_buff_stash xdp_stash;
} ____cacheline_internodealigned_in_smp;
Expand Down Expand Up @@ -147,6 +151,8 @@ struct ixgbevf_ring {
#define IXGBEVF_RX_PAGE_LEN(hr) (ALIGN_DOWN(LIBETH_RX_PAGE_LEN(hr), \
IXGBE_SRRCTL_BSIZEPKT_STEP))

#define IXGBEVF_FLAG_HSPLIT BIT(0)

#define IXGBE_TX_FLAGS_CSUM BIT(0)
#define IXGBE_TX_FLAGS_VLAN BIT(1)
#define IXGBE_TX_FLAGS_TSO BIT(2)
Expand Down
150 changes: 135 additions & 15 deletions drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,
.truesize = rx_ring->truesize,
.count = rx_ring->count,
};
const struct libeth_fq_fp hdr_fq = {
.pp = rx_ring->hdr_pp,
.fqes = rx_ring->hdr_fqes,
.truesize = rx_ring->hdr_truesize,
.count = rx_ring->count,
};
u16 ntu = rx_ring->next_to_use;

/* nothing to do or no valid netdev defined */
Expand All @@ -584,6 +590,14 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring,

rx_desc->read.pkt_addr = cpu_to_le64(addr);

if (!hdr_fq.pp)
goto next;

addr = libeth_rx_alloc(&hdr_fq, ntu);
if (addr == DMA_MAPPING_ERROR)
return;

next:
rx_desc++;
ntu++;
if (unlikely(ntu == fq.count)) {
Expand Down Expand Up @@ -781,6 +795,32 @@ static int ixgbevf_run_xdp(struct ixgbevf_adapter *adapter,
return result;
}

static u32 ixgbevf_rx_hsplit_wa(const struct libeth_fqe *hdr,
struct libeth_fqe *buf, u32 data_len)
{
u32 copy = data_len <= L1_CACHE_BYTES ? data_len : ETH_HLEN;
struct page *hdr_page, *buf_page;
const void *src;
void *dst;

if (unlikely(netmem_is_net_iov(buf->netmem)) ||
!libeth_rx_sync_for_cpu(buf, copy))
return 0;

hdr_page = __netmem_to_page(hdr->netmem);
buf_page = __netmem_to_page(buf->netmem);

dst = page_address(hdr_page) + hdr->offset +
pp_page_to_nmdesc(hdr_page)->pp->p.offset;
src = page_address(buf_page) + buf->offset +
pp_page_to_nmdesc(buf_page)->pp->p.offset;

memcpy(dst, src, LARGEST_ALIGN(copy));
buf->offset += copy;

return copy;
}

static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
struct ixgbevf_ring *rx_ring,
int budget)
Expand Down Expand Up @@ -818,6 +858,23 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
rmb();

rx_buffer = &rx_ring->rx_fqes[rx_ring->next_to_clean];

if (unlikely(rx_ring->hdr_pp)) {
struct libeth_fqe *hdr_buff;
unsigned int hdr_size = 0;

hdr_buff = &rx_ring->hdr_fqes[rx_ring->next_to_clean];

if (!xdp->data) {
hdr_size = ixgbevf_rx_hsplit_wa(hdr_buff,
rx_buffer,
size);
size -= hdr_size ? : size;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if we cannot copy from the buffer, we zero its size, so it is dropped?

}

libeth_xdp_process_buff(xdp, hdr_buff, hdr_size);
}

libeth_xdp_process_buff(xdp, rx_buffer, size);

cleaned_count++;
Expand Down Expand Up @@ -3054,19 +3111,38 @@ static int ixgbevf_setup_all_tx_resources(struct ixgbevf_adapter *adapter)
return err;
}

/**
* ixgbevf_setup_rx_resources - allocate Rx resources (Descriptors)
* @adapter: board private structure
* @rx_ring: Rx descriptor ring (for a specific queue) to setup
*
* Returns 0 on success, negative on failure
**/
int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter,
struct ixgbevf_ring *rx_ring)
static void ixgbvf_rx_destroy_pp(struct ixgbevf_ring *rx_ring)
{
struct libeth_fq fq = {
.pp = rx_ring->pp,
.fqes = rx_ring->rx_fqes,
};

libeth_rx_fq_destroy(&fq);
rx_ring->rx_fqes = NULL;
rx_ring->pp = NULL;

if (!rx_ring->hdr_pp)
return;

fq = (struct libeth_fq) {
.pp = rx_ring->hdr_pp,
.fqes = rx_ring->hdr_fqes,
};

libeth_rx_fq_destroy(&fq);
rx_ring->hdr_fqes = NULL;
rx_ring->hdr_pp = NULL;
}

static int ixgbvf_rx_create_pp(struct ixgbevf_ring *rx_ring)
{
u32 adapter_flags = rx_ring->q_vector->adapter->flags;

struct libeth_fq fq = {
.count = rx_ring->count,
.nid = NUMA_NO_NODE,
.hsplit = adapter_flags & IXGBEVF_FLAG_HSPLIT,
.type = LIBETH_FQE_MTU,
.xdp = !!rx_ring->xdp_prog,
.buf_len = IXGBEVF_RX_PAGE_LEN(rx_ring->xdp_prog ?
Expand All @@ -3084,34 +3160,75 @@ int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter,
rx_ring->truesize = fq.truesize;
rx_ring->rx_buf_len = fq.buf_len;

if (!fq.hsplit)
return 0;

fq = (struct libeth_fq) {
.count = rx_ring->count,
.nid = NUMA_NO_NODE,
.type = LIBETH_FQE_HDR,
.xdp = !!rx_ring->xdp_prog,
};

ret = libeth_rx_fq_create(&fq, &rx_ring->q_vector->napi);
if (ret)
goto err;

rx_ring->hdr_pp = fq.pp;
rx_ring->hdr_fqes = fq.fqes;
rx_ring->hdr_truesize = fq.truesize;
rx_ring->hdr_buf_len = fq.buf_len;

return 0;

err:
ixgbvf_rx_destroy_pp(rx_ring);
return ret;
}

/**
* ixgbevf_setup_rx_resources - allocate Rx resources
* @adapter: board private structure
* @rx_ring: Rx descriptor ring (for a specific queue) to setup
*
* Returns: 0 on success, negative on failure.
**/
int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter,
struct ixgbevf_ring *rx_ring)
{
int ret;

ret = ixgbvf_rx_create_pp(rx_ring);
if (ret)
return ret;

u64_stats_init(&rx_ring->syncp);

/* Round up to nearest 4K */
rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
rx_ring->size = ALIGN(rx_ring->size, 4096);

rx_ring->desc = dma_alloc_coherent(fq.pp->p.dev, rx_ring->size,
rx_ring->desc = dma_alloc_coherent(rx_ring->pp->p.dev, rx_ring->size,
&rx_ring->dma, GFP_KERNEL);

if (!rx_ring->desc)
goto err;

/* XDP RX-queue info */
ret = __xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev,
rx_ring->queue_index, 0, fq.buf_len);
rx_ring->queue_index, 0, rx_ring->rx_buf_len);
if (ret)
goto err;

xdp_rxq_info_attach_page_pool(&rx_ring->xdp_rxq, fq.pp);
xdp_rxq_info_attach_page_pool(&rx_ring->xdp_rxq, rx_ring->pp);

rx_ring->xdp_prog = adapter->xdp_prog;

return 0;
err:
libeth_rx_fq_destroy(&fq);
rx_ring->rx_fqes = NULL;
rx_ring->pp = NULL;
ixgbvf_rx_destroy_pp(rx_ring);
dev_err(rx_ring->dev, "Unable to allocate memory for the Rx descriptor ring\n");

return ret;
}

Expand Down Expand Up @@ -4222,6 +4339,9 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev->priv_flags |= IFF_UNICAST_FLT;
netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_RX_SG;

if (adapter->hw.mac.type == ixgbe_mac_82599_vf)
adapter->flags |= IXGBEVF_FLAG_HSPLIT;

/* MTU range: 68 - 1504 or 9710 */
netdev->min_mtu = ETH_MIN_MTU;
switch (adapter->hw.api_version) {
Expand Down