aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincenzo Maffione <vmaffione@FreeBSD.org>2021-04-05 07:54:47 +0000
committerVincenzo Maffione <vmaffione@FreeBSD.org>2021-04-05 07:54:47 +0000
commit361e950180025b72cf78a41a3563d32f9beb0b05 (patch)
tree859893f46b20c1d7024f030f6fe5579147037f7b
parent7a606f280a3e174dcdd12736b7b976903809eb9c (diff)
downloadsrc-361e950180025b72cf78a41a3563d32f9beb0b05.tar.gz
src-361e950180025b72cf78a41a3563d32f9beb0b05.zip
iflib: add support for netmap offsets
Follow-up change to a6d768d845c173823785c71bb18b40074e7a8998. This change adds iflib support for netmap offsets, enabling applications to use offsets on any driver backed by iflib.
-rw-r--r--sys/net/iflib.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index f6cf1233a3b5..6dbaff556a15 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -914,13 +914,16 @@ netmap_fl_refill(iflib_rxq_t rxq, struct netmap_kring *kring, bool init)
nic_i_first = nic_i;
for (i = 0; n > 0 && i < IFLIB_MAX_RX_REFRESH; n--, i++) {
struct netmap_slot *slot = &ring->slot[nm_i];
- void *addr = PNMB(na, slot, &fl->ifl_bus_addrs[i]);
+ uint64_t paddr;
+ void *addr = PNMB(na, slot, &paddr);
MPASS(i < IFLIB_MAX_RX_REFRESH);
if (addr == NETMAP_BUF_BASE(na)) /* bad buf */
return netmap_ring_reinit(kring);
+ fl->ifl_bus_addrs[i] = paddr +
+ nm_get_offset(kring, slot);
fl->ifl_rxd_idxs[i] = nic_i;
if (__predict_false(init)) {
@@ -1038,6 +1041,7 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags)
for (n = 0; nm_i != head; n++) {
struct netmap_slot *slot = &ring->slot[nm_i];
+ uint64_t offset = nm_get_offset(kring, slot);
u_int len = slot->len;
uint64_t paddr;
void *addr = PNMB(na, slot, &paddr);
@@ -1053,7 +1057,7 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags)
if (nic_i_start < 0)
nic_i_start = nic_i;
- pi.ipi_segs[seg_idx].ds_addr = paddr;
+ pi.ipi_segs[seg_idx].ds_addr = paddr + offset;
pi.ipi_segs[seg_idx].ds_len = len;
if (len) {
pkt_len += len;
@@ -1081,7 +1085,7 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags)
__builtin_prefetch(&txq->ift_sds.ifsd_m[nic_i + 1]);
__builtin_prefetch(&txq->ift_sds.ifsd_map[nic_i + 1]);
- NM_CHECK_ADDR_LEN(na, addr, len);
+ NM_CHECK_ADDR_LEN_OFF(na, len, offset);
if (slot->flags & NS_BUF_CHANGED) {
/* buffer has changed, reload map */
@@ -1289,7 +1293,7 @@ iflib_netmap_attach(if_ctx_t ctx)
bzero(&na, sizeof(na));
na.ifp = ctx->ifc_ifp;
- na.na_flags = NAF_BDG_MAYSLEEP | NAF_MOREFRAG;
+ na.na_flags = NAF_BDG_MAYSLEEP | NAF_MOREFRAG | NAF_OFFSETS;
MPASS(ctx->ifc_softc_ctx.isc_ntxqsets);
MPASS(ctx->ifc_softc_ctx.isc_nrxqsets);