Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Aug 2016 04:12:50 GMT
From:      yuanxunzhang@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r307850 - in soc2016/yuanxunzhang/head: sys/net usr.sbin/eaps
Message-ID:  <201608180412.u7I4CoPm049719@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608180412.u7I4CoPm049719>