From c74443892c07717bae2304d51260557033775055 Mon Sep 17 00:00:00 2001 From: Marcin Wojtas Date: Wed, 18 Nov 2020 15:02:12 +0000 Subject: [PATCH] Add Rx offsets support for the ENA driver For the first descriptor in a chain the data may start at an offset. It is optional feature of some devices, so the driver must ack that it supports it. The data pointer of the mbuf is simply shifted by the given value. Submitted by: Maciej Bielski Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27116 --- sys/dev/ena/ena.c | 2 ++ sys/dev/ena/ena_datapath.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index 4d853d968351..8c2eeecc8d9c 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -2797,6 +2797,8 @@ ena_config_host_info(struct ena_com_dev *ena_dev, device_t dev) (DRV_MODULE_VER_MINOR << ENA_ADMIN_HOST_INFO_MINOR_SHIFT) | (DRV_MODULE_VER_SUBMINOR << ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT); host_info->num_cpus = mp_ncpus; + host_info->driver_supported_features = + ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK; rc = ena_com_set_host_attributes(ena_dev); if (unlikely(rc != 0)) { diff --git a/sys/dev/ena/ena_datapath.c b/sys/dev/ena/ena_datapath.c index f2783efd98cc..7df7ba0a63db 100644 --- a/sys/dev/ena/ena_datapath.c +++ b/sys/dev/ena/ena_datapath.c @@ -431,6 +431,10 @@ ena_rx_mbuf(struct ena_ring *rx_ring, struct ena_com_rx_buf_info *ena_bufs, mbuf->m_flags |= M_PKTHDR; mbuf->m_pkthdr.len = len; mbuf->m_len = len; + // Only for the first segment the data starts at specific offset + mbuf->m_data = mtodo(mbuf, ena_rx_ctx->pkt_offset); + ena_trace(NULL, ENA_DBG | ENA_RXPTH, + "Mbuf data offset=%u\n", ena_rx_ctx->pkt_offset); mbuf->m_pkthdr.rcvif = rx_ring->que->adapter->ifp; /* Fill mbuf with hash key and it's interpretation for optimization */ @@ -575,6 +579,8 @@ ena_rx_cleanup(struct ena_ring *rx_ring) ena_rx_ctx.ena_bufs = rx_ring->ena_bufs; ena_rx_ctx.max_bufs = adapter->max_rx_sgl_size; ena_rx_ctx.descs = 0; + ena_rx_ctx.pkt_offset = 0; + bus_dmamap_sync(io_cq->cdesc_addr.mem_handle.tag, io_cq->cdesc_addr.mem_handle.map, BUS_DMASYNC_POSTREAD); rc = ena_com_rx_pkt(io_cq, io_sq, &ena_rx_ctx);