From owner-svn-src-head@FreeBSD.ORG Thu Sep 9 02:52:44 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 82D9C106564A; Thu, 9 Sep 2010 02:52:44 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 710FA8FC08; Thu, 9 Sep 2010 02:52:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o892qiSY019690; Thu, 9 Sep 2010 02:52:44 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o892qiHM019688; Thu, 9 Sep 2010 02:52:44 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201009090252.o892qiHM019688@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 9 Sep 2010 02:52:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212347 - head/sys/mips/rmi/dev/nlge X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Sep 2010 02:52:44 -0000 Author: jchandra Date: Thu Sep 9 02:52:44 2010 New Revision: 212347 URL: http://svn.freebsd.org/changeset/base/212347 Log: Minor clean up for nlge - nlna_submit_rx_free_desc() can use the same desc every time. Also merge couple of one-line functions into their caller. Modified: head/sys/mips/rmi/dev/nlge/if_nlge.c Modified: head/sys/mips/rmi/dev/nlge/if_nlge.c ============================================================================== --- head/sys/mips/rmi/dev/nlge/if_nlge.c Thu Sep 9 02:29:40 2010 (r212346) +++ head/sys/mips/rmi/dev/nlge/if_nlge.c Thu Sep 9 02:52:44 2010 (r212347) @@ -148,7 +148,6 @@ static void nlge_mediastatus(struct ifne /* Other internal/helper functions */ static void *get_buf(void); -static struct mbuf *get_mbuf(void); static void nlna_add_to_port_set(struct nlge_port_set *pset, struct nlge_softc *sc); @@ -170,8 +169,6 @@ static void nlna_reset_ports(struct nln struct xlr_gmac_block_t *blk); static struct nlna_softc *nlna_sc_init(device_t dev, struct xlr_gmac_block_t *blk); -static __inline__ int nlna_send_free_desc(struct nlna_softc *nlna, - vm_paddr_t addr); static void nlna_setup_intr(struct nlna_softc *sc); static void nlna_smp_update_pde(void *dummy __unused); static void nlna_submit_rx_free_desc(struct nlna_softc *sc, @@ -206,7 +203,6 @@ static int prepare_fmn_message(struct nl struct msgrng_msg *msg, uint32_t *n_entries, struct mbuf *m_head, uint64_t fr_stid, struct nlge_tx_desc **tx_desc); -static void release_mbuf(uint64_t phy_addr); static void release_tx_desc(vm_paddr_t phy_addr); static int send_fmn_msg_tx(struct nlge_softc *, struct msgrng_msg *, uint32_t n_entries); @@ -680,7 +676,7 @@ nlge_msgring_handler(int bucket, int siz if (is_p2p) { release_tx_desc(phys_addr); } else { - release_mbuf(phys_addr); + m_freem((struct mbuf *)(uintptr_t)phys_addr); } ifp = sc->nlge_if; @@ -1009,39 +1005,23 @@ nlna_is_last_active_na(struct nlna_softc return (id == 2 || xlr_board_info.gmac_block[id + 1].enabled == 0); } -static __inline__ int -nlna_send_free_desc(struct nlna_softc *sc, vm_paddr_t addr) -{ - struct msgrng_msg msg; - uint32_t msgrng_flags; - int i = 0, stid, code, ret; - - stid = sc->rfrbucket; - memset(&msg, 0, sizeof(msg)); - msg.msg0 = (uint64_t) addr & 0xffffffffe0ULL; - - code = (sc->na_type == XLR_XGMAC) ? MSGRNG_CODE_XGMAC : MSGRNG_CODE_MAC; - do { - msgrng_flags = msgrng_access_enable(); - ret = message_send_retry(1, code, stid, &msg); - msgrng_restore(msgrng_flags); - KASSERT(i++ < 100000, ("Too many credit fails\n")); - } while (ret != 0); - return (0); -} - static void nlna_submit_rx_free_desc(struct nlna_softc *sc, uint32_t n_desc) { + struct msgrng_msg msg; void *ptr; - int i; - int ret; + uint32_t msgrng_flags; + int i, n, stid, ret, code; if (n_desc > 1) { PDEBUG("Sending %d free-in descriptors to station=%d\n", n_desc, sc->rfrbucket); } + stid = sc->rfrbucket; + code = (sc->na_type == XLR_XGMAC) ? MSGRNG_CODE_XGMAC : MSGRNG_CODE_MAC; + memset(&msg, 0, sizeof(msg)); + for (i = 0; i < n_desc; i++) { ptr = get_buf(); if (!ptr) { @@ -1051,10 +1031,14 @@ nlna_submit_rx_free_desc(struct nlna_sof } /* Send the free Rx desc to the MAC */ - ret = nlna_send_free_desc(sc, vtophys(ptr)); - if (ret != 0) /* no point trying other descriptors after - a failure. */ - break; + msg.msg0 = vtophys(ptr) & 0xffffffffe0ULL; + n = 0; + do { + msgrng_flags = msgrng_access_enable(); + ret = message_send_retry(1, code, stid, &msg); + msgrng_restore(msgrng_flags); + KASSERT(n++ < 100000, ("Too many credit fails\n")); + } while (ret != 0); } } @@ -1982,15 +1966,6 @@ send_fmn_msg_tx(struct nlge_softc *sc, s } static void -release_mbuf(uint64_t phy_addr) -{ - struct mbuf *m; - - m = (struct mbuf *)((uint32_t) phy_addr); - m_freem(m); -} - -static void release_tx_desc(vm_paddr_t paddr) { struct nlge_tx_desc *tx_desc; @@ -2008,17 +1983,6 @@ release_tx_desc(vm_paddr_t paddr) uma_zfree(nl_tx_desc_zone, tx_desc); } -static struct mbuf * -get_mbuf(void) -{ - struct mbuf *m_new; - - if ((m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL) - return NULL; - m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; - return (m_new); -} - static void * get_buf(void) { @@ -2026,10 +1990,9 @@ get_buf(void) vm_paddr_t temp1, temp2; unsigned int *md; - m_new = get_mbuf(); - if (m_new == NULL) - return m_new; - + if ((m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL) + return NULL; + m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; m_adj(m_new, XLR_CACHELINE_SIZE - ((unsigned int)m_new->m_data & 0x1f)); md = (unsigned int *)m_new->m_data; md[0] = (unsigned int)m_new; /* Back Ptr */