From owner-svn-soc-all@freebsd.org Thu Aug 18 04:12:52 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03531BBDCF9 for ; Thu, 18 Aug 2016 04:12:52 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E05791176 for ; Thu, 18 Aug 2016 04:12:51 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u7I4CpPt050585 for ; Thu, 18 Aug 2016 04:12:51 GMT (envelope-from yuanxunzhang@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u7I4CoPm049719 for svn-soc-all@FreeBSD.org; Thu, 18 Aug 2016 04:12:50 GMT (envelope-from yuanxunzhang@FreeBSD.org) Date: Thu, 18 Aug 2016 04:12:50 GMT Message-Id: <201608180412.u7I4CoPm049719@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to yuanxunzhang@FreeBSD.org using -f From: yuanxunzhang@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r307850 - in soc2016/yuanxunzhang/head: sys/net usr.sbin/eaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2016 04:12:52 -0000 Author: yuanxunzhang Date: Thu Aug 18 04:12:49 2016 New Revision: 307850 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=307850 Log: EAPS: query eaps domian status Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c soc2016/yuanxunzhang/head/sys/net/eaps.h soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c ============================================================================== --- soc2016/yuanxunzhang/head/sys/net/eaps.c Thu Aug 18 02:14:39 2016 (r307849) +++ soc2016/yuanxunzhang/head/sys/net/eaps.c Thu Aug 18 04:12:49 2016 (r307850) @@ -70,13 +70,15 @@ static int eaps_transmit(struct ifnet *, struct mbuf *); static void eaps_qflush(struct ifnet *); static void eaps_init(void *); -static void eaps_domain_init(struct eaps_softc *); - +void eaps_attach(struct eaps_state *); +void eaps_detach(struct eaps_state *); static VNET_DEFINE(struct if_clone *, eaps_cloner); #define V_eaps_cloner VNET(eaps_cloner) static const char eaps_name[] = "eaps"; +static struct mtx es_list_mtx; + SYSCTL_DECL(_net_link); static SYSCTL_NODE(_net_link, IFT_EAPS, eaps, CTLFLAG_RW, 0, "EAPS"); @@ -168,6 +170,7 @@ ifp->if_init = eaps_init; ifp->if_type = IFT_EAPS; + eaps_attach(&sc->sc_eaps); ether_ifattach(ifp, sc->sc_defaddr); EAPS_LIST_LOCK(); @@ -232,13 +235,26 @@ { } -static void -eaps_domain_init(struct eaps_softc *sc) +void +eaps_attach(struct eaps_state *es) { - //set eaps domain default state - sc->sc_eaps.state = EAPS_S_IDLE; - sc->sc_eaps.active = EAPS_ACTIVE_DISABLE; + //set eaps domain protocol state to default value + es->state = EAPS_S_IDLE; + es->active = EAPS_ACTIVE_DISABLE; + + mtx_lock(&es_list_mtx); + LIST_INSERT_HEAD(&es_list_mtx, es, es_list); + mtx_unlock(&es_list_mtx); } + +void +eaps_detach(struct eaps_state *es) +{ + mtx_lock(&es_list_mtx); + LIST_REMOVE(es, es_list); + mtx_unlock(&es_list_mtx); +} + /* * eaps_init: * Modified: soc2016/yuanxunzhang/head/sys/net/eaps.h ============================================================================== --- soc2016/yuanxunzhang/head/sys/net/eaps.h Thu Aug 18 02:14:39 2016 (r307849) +++ soc2016/yuanxunzhang/head/sys/net/eaps.h Thu Aug 18 04:12:49 2016 (r307850) @@ -36,6 +36,8 @@ */ struct eaps_state { char ifname[IFNAMSIZ]; /* name of the eaps */ + LIST_ENTRY(eaps_state) es_list; + struct mtx bs_mtx; /* mutex signal */ uint8_t state; /* state of eaps */ uint8_t active; /* enable or disable eaps */ }; @@ -165,5 +167,11 @@ #define EAPS_RLOCK_ASSERT(_sc) rm_assert(&(_sc)->sc_mtx, RA_RLOCKED) #define EAPS_WLOCK_ASSERT(_sc) rm_assert(&(_sc)->sc_mtx, RA_WLOCKED) #define EAPS_UNLOCK_ASSERT(_sc) rm_assert(&(_sc)->sc_mtx, RA_UNLOCKED) - + +#define EAPS_STATE_LOCK_INIT(_bs) mtx_init(&(_bs)->bs_mtx, "eaps state", NULL, MTX_DEF) +#define EAPS_STATE_LOCK_DESTROY(_bs) mtx_destroy(&(_bs)->bs_mtx) +#define EAPS_STATE_LOCK(_bs) mtx_lock(&(_bs)->bs_mtx) +#define EAPS_STATE_UNLOCK(_bs) mtx_unlock(&(_bs)->bs_mtx) +#define EAPS_STATE_LOCK_ASSERT(_bs) mtx_assert(&(_bs)->bs_mtx, MA_OWNED) + #endif /* _NET_EAPS_H */ Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h ============================================================================== --- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h Thu Aug 18 02:14:39 2016 (r307849) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h Thu Aug 18 04:12:49 2016 (r307850) @@ -39,6 +39,8 @@ */ struct eaps_state { char ifname[IFNAMSIZ]; /* name of the eaps */ + LIST_ENTRY(eaps_state) es_list; + struct mtx bs_mtx; /* mutex signal */ uint8_t state; /* state of eaps */ uint8_t active; /* enable or disable eaps */ };