Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Get this driver into a functional state.
details: https://anonhg.NetBSD.org/src/rev/c8886c9de5bf
branches: trunk
changeset: 994975:c8886c9de5bf
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Nov 30 14:07:30 2018 +0000
description:
Get this driver into a functional state.
diffstat:
sys/dev/pci/if_ena.c | 12 +++----
sys/dev/pci/if_enavar.h | 72 +++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 69 insertions(+), 15 deletions(-)
diffs (156 lines):
diff -r c6a2ad58758c -r c8886c9de5bf sys/dev/pci/if_ena.c
--- a/sys/dev/pci/if_ena.c Fri Nov 30 11:37:11 2018 +0000
+++ b/sys/dev/pci/if_ena.c Fri Nov 30 14:07:30 2018 +0000
@@ -31,7 +31,7 @@
#if 0
__FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
#endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.10 2018/11/30 11:37:11 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.11 2018/11/30 14:07:30 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1670,9 +1670,7 @@
uint16_t next_to_clean;
uint32_t refill_required;
uint32_t refill_threshold;
-#ifdef LRO
uint32_t do_if_input = 0;
-#endif
unsigned int qid;
int rc, i;
int budget = RX_BUDGET;
@@ -1735,12 +1733,12 @@
counter_u64_add_protected(adapter->hw_stats.rx_bytes,
mbuf->m_pkthdr.len);
counter_exit();
-#ifdef LRO
/*
* LRO is only for IP/TCP packets and TCP checksum of the packet
* should be computed by hardware.
*/
do_if_input = 1;
+#ifdef LRO
if (((ifp->if_capenable & IFCAP_LRO) != 0) &&
((mbuf->m_pkthdr.csum_flags & CSUM_IP_VALID) != 0) &&
(ena_rx_ctx.l4_proto == ENA_ETH_IO_L4_PROTO_TCP)) {
@@ -1754,12 +1752,12 @@
(tcp_lro_rx(&rx_ring->lro, mbuf, 0) == 0))
do_if_input = 0;
}
+#endif
if (do_if_input != 0) {
ena_trace(ENA_DBG | ENA_RXPTH,
"calling if_input() with mbuf %p", mbuf);
- (*ifp->if_input)(ifp, mbuf);
+ if_percpuq_enqueue(ifp->if_percpuq, mbuf);
}
-#endif
counter_enter();
counter_u64_add_protected(rx_ring->rx_stats.cnt, 1);
@@ -2500,7 +2498,7 @@
ena_trace(ENA_ALERT, "can not allocate ifnet structure\n");
return (ENXIO);
}
- if_initname(ifp, device_xname(pdev), device_unit(pdev));
+ if_initname(ifp, "ena", device_unit(pdev));
if_setdev(ifp, pdev);
if_setsoftc(ifp, adapter);
diff -r c6a2ad58758c -r c8886c9de5bf sys/dev/pci/if_enavar.h
--- a/sys/dev/pci/if_enavar.h Fri Nov 30 11:37:11 2018 +0000
+++ b/sys/dev/pci/if_enavar.h Fri Nov 30 14:07:30 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_enavar.h,v 1.5 2018/11/28 19:06:54 jmcneill Exp $ */
+/* $NetBSD: if_enavar.h,v 1.6 2018/11/30 14:07:30 jmcneill Exp $ */
/*-
* BSD LICENSE
@@ -273,6 +273,7 @@
struct workqueue *cmpl_tq;
};
};
+ u_int task_pending;
union {
struct ena_stats_tx tx_stats;
@@ -472,16 +473,71 @@
*/
#define buf_ring_alloc(a, b, c, d) (void *)&a
#define drbr_free(ifp, b) do { } while (0)
-#define drbr_flush(ifp, b) do { } while (0)
-#define drbr_advance(ifp, b) do { } while (0)
+#define drbr_flush(ifp, b) IFQ_PURGE(&(ifp)->if_snd)
+#define drbr_advance(ifp, b) \
+ ({ \
+ struct mbuf *__m; \
+ IFQ_DEQUEUE(&(ifp)->if_snd, __m); \
+ __m; \
+ })
#define drbr_putback(ifp, b, m) do { } while (0)
-#define drbr_empty(ifp, b) false
-#define drbr_peek(ifp, b) NULL
-#define drbr_enqueue(ifp, b, m) 0
+#define drbr_empty(ifp, b) IFQ_IS_EMPTY(&(ifp)->if_snd)
+#define drbr_peek(ifp, b) \
+ ({ \
+ struct mbuf *__m; \
+ IFQ_POLL(&(ifp)->if_snd, __m); \
+ __m; \
+ })
+#define drbr_enqueue(ifp, b, m) \
+ ({ \
+ int __err; \
+ IFQ_ENQUEUE(&(ifp)->if_snd, m, __err); \
+ __err; \
+ })
#define m_getjcl(a, b, c, d) NULL
#define MJUM16BYTES MCLBYTES
-#define m_append(m, len, cp) 0
-#define m_collapse(m, how, maxfrags) NULL
+#define m_append(m, len, cp) ena_m_append(m, len, cp)
+#define m_collapse(m, how, maxfrags) m_defrag(m, how) /* XXX */
/* XXX XXX XXX */
+static inline int
+ena_m_append(struct mbuf *m0, int len, const void *cpv)
+{
+ struct mbuf *m, *n;
+ int remainder, space;
+ const char *cp = cpv;
+
+ KASSERT(len != M_COPYALL);
+ for (m = m0; m->m_next != NULL; m = m->m_next)
+ continue;
+ remainder = len;
+ space = M_TRAILINGSPACE(m);
+ if (space > 0) {
+ /*
+ * Copy into available space.
+ */
+ if (space > remainder)
+ space = remainder;
+ memmove(mtod(m, char *) + m->m_len, cp, space);
+ m->m_len += space;
+ cp = cp + space, remainder -= space;
+ }
+ while (remainder > 0) {
+ /*
+ * Allocate a new mbuf; could check space
+ * and allocate a cluster instead.
+ */
+ n = m_get(M_DONTWAIT, m->m_type);
+ if (n == NULL)
+ break;
+ n->m_len = uimin(MLEN, remainder);
+ memmove(mtod(n, void *), cp, n->m_len);
+ cp += n->m_len, remainder -= n->m_len;
+ m->m_next = n;
+ m = n;
+ }
+ if (m0->m_flags & M_PKTHDR)
+ m0->m_pkthdr.len += len - remainder;
+ return (remainder == 0);
+}
#endif /* !(ENA_H) */
Home |
Main Index |
Thread Index |
Old Index