From 310b705cf093957e1744a6c042b1b7ac796cc591 Mon Sep 17 00:00:00 2001 From: jmatthew Date: Thu, 11 Jun 2015 12:30:42 +0000 Subject: [PATCH] convert sc_sendq into an mbuf_list, and use ph_cookie rather than rcvif to store the sgl address, allowing rcvif to be removed. ok mpi@ dlg@ uebayasi@ --- sys/arch/octeon/dev/if_cnmac.c | 45 +++++++------------------------ sys/arch/octeon/dev/if_cnmacvar.h | 5 ++-- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/sys/arch/octeon/dev/if_cnmac.c b/sys/arch/octeon/dev/if_cnmac.c index 080c19787f0..ec5520aa963 100644 --- a/sys/arch/octeon/dev/if_cnmac.c +++ b/sys/arch/octeon/dev/if_cnmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cnmac.c,v 1.22 2015/04/30 21:52:49 mpi Exp $ */ +/* $OpenBSD: if_cnmac.c,v 1.23 2015/06/11 12:30:42 jmatthew Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -292,7 +292,7 @@ octeon_eth_attach(struct device *parent, struct device *self, void *aux) octeon_eth_gsc[sc->sc_port] = sc; - SIMPLEQ_INIT(&sc->sc_sendq); + ml_init(&sc->sc_sendq); sc->sc_soft_req_thresh = 15/* XXX */; sc->sc_ext_callback_cnt = 0; @@ -642,37 +642,14 @@ octeon_eth_send_queue_is_full(struct octeon_eth_softc *sc) return 0; } -/* - * (Ab)use m_nextpkt and m_paddr to maintain mbuf chain and pointer to gather - * buffer. Other mbuf members may be used by m_freem(), so don't touch them! - */ - -struct _send_queue_entry { - union { - struct mbuf _sqe_s_mbuf; - struct { - char _sqe_s_entry_pad[offsetof(struct mbuf, m_nextpkt)]; - SIMPLEQ_ENTRY(_send_queue_entry) _sqe_s_entry_entry; - } _sqe_s_entry; - struct { - char _sqe_s_gbuf_pad[offsetof(struct mbuf, M_dat.MH.MH_pkthdr.rcvif)]; - uint64_t *_sqe_s_gbuf_gbuf; - } _sqe_s_gbuf; - } _sqe_u; -#define _sqe_entry _sqe_u._sqe_s_entry._sqe_s_entry_entry -#define _sqe_gbuf _sqe_u._sqe_s_gbuf._sqe_s_gbuf_gbuf -}; - void octeon_eth_send_queue_add(struct octeon_eth_softc *sc, struct mbuf *m, uint64_t *gbuf) { - struct _send_queue_entry *sqe = (struct _send_queue_entry *)m; - OCTEON_ETH_KASSERT(m->m_flags & M_PKTHDR); - sqe->_sqe_gbuf = gbuf; - SIMPLEQ_INSERT_TAIL(&sc->sc_sendq, sqe, _sqe_entry); + m->m_pkthdr.ph_cookie = gbuf; + ml_enqueue(&sc->sc_sendq, m); if (m->m_ext.ext_free != NULL) sc->sc_ext_callback_cnt++; @@ -682,16 +659,14 @@ void octeon_eth_send_queue_del(struct octeon_eth_softc *sc, struct mbuf **rm, uint64_t **rgbuf) { - struct _send_queue_entry *sqe; - - sqe = SIMPLEQ_FIRST(&sc->sc_sendq); - OCTEON_ETH_KASSERT(sqe != NULL); - SIMPLEQ_REMOVE_HEAD(&sc->sc_sendq, _sqe_entry); + struct mbuf *m; + m = ml_dequeue(&sc->sc_sendq); + OCTEON_ETH_KASSERT(m != NULL); - *rm = (void *)sqe; - *rgbuf = sqe->_sqe_gbuf; + *rm = m; + *rgbuf = m->m_pkthdr.ph_cookie; - if ((*rm)->m_ext.ext_free != NULL) { + if (m->m_ext.ext_free != NULL) { sc->sc_ext_callback_cnt--; OCTEON_ETH_KASSERT(sc->sc_ext_callback_cnt >= 0); } diff --git a/sys/arch/octeon/dev/if_cnmacvar.h b/sys/arch/octeon/dev/if_cnmacvar.h index 4aa3bf49ecd..464aef225e7 100644 --- a/sys/arch/octeon/dev/if_cnmacvar.h +++ b/sys/arch/octeon/dev/if_cnmacvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cnmacvar.h,v 1.5 2014/08/11 18:29:56 miod Exp $ */ +/* $OpenBSD: if_cnmacvar.h,v 1.6 2015/06/11 12:30:42 jmatthew Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -81,8 +81,7 @@ struct octeon_eth_softc { int64_t sc_hard_done_cnt; int sc_flush; int sc_prefetch; - SIMPLEQ_HEAD(, _send_queue_entry) - sc_sendq; + struct mbuf_list sc_sendq; uint64_t sc_ext_callback_cnt; uint32_t sc_port; -- 2.20.1