socsvn commit: r307251 - in soc2016/vincenzo/head/sys: dev/netmap net
vincenzo at FreeBSD.org
vincenzo at FreeBSD.org
Fri Aug 5 16:11:16 UTC 2016
Author: vincenzo
Date: Fri Aug 5 16:11:11 2016
New Revision: 307251
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=307251
Log:
align netmap to github and port ptnet driver to head
Added:
soc2016/vincenzo/head/sys/net/netmap_virt.h
Modified:
soc2016/vincenzo/head/sys/dev/netmap/if_em_netmap.h
soc2016/vincenzo/head/sys/dev/netmap/if_lem_netmap.h
soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c
soc2016/vincenzo/head/sys/dev/netmap/if_vtnet_netmap.h
soc2016/vincenzo/head/sys/dev/netmap/ixgbe_netmap.h
soc2016/vincenzo/head/sys/dev/netmap/netmap.c
soc2016/vincenzo/head/sys/dev/netmap/netmap_freebsd.c
soc2016/vincenzo/head/sys/dev/netmap/netmap_generic.c
soc2016/vincenzo/head/sys/dev/netmap/netmap_kern.h
soc2016/vincenzo/head/sys/dev/netmap/netmap_mem2.c
soc2016/vincenzo/head/sys/dev/netmap/netmap_monitor.c
soc2016/vincenzo/head/sys/dev/netmap/netmap_offloadings.c
soc2016/vincenzo/head/sys/dev/netmap/netmap_pipe.c
soc2016/vincenzo/head/sys/dev/netmap/netmap_vale.c
soc2016/vincenzo/head/sys/dev/netmap/ptnetmap.c
soc2016/vincenzo/head/sys/net/netmap.h
soc2016/vincenzo/head/sys/net/netmap_user.h
Modified: soc2016/vincenzo/head/sys/dev/netmap/if_em_netmap.h
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/if_em_netmap.h Fri Aug 5 15:48:56 2016 (r307250)
+++ soc2016/vincenzo/head/sys/dev/netmap/if_em_netmap.h Fri Aug 5 16:11:11 2016 (r307251)
@@ -148,7 +148,7 @@
/* device-specific */
struct e1000_tx_desc *curr = &txr->tx_base[nic_i];
- struct em_buffer *txbuf = &txr->tx_buffers[nic_i];
+ struct em_txbuffer *txbuf = &txr->tx_buffers[nic_i];
int flags = (slot->flags & NS_REPORT ||
nic_i == 0 || nic_i == report_frequency) ?
E1000_TXD_CMD_RS : 0;
@@ -239,12 +239,12 @@
nm_i = netmap_idx_n2k(kring, nic_i);
for (n = 0; ; n++) { // XXX no need to count
- struct e1000_rx_desc *curr = &rxr->rx_base[nic_i];
- uint32_t staterr = le32toh(curr->status);
+ union e1000_rx_desc_extended *curr = &rxr->rx_base[nic_i];
+ uint32_t staterr = le32toh(curr->wb.upper.status_error);
if ((staterr & E1000_RXD_STAT_DD) == 0)
break;
- ring->slot[nm_i].len = le16toh(curr->length);
+ ring->slot[nm_i].len = le16toh(curr->wb.upper.length);
ring->slot[nm_i].flags = slot_flags;
bus_dmamap_sync(rxr->rxtag, rxr->rx_buffers[nic_i].map,
BUS_DMASYNC_POSTREAD);
@@ -271,19 +271,19 @@
uint64_t paddr;
void *addr = PNMB(na, slot, &paddr);
- struct e1000_rx_desc *curr = &rxr->rx_base[nic_i];
- struct em_buffer *rxbuf = &rxr->rx_buffers[nic_i];
+ union e1000_rx_desc_extended *curr = &rxr->rx_base[nic_i];
+ struct em_rxbuffer *rxbuf = &rxr->rx_buffers[nic_i];
if (addr == NETMAP_BUF_BASE(na)) /* bad buf */
goto ring_reset;
if (slot->flags & NS_BUF_CHANGED) {
/* buffer has changed, reload map */
- curr->buffer_addr = htole64(paddr);
+ curr->read.buffer_addr = htole64(paddr);
netmap_reload_map(na, rxr->rxtag, rxbuf->map, addr);
slot->flags &= ~NS_BUF_CHANGED;
}
- curr->status = 0;
+ curr->wb.upper.status_error = 0;
bus_dmamap_sync(rxr->rxtag, rxbuf->map,
BUS_DMASYNC_PREREAD);
nm_i = nm_next(nm_i, lim);
Modified: soc2016/vincenzo/head/sys/dev/netmap/if_lem_netmap.h
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/if_lem_netmap.h Fri Aug 5 15:48:56 2016 (r307250)
+++ soc2016/vincenzo/head/sys/dev/netmap/if_lem_netmap.h Fri Aug 5 16:11:11 2016 (r307251)
@@ -41,7 +41,7 @@
#ifdef WITH_PTNETMAP_GUEST
#include <dev/netmap/netmap_mem2.h>
#endif
-#include <dev/netmap/netmap_virt.h>
+#include <net/netmap_virt.h>
extern int netmap_adaptive_io;
@@ -509,7 +509,7 @@
if (csb == NULL)
return EINVAL;
- ret = lem_ptnetmap_ptctl(ifp, NET_PARAVIRT_PTCTL_CONFIG);
+ ret = lem_ptnetmap_ptctl(ifp, PTNETMAP_PTCTL_CONFIG);
if (ret)
return ret;
@@ -569,7 +569,7 @@
int ret;
if (onoff) {
- ret = lem_ptnetmap_ptctl(ifp, NET_PARAVIRT_PTCTL_REGIF);
+ ret = lem_ptnetmap_ptctl(ifp, PTNETMAP_PTCTL_REGIF);
if (ret)
return ret;
@@ -601,7 +601,7 @@
} else {
na->na_flags &= ~NAF_NETMAP_ON;
adapter->ptnetmap_enabled = 0;
- ret = lem_ptnetmap_ptctl(ifp, NET_PARAVIRT_PTCTL_UNREGIF);
+ ret = lem_ptnetmap_ptctl(ifp, PTNETMAP_PTCTL_UNREGIF);
}
return lem_netmap_reg(na, onoff);
@@ -634,11 +634,11 @@
{
uint32_t features;
/* tell the device the features we support */
- E1000_WRITE_REG(&adapter->hw, E1000_PTFEAT, NET_PTN_FEATURES_BASE);
+ E1000_WRITE_REG(&adapter->hw, E1000_PTFEAT, PTNETMAP_F_BASE);
/* get back the acknowledged features */
features = E1000_READ_REG(&adapter->hw, E1000_PTFEAT);
device_printf(adapter->dev, "ptnetmap support: %s\n",
- (features & NET_PTN_FEATURES_BASE) ? "base" :
+ (features & PTNETMAP_F_BASE) ? "base" :
"none");
return features;
}
@@ -678,7 +678,7 @@
#if defined (NIC_PTNETMAP) && defined (WITH_PTNETMAP_GUEST)
/* XXX: check if the device support ptnetmap (now we use PARA_SUBDEV) */
if ((adapter->hw.subsystem_device_id == E1000_PARA_SUBDEV) &&
- (lem_ptnetmap_features(adapter) & NET_PTN_FEATURES_BASE)) {
+ (lem_ptnetmap_features(adapter) & PTNETMAP_F_BASE)) {
int err;
na.nm_config = lem_ptnetmap_config;
@@ -690,7 +690,7 @@
/* Ask the device to fill in some configuration fields. Here we
* just need nifp_offset. */
- err = lem_ptnetmap_ptctl(na.ifp, NET_PARAVIRT_PTCTL_CONFIG);
+ err = lem_ptnetmap_ptctl(na.ifp, PTNETMAP_PTCTL_CONFIG);
if (err) {
D("Failed to get nifp_offset from passthrough device");
return;
Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri Aug 5 15:48:56 2016 (r307250)
+++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri Aug 5 16:11:11 2016 (r307251)
@@ -29,6 +29,7 @@
#include <sys/cdefs.h>
//__FBSDID("$FreeBSD: releng/10.2/sys/dev/netmap/netmap_ptnet.c xxx $");
+#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -51,6 +52,7 @@
#include <net/ethernet.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_types.h>
@@ -81,7 +83,7 @@
#include <sys/selinfo.h>
#include <net/netmap.h>
#include <dev/netmap/netmap_kern.h>
-#include <dev/netmap/netmap_virt.h>
+#include <net/netmap_virt.h>
#include <dev/netmap/netmap_mem2.h>
#include <dev/virtio/network/virtio_net.h>
@@ -141,7 +143,7 @@
struct ptnet_softc {
device_t dev;
- struct ifnet *ifp;
+ if_t ifp;
struct ifmedia media;
struct mtx lock;
char lock_name[16];
@@ -182,24 +184,25 @@
static int ptnet_shutdown(device_t);
static void ptnet_init(void *opaque);
-static int ptnet_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
+static int ptnet_ioctl(if_t ifp, u_long cmd, caddr_t data);
+static uint64_t ptnet_get_counter(if_t, ift_counter);
static int ptnet_init_locked(struct ptnet_softc *sc);
static int ptnet_stop(struct ptnet_softc *sc);
-static int ptnet_transmit(struct ifnet *ifp, struct mbuf *m);
+static int ptnet_transmit(if_t ifp, struct mbuf *m);
static int ptnet_drain_transmit_queue(struct ptnet_queue *pq,
unsigned int budget,
bool may_resched);
-static void ptnet_qflush(struct ifnet *ifp);
+static void ptnet_qflush(if_t ifp);
static void ptnet_tx_task(void *context, int pending);
-static int ptnet_media_change(struct ifnet *ifp);
-static void ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr);
+static int ptnet_media_change(if_t ifp);
+static void ptnet_media_status(if_t ifp, struct ifmediareq *ifmr);
static void ptnet_tick(void *opaque);
static int ptnet_irqs_init(struct ptnet_softc *sc);
static void ptnet_irqs_fini(struct ptnet_softc *sc);
-static uint32_t ptnet_nm_ptctl(struct ifnet *ifp, uint32_t cmd);
+static uint32_t ptnet_nm_ptctl(if_t ifp, uint32_t cmd);
static int ptnet_nm_config(struct netmap_adapter *na, unsigned *txr,
unsigned *txd, unsigned *rxr, unsigned *rxd);
static void ptnet_update_vnet_hdr(struct ptnet_softc *sc);
@@ -279,12 +282,12 @@
static int
ptnet_attach(device_t dev)
{
- uint32_t ptfeatures = NET_PTN_FEATURES_BASE;
+ uint32_t ptfeatures = PTNETMAP_F_BASE;
unsigned int num_rx_rings, num_tx_rings;
struct netmap_adapter na_arg;
unsigned int nifp_offset;
struct ptnet_softc *sc;
- struct ifnet *ifp;
+ if_t ifp;
uint32_t macreg;
int err, rid;
int i;
@@ -306,11 +309,11 @@
/* Check if we are supported by the hypervisor. If not,
* bail out immediately. */
if (ptnet_vnet_hdr) {
- ptfeatures |= NET_PTN_FEATURES_VNET_HDR;
+ ptfeatures |= PTNETMAP_F_VNET_HDR;
}
bus_write_4(sc->iomem, PTNET_IO_PTFEAT, ptfeatures); /* wanted */
ptfeatures = bus_read_4(sc->iomem, PTNET_IO_PTFEAT); /* acked */
- if (!(ptfeatures & NET_PTN_FEATURES_BASE)) {
+ if (!(ptfeatures & PTNETMAP_F_BASE)) {
device_printf(dev, "Hypervisor does not support netmap "
"passthorugh\n");
err = ENXIO;
@@ -390,11 +393,12 @@
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
- if_initbaudrate(ifp, IF_Gbps(10));
+ ifp->if_baudrate = IF_Gbps(10);
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX;
ifp->if_init = ptnet_init;
ifp->if_ioctl = ptnet_ioctl;
+ ifp->if_get_counter = ptnet_get_counter;
ifp->if_transmit = ptnet_transmit;
ifp->if_qflush = ptnet_qflush;
@@ -414,10 +418,10 @@
ether_ifattach(ifp, sc->hwaddr);
- ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
+ ifp->if_hdrlen = sizeof(struct ether_vlan_header);
ifp->if_capabilities |= IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU;
- if (sc->ptfeatures & NET_PTN_FEATURES_VNET_HDR) {
+ if (sc->ptfeatures & PTNETMAP_F_VNET_HDR) {
/* Similarly to what the vtnet driver does, we can emulate
* VLAN offloadings by inserting and removing the 802.1Q
* header during transmit and receive. We are then able
@@ -720,9 +724,9 @@
}
static int
-ptnet_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
+ptnet_ioctl(if_t ifp, u_long cmd, caddr_t data)
{
- struct ptnet_softc *sc = ifp->if_softc;
+ struct ptnet_softc *sc = if_getsoftc(ifp);
device_t dev = sc->dev;
struct ifreq *ifr = (struct ifreq *)data;
int mask, err = 0;
@@ -815,7 +819,7 @@
static int
ptnet_init_locked(struct ptnet_softc *sc)
{
- struct ifnet *ifp = sc->ifp;
+ if_t ifp = sc->ifp;
struct netmap_adapter *na_dr = &sc->ptna->dr.up;
struct netmap_adapter *na_nm = &sc->ptna->hwup.up;
unsigned int nm_buf_size;
@@ -906,7 +910,7 @@
static int
ptnet_stop(struct ptnet_softc *sc)
{
- struct ifnet *ifp = sc->ifp;
+ if_t ifp = sc->ifp;
struct netmap_adapter *na_dr = &sc->ptna->dr.up;
struct netmap_adapter *na_nm = &sc->ptna->hwup.up;
int i;
@@ -939,9 +943,9 @@
}
static void
-ptnet_qflush(struct ifnet *ifp)
+ptnet_qflush(if_t ifp)
{
- struct ptnet_softc *sc = ifp->if_softc;
+ struct ptnet_softc *sc = if_getsoftc(ifp);
int i;
/* Flush all the bufrings and do the interface flush. */
@@ -962,9 +966,9 @@
}
static int
-ptnet_media_change(struct ifnet *ifp)
+ptnet_media_change(if_t ifp)
{
- struct ptnet_softc *sc = ifp->if_softc;
+ struct ptnet_softc *sc = if_getsoftc(ifp);
struct ifmedia *ifm = &sc->media;
if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) {
@@ -974,12 +978,10 @@
return 0;
}
-/* Called under core lock. */
-static void
-ptnet_tick(void *opaque)
+static uint64_t
+ptnet_get_counter(if_t ifp, ift_counter cnt)
{
- struct ptnet_softc *sc = opaque;
- struct ifnet *ifp = sc->ifp;
+ struct ptnet_softc *sc = if_getsoftc(ifp);
struct ptnet_queue_stats stats[2];
int i;
@@ -996,16 +998,29 @@
stats[idx].mcasts += pq->stats.mcasts;
}
- /* Update interface statistics. */
- ifp->if_opackets = stats[0].packets;
- ifp->if_obytes = stats[0].bytes;
- ifp->if_omcasts = stats[0].mcasts;
- ifp->if_oerrors = stats[0].errors;
- ifp->if_ipackets = stats[1].packets;
- ifp->if_ibytes = stats[1].bytes;
- ifp->if_imcasts = stats[1].mcasts;
- ifp->if_ierrors = stats[1].errors;
- ifp->if_iqdrops = stats[1].iqdrops;
+ switch (cnt) {
+ case IFCOUNTER_IPACKETS:
+ return (stats[1].packets);
+ case IFCOUNTER_IQDROPS:
+ return (stats[1].iqdrops);
+ case IFCOUNTER_IERRORS:
+ return (stats[1].errors);
+ case IFCOUNTER_OPACKETS:
+ return (stats[0].packets);
+ case IFCOUNTER_OBYTES:
+ return (stats[0].bytes);
+ case IFCOUNTER_OMCASTS:
+ return (stats[0].mcasts);
+ default:
+ return (if_get_counter_default(ifp, cnt));
+ }
+}
+
+/* Called under core lock. */
+static void
+ptnet_tick(void *opaque)
+{
+ struct ptnet_softc *sc = opaque;
#ifdef PTNETMAP_STATS
for (i = 0; i < sc->num_rings; i++) {
@@ -1036,7 +1051,7 @@
}
static void
-ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+ptnet_media_status(if_t ifp, struct ifmediareq *ifmr)
{
/* We are always active, as the backend netmap port is
* always open in netmap mode. */
@@ -1045,9 +1060,9 @@
}
static uint32_t
-ptnet_nm_ptctl(struct ifnet *ifp, uint32_t cmd)
+ptnet_nm_ptctl(if_t ifp, uint32_t cmd)
{
- struct ptnet_softc *sc = ifp->if_softc;
+ struct ptnet_softc *sc = if_getsoftc(ifp);
int ret;
bus_write_4(sc->iomem, PTNET_IO_PTCTL, cmd);
@@ -1118,8 +1133,8 @@
ptnet_nm_register(struct netmap_adapter *na, int onoff)
{
/* device-specific */
- struct ifnet *ifp = na->ifp;
- struct ptnet_softc *sc = ifp->if_softc;
+ if_t ifp = na->ifp;
+ struct ptnet_softc *sc = if_getsoftc(ifp);
int native = (na == &sc->ptna->hwup.up);
struct ptnet_queue *pq;
enum txrx t;
@@ -1160,7 +1175,7 @@
/* Make sure the host adapter passed through is ready
* for txsync/rxsync. */
- ret = ptnet_nm_ptctl(ifp, NET_PARAVIRT_PTCTL_REGIF);
+ ret = ptnet_nm_ptctl(ifp, PTNETMAP_PTCTL_REGIF);
if (ret) {
return ret;
}
@@ -1210,7 +1225,7 @@
}
if (sc->ptna->backend_regifs == 0) {
- ret = ptnet_nm_ptctl(ifp, NET_PARAVIRT_PTCTL_UNREGIF);
+ ret = ptnet_nm_ptctl(ifp, PTNETMAP_PTCTL_UNREGIF);
}
}
@@ -1352,7 +1367,7 @@
}
static int
-ptnet_tx_offload_tso(struct ifnet *ifp, struct mbuf *m, int eth_type,
+ptnet_tx_offload_tso(if_t ifp, struct mbuf *m, int eth_type,
int offset, bool allow_ecn, struct virtio_net_hdr *hdr)
{
static struct timeval lastecn;
@@ -1391,7 +1406,7 @@
}
static struct mbuf *
-ptnet_tx_offload(struct ifnet *ifp, struct mbuf *m, bool allow_ecn,
+ptnet_tx_offload(if_t ifp, struct mbuf *m, bool allow_ecn,
struct virtio_net_hdr *hdr)
{
int flags, etype, csum_start, proto, error;
@@ -1662,7 +1677,7 @@
struct ptnet_softc *sc = pq->sc;
bool have_vnet_hdr = sc->vnet_hdr_len;
struct netmap_adapter *na = &sc->ptna->dr.up;
- struct ifnet *ifp = sc->ifp;
+ if_t ifp = sc->ifp;
unsigned int batch_count = 0;
struct ptnet_ring *ptring;
struct netmap_kring *kring;
@@ -1846,9 +1861,9 @@
}
static int
-ptnet_transmit(struct ifnet *ifp, struct mbuf *m)
+ptnet_transmit(if_t ifp, struct mbuf *m)
{
- struct ptnet_softc *sc = ifp->if_softc;
+ struct ptnet_softc *sc = if_getsoftc(ifp);
struct ptnet_queue *pq;
unsigned int queue_idx;
int err;
@@ -1961,7 +1976,7 @@
unsigned int const lim = kring->nkr_num_slots - 1;
unsigned int head = ring->head;
unsigned int batch_count = 0;
- struct ifnet *ifp = sc->ifp;
+ if_t ifp = sc->ifp;
unsigned int count = 0;
PTNET_Q_LOCK(pq);
@@ -2190,9 +2205,9 @@
/* We don't need to handle differently POLL_AND_CHECK_STATUS and
* POLL_ONLY, since we don't have an Interrupt Status Register. */
static int
-ptnet_poll(struct ifnet *ifp, enum poll_cmd cmd, int budget)
+ptnet_poll(if_t ifp, enum poll_cmd cmd, int budget)
{
- struct ptnet_softc *sc = ifp->if_softc;
+ struct ptnet_softc *sc = if_getsoftc(ifp);
unsigned int queue_budget;
unsigned int count = 0;
bool borrow = false;
Modified: soc2016/vincenzo/head/sys/dev/netmap/if_vtnet_netmap.h
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/if_vtnet_netmap.h Fri Aug 5 15:48:56 2016 (r307250)
+++ soc2016/vincenzo/head/sys/dev/netmap/if_vtnet_netmap.h Fri Aug 5 16:11:11 2016 (r307251)
@@ -33,7 +33,7 @@
#include <vm/pmap.h> /* vtophys ? */
#include <dev/netmap/netmap_kern.h>
#ifdef WITH_PTNETMAP_GUEST
-#include <dev/netmap/netmap_virt.h>
+#include <net/netmap_virt.h>
#include <dev/netmap/netmap_mem2.h>
static int vtnet_ptnetmap_txsync(struct netmap_kring *kring, int flags);
#define VTNET_PTNETMAP_ON(_na) \
@@ -477,7 +477,7 @@
vm_paddr_t csb_phyaddr;
- csb = contigmalloc(NET_PARAVIRT_CSB_SIZE, M_DEVBUF,
+ csb = contigmalloc(NETMAP_VIRT_CSB_SIZE, M_DEVBUF,
M_NOWAIT | M_ZERO, (size_t)0, -1UL, PAGE_SIZE, 0);
if (!csb) {
D("Communication Status Block allocation failed!");
@@ -513,7 +513,7 @@
vtnet_ptnetmap_iowrite4(dev, PTNETMAP_VIRTIO_IO_CSBBAH, 0x0ULL);
vtnet_ptnetmap_iowrite4(dev, PTNETMAP_VIRTIO_IO_CSBBAL, 0x0ULL);
- contigfree(ptna->csb, NET_PARAVIRT_CSB_SIZE, M_DEVBUF);
+ contigfree(ptna->csb, NETMAP_VIRT_CSB_SIZE, M_DEVBUF);
ptna->csb = NULL;
}
}
@@ -538,7 +538,7 @@
if (csb == NULL)
return EINVAL;
- ret = vtnet_ptnetmap_ptctl(na->ifp, NET_PARAVIRT_PTCTL_CONFIG);
+ ret = vtnet_ptnetmap_ptctl(na->ifp, PTNETMAP_PTCTL_CONFIG);
if (ret)
return ret;
@@ -642,7 +642,7 @@
ret = vtnet_txq_encap(txq, &m0);
}
}
- ret = vtnet_ptnetmap_ptctl(na->ifp, NET_PARAVIRT_PTCTL_REGIF);
+ ret = vtnet_ptnetmap_ptctl(na->ifp, PTNETMAP_PTCTL_REGIF);
if (ret) {
//na->na_flags &= ~NAF_NETMAP_ON;
nm_clear_native_flags(na);
@@ -674,7 +674,7 @@
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
//na->na_flags &= ~NAF_NETMAP_ON;
nm_clear_native_flags(na);
- ret = vtnet_ptnetmap_ptctl(na->ifp, NET_PARAVIRT_PTCTL_UNREGIF);
+ ret = vtnet_ptnetmap_ptctl(na->ifp, PTNETMAP_PTCTL_UNREGIF);
vtnet_init_locked(sc); /* also enable intr */
}
out:
@@ -719,11 +719,11 @@
uint32_t features;
/* tell the device the features we support */
vtnet_ptnetmap_iowrite4(dev, PTNETMAP_VIRTIO_IO_PTFEAT,
- NET_PTN_FEATURES_BASE);
+ PTNETMAP_F_BASE);
/* get back the acknowledged features */
features = vtnet_ptnetmap_ioread4(dev, PTNETMAP_VIRTIO_IO_PTFEAT);
D("ptnetmap support: %s\n",
- (features & NET_PTN_FEATURES_BASE) ? "base" :
+ (features & PTNETMAP_F_BASE) ? "base" :
"none");
return features;
}
@@ -759,7 +759,7 @@
#ifdef WITH_PTNETMAP_GUEST
/* check if virtio-net (guest and host) supports ptnetmap */
if (virtio_with_feature(sc->vtnet_dev, VIRTIO_NET_F_PTNETMAP) &&
- (vtnet_ptnetmap_features(sc) & NET_PTN_FEATURES_BASE)) {
+ (vtnet_ptnetmap_features(sc) & PTNETMAP_F_BASE)) {
struct paravirt_csb *csb;
int err;
@@ -778,7 +778,7 @@
/* Ask the device to fill in some configuration fields. Here we
* just need nifp_offset. */
- err = vtnet_ptnetmap_ptctl(na.ifp, NET_PARAVIRT_PTCTL_CONFIG);
+ err = vtnet_ptnetmap_ptctl(na.ifp, PTNETMAP_PTCTL_CONFIG);
if (err) {
D("Failed to get nifp_offset from passthrough device");
return;
Modified: soc2016/vincenzo/head/sys/dev/netmap/ixgbe_netmap.h
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/ixgbe_netmap.h Fri Aug 5 15:48:56 2016 (r307250)
+++ soc2016/vincenzo/head/sys/dev/netmap/ixgbe_netmap.h Fri Aug 5 16:11:11 2016 (r307251)
@@ -48,6 +48,7 @@
*/
#include <dev/netmap/netmap_kern.h>
+void ixgbe_netmap_attach(struct adapter *adapter);
/*
* device-specific sysctl variables:
@@ -134,20 +135,19 @@
struct adapter *adapter = ifp->if_softc;
IXGBE_CORE_LOCK(adapter);
- ixgbe_disable_intr(adapter); // XXX maybe ixgbe_stop ?
+ adapter->stop_locked(adapter);
- /* Tell the stack that the interface is no longer active */
- ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
-
- set_crcstrip(&adapter->hw, onoff);
+ if (!IXGBE_IS_VF(adapter))
+ set_crcstrip(&adapter->hw, onoff);
/* enable or disable flags and callbacks in na and ifp */
if (onoff) {
nm_set_native_flags(na);
} else {
nm_clear_native_flags(na);
}
- ixgbe_init_locked(adapter); /* also enables intr */
- set_crcstrip(&adapter->hw, onoff); // XXX why twice ?
+ adapter->init_locked(adapter); /* also enables intr */
+ if (!IXGBE_IS_VF(adapter))
+ set_crcstrip(&adapter->hw, onoff); // XXX why twice ?
IXGBE_CORE_UNLOCK(adapter);
return (ifp->if_drv_flags & IFF_DRV_RUNNING ? 0 : 1);
}
@@ -280,7 +280,7 @@
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
/* (re)start the tx unit up to slot nic_i (excluded) */
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_TDT(txr->me), nic_i);
+ IXGBE_WRITE_REG(&adapter->hw, txr->tail, nic_i);
}
/*
@@ -324,7 +324,8 @@
* REPORT_STATUS in a few slots so TDH is the only
* good way.
*/
- nic_i = IXGBE_READ_REG(&adapter->hw, IXGBE_TDH(kring->ring_id));
+ nic_i = IXGBE_READ_REG(&adapter->hw, IXGBE_IS_VF(adapter) ?
+ IXGBE_VFTDH(kring->ring_id) : IXGBE_TDH(kring->ring_id));
if (nic_i >= kring->nkr_num_slots) { /* XXX can it happen ? */
D("TDH wrap %d", nic_i);
nic_i -= kring->nkr_num_slots;
@@ -393,7 +394,7 @@
* rxr->next_to_check is set to 0 on a ring reinit
*/
if (netmap_no_pendintr || force_update) {
- int crclen = ix_crcstrip ? 0 : 4;
+ int crclen = (ix_crcstrip || IXGBE_IS_VF(adapter)) ? 0 : 4;
uint16_t slot_flags = kring->nkr_slot_flags;
nic_i = rxr->next_to_check; // or also k2n(kring->nr_hwtail)
@@ -467,7 +468,7 @@
* so move nic_i back by one unit
*/
nic_i = nm_prev(nic_i, lim);
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_RDT(rxr->me), nic_i);
+ IXGBE_WRITE_REG(&adapter->hw, rxr->tail, nic_i);
}
return 0;
@@ -484,7 +485,7 @@
* netmap mode will be disabled and the driver will only
* operate in standard mode.
*/
-static void
+void
ixgbe_netmap_attach(struct adapter *adapter)
{
struct netmap_adapter na;
Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap.c
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/netmap.c Fri Aug 5 15:48:56 2016 (r307250)
+++ soc2016/vincenzo/head/sys/dev/netmap/netmap.c Fri Aug 5 16:11:11 2016 (r307251)
@@ -185,7 +185,7 @@
* This is a persistent or ephemeral VALE port. Ephemeral ports
* are created on the fly if they don't already exist, and are
* always attached to a bridge.
- * Persistent VALE ports must must be created seperately, and i
+ * Persistent VALE ports must must be created separately, and i
* then attached like normal NICs. The NIOCREGIF we are examining
* will find them only if they had previosly been created and
* attached (see VALE_CTL below).
@@ -599,8 +599,8 @@
/*
* Convenience function used in drivers. Waits for current txsync()s/rxsync()s
* to finish and prevents any new one from starting. Call this before turning
- * netmap mode off, or before removing the harware rings (e.g., on module
- * onload).
+ * netmap mode off, or before removing the hardware rings (e.g., on module
+ * onload).
*/
void
netmap_disable_all_rings(struct ifnet *ifp)
@@ -634,6 +634,18 @@
}
}
+void
+netmap_undo_zombie(struct ifnet *ifp)
+{
+ if (NM_NA_VALID(ifp)) {
+ struct netmap_adapter *na = NA(ifp);
+ if (na->na_flags & NAF_ZOMBIE) {
+ netmap_set_all_rings(na, NM_KR_LOCKED);
+ na->na_flags &= ~NAF_ZOMBIE;
+ netmap_set_all_rings(na, 0);
+ }
+ }
+}
/*
* generic bound_checking function
@@ -829,7 +841,7 @@
* IMPORTANT: Always keep one slot empty.
*/
kring->rtail = kring->nr_hwtail = (t == NR_TX ? ndesc - 1 : 0);
- snprintf(kring->name, sizeof(kring->name) - 1, "%s %s%d", na->name,
+ snprintf(kring->name, sizeof(kring->name) - 1, "%s %s%d", na->name,
nm_txrx2str(t), i);
ND("ktx %s h %d c %d t %d",
kring->name, kring->rhead, kring->rcur, kring->rtail);
@@ -918,6 +930,9 @@
na->nm_register(na, 0);
}
+ /* delete rings and buffers that are no longer needed */
+ netmap_mem_rings_delete(na);
+
if (na->active_fds <= 0) { /* last instance */
/*
* (TO CHECK) We enter here
@@ -936,8 +951,10 @@
if (netmap_verbose)
D("deleting last instance for %s", na->name);
- /* delete rings and buffers */
- netmap_mem_rings_delete(na);
+ if (nm_netmap_on(na)) {
+ D("BUG: netmap on while going to delete the krings");
+ }
+
na->nm_krings_delete(na);
}
@@ -1392,7 +1409,7 @@
NMG_LOCK_ASSERT();
- /* we cascade through all possibile types of netmap adapter.
+ /* We cascade through all possible types of netmap adapter.
* All netmap_get_*_na() functions return an error and an na,
* with the following combinations:
*
@@ -1692,6 +1709,13 @@
}
D("deprecated API, old ringid 0x%x -> ringid %x reg %d", ringid, i, reg);
}
+
+ if ((flags & NR_PTNETMAP_HOST) && (reg != NR_REG_ALL_NIC ||
+ flags & (NR_RX_RINGS_ONLY|NR_TX_RINGS_ONLY))) {
+ D("Error: only NR_REG_ALL_NIC supported with netmap passthrough");
+ return EINVAL;
+ }
+
for_rx_tx(t) {
if (flags & excluded_direction[t]) {
priv->np_qfirst[t] = priv->np_qlast[t] = 0;
@@ -1939,7 +1963,7 @@
*
* * netmap_pipe_reg (pipes)
* inform the other pipe end that it is no
- * longer responsibile for the lifetime of this
+ * longer responsible for the lifetime of this
* pipe end
*
* * netmap_monitor_reg (monitors)
@@ -1975,7 +1999,7 @@
if (na->active_fds == 0) {
/*
* If this is the first registration of the adapter,
- * also create the netmap rings and their in-kernel view,
+ * create the in-kernel view of the netmap rings,
* the netmap krings.
*/
@@ -1987,25 +2011,26 @@
if (error)
goto err_drop_mem;
- /* create all missing netmap rings */
- error = netmap_mem_rings_create(na);
- if (error)
- goto err_del_krings;
}
- /* now the kring must exist and we can check whether some
+ /* now the krings must exist and we can check whether some
* previous bind has exclusive ownership on them, and set
* nr_pending_mode
*/
error = netmap_krings_get(priv);
if (error)
- goto err_del_rings;
+ goto err_del_krings;
+
+ /* create all needed missing netmap rings */
+ error = netmap_mem_rings_create(na);
+ if (error)
+ goto err_rel_excl;
/* in all cases, create a new netmap if */
nifp = netmap_mem_if_new(na);
if (nifp == NULL) {
error = ENOMEM;
- goto err_rel_excl;
+ goto err_del_rings;
}
if (na->active_fds == 0) {
@@ -2013,7 +2038,7 @@
error = netmap_mem_get_lut(na->nm_mem, &na->na_lut);
if (error)
goto err_del_if;
- D("lut %p bufs %u size %u", na->na_lut.lut, na->na_lut.objtotal,
+ ND("lut %p bufs %u size %u", na->na_lut.lut, na->na_lut.objtotal,
na->na_lut.objsize);
}
@@ -2021,7 +2046,7 @@
/* Some kring is switching mode, tell the adapter to
* react on this. */
error = na->nm_register(na, 1);
- if (error)
+ if (error)
goto err_put_lut;
}
@@ -2046,8 +2071,7 @@
err_rel_excl:
netmap_krings_put(priv);
err_del_rings:
- if (na->active_fds == 0)
- netmap_mem_rings_delete(na);
+ netmap_mem_rings_delete(na);
err_del_krings:
if (na->active_fds == 0)
na->nm_krings_delete(na);
@@ -2245,10 +2269,12 @@
}
if (nmr->nr_arg3) {
- D("requested %d extra buffers", nmr->nr_arg3);
+ if (netmap_verbose)
+ D("requested %d extra buffers", nmr->nr_arg3);
nmr->nr_arg3 = netmap_extra_alloc(na,
&nifp->ni_bufs_head, nmr->nr_arg3);
- D("got %d extra buffers", nmr->nr_arg3);
+ if (netmap_verbose)
+ D("got %d extra buffers", nmr->nr_arg3);
}
nmr->nr_offset = netmap_mem_if_offset(na->nm_mem, nifp);
@@ -3009,6 +3035,11 @@
goto done;
}
+ if (nm_os_mbuf_has_offld(m)) {
+ D("%s drop mbuf requiring offloadings", na->name);
+ goto done;
+ }
+
/* protect against rxsync_from_host(), netmap_sw_to_nic()
* and maybe other instances of netmap_transmit (the latter
* not possible on Linux).
Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_freebsd.c
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/netmap_freebsd.c Fri Aug 5 15:48:56 2016 (r307250)
+++ soc2016/vincenzo/head/sys/dev/netmap/netmap_freebsd.c Fri Aug 5 16:11:11 2016 (r307251)
@@ -67,8 +67,8 @@
#include <net/netmap.h>
#include <dev/netmap/netmap_kern.h>
+#include <net/netmap_virt.h>
#include <dev/netmap/netmap_mem2.h>
-#include <dev/netmap/netmap_virt.h>
/* ======================== FREEBSD-SPECIFIC ROUTINES ================== */
@@ -116,16 +116,27 @@
}
static void
+netmap_ifnet_arrival_handler(void *arg __unused, struct ifnet *ifp)
+{
+ netmap_undo_zombie(ifp);
+}
+
+static void
netmap_ifnet_departure_handler(void *arg __unused, struct ifnet *ifp)
{
netmap_make_zombie(ifp);
}
+static eventhandler_tag nm_ifnet_ah_tag;
static eventhandler_tag nm_ifnet_dh_tag;
int
nm_os_ifnet_init(void)
{
+ nm_ifnet_ah_tag =
+ EVENTHANDLER_REGISTER(ifnet_arrival_event,
+ netmap_ifnet_arrival_handler,
+ NULL, EVENTHANDLER_PRI_ANY);
nm_ifnet_dh_tag =
EVENTHANDLER_REGISTER(ifnet_departure_event,
netmap_ifnet_departure_handler,
@@ -136,6 +147,8 @@
void
nm_os_ifnet_fini(void)
{
+ EVENTHANDLER_DEREGISTER(ifnet_arrival_event,
+ nm_ifnet_ah_tag);
EVENTHANDLER_DEREGISTER(ifnet_departure_event,
nm_ifnet_dh_tag);
}
@@ -227,6 +240,14 @@
return NULL;
}
+int
+nm_os_mbuf_has_offld(struct mbuf *m)
+{
+ return m->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP | CSUM_SCTP |
+ CSUM_TCP_IPV6 | CSUM_UDP_IPV6 |
+ CSUM_SCTP_IPV6 | CSUM_TSO);
+}
+
static void
freebsd_generic_rx_handler(struct ifnet *ifp, struct mbuf *m)
{
@@ -590,7 +611,7 @@
};
static driver_t ptn_memdev_driver = {
- PTN_MEMDEV_NAME,
+ PTNETMAP_MEMDEV_NAME,
ptn_memdev_methods,
sizeof(struct ptnetmap_memdev),
};
@@ -676,7 +697,7 @@
return (ENXIO);
snprintf(desc, sizeof(desc), "%s PCI adapter",
- PTN_MEMDEV_NAME);
+ PTNETMAP_MEMDEV_NAME);
device_set_desc_copy(dev, desc);
return (BUS_PROBE_DEFAULT);
Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_generic.c
==============================================================================
--- soc2016/vincenzo/head/sys/dev/netmap/netmap_generic.c Fri Aug 5 15:48:56 2016 (r307250)
+++ soc2016/vincenzo/head/sys/dev/netmap/netmap_generic.c Fri Aug 5 16:11:11 2016 (r307251)
@@ -92,7 +92,7 @@
*
* We allocate EXT_PACKET mbuf+clusters, but need to set M_NOFREE
* so that the destructor, if invoked, will not free the packet.
- * In principle we should set the destructor only on demand,
+ * In principle we should set the destructor only on demand,
* but since there might be a race we better do it on allocation.
* As a consequence, we also need to set the destructor or we
* would leak buffers.
@@ -131,8 +131,12 @@
struct mbuf *m;
(void)ifp;
- m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR | M_NOFREE);
+ m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m) {
+ /* m_getcl() (mb_ctor_mbuf) has an assert that checks that
+ * M_NOFREE flag is not specified as third argument,
+ * so we have to set M_NOFREE after m_getcl(). */
+ m->m_flags |= M_NOFREE;
m->m_ext.ext_arg1 = m->m_ext.ext_buf; // XXX save
m->m_ext.ext_free = (void *)netmap_default_mbuf_destructor;
m->m_ext.ext_type = EXT_EXTREF;
@@ -159,6 +163,13 @@
#include <linux/ethtool.h> /* struct ethtool_ops, get_ringparam */
#include <linux/hrtimer.h>
+static inline struct mbuf *
+nm_os_get_mbuf(struct ifnet *ifp, int len)
+{
+ return alloc_skb(ifp->needed_headroom + len +
+ ifp->needed_tailroom, GFP_ATOMIC);
+}
+
#endif /* linux */
@@ -168,13 +179,18 @@
#include <dev/netmap/netmap_mem2.h>
-#define for_each_tx_kring(_i, _k, _na) \
- for (_k=&(_na)->tx_rings[0], _i = 0; \
- _i < (_na)->num_tx_rings; (_k)++, (_i)++)
-
-#define for_each_rx_kring(_i, _k, _na) \
- for (_k=&(_na)->rx_rings[0], _i = 0; \
- _i < (_na)->num_rx_rings; (_k)++, (_i)++)
+#define for_each_kring_n(_i, _k, _karr, _n) \
+ for (_k=_karr, _i = 0; _i < _n; (_k)++, (_i)++)
+
+#define for_each_tx_kring(_i, _k, _na) \
+ for_each_kring_n(_i, _k, (_na)->tx_rings, (_na)->num_tx_rings)
+#define for_each_tx_kring_h(_i, _k, _na) \
+ for_each_kring_n(_i, _k, (_na)->tx_rings, (_na)->num_tx_rings + 1)
+
+#define for_each_rx_kring(_i, _k, _na) \
+ for_each_kring_n(_i, _k, (_na)->rx_rings, (_na)->num_rx_rings)
+#define for_each_rx_kring_h(_i, _k, _na) \
+ for_each_kring_n(_i, _k, (_na)->rx_rings, (_na)->num_rx_rings + 1)
/* ======================== PERFORMANCE STATISTICS =========================== */
@@ -286,18 +302,25 @@
rtnl_unlock();
}
- for_each_rx_kring(r, kring, na) {
- if (!nm_kring_pending_off(kring)) {
- continue;
+ for_each_rx_kring_h(r, kring, na) {
+ if (nm_kring_pending_off(kring)) {
+ D("RX ring %d of generic adapter %p goes off", r, na);
+ kring->nr_mode = NKR_NETMAP_OFF;
+ }
+ }
+ for_each_tx_kring_h(r, kring, na) {
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-soc-all
mailing list