From owner-svn-soc-all@freebsd.org Fri Aug 19 07:45:07 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 2C5B8BBF298 for ; Fri, 19 Aug 2016 07:45:07 +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 11CDE1B41 for ; Fri, 19 Aug 2016 07:45:07 +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 u7J7j6vR077468 for ; Fri, 19 Aug 2016 07:45:06 GMT (envelope-from yuanxunzhang@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u7J7j422077409 for svn-soc-all@FreeBSD.org; Fri, 19 Aug 2016 07:45:04 GMT (envelope-from yuanxunzhang@FreeBSD.org) Date: Fri, 19 Aug 2016 07:45:04 GMT Message-Id: <201608190745.u7J7j422077409@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: r307994 - 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: Fri, 19 Aug 2016 07:45:07 -0000 Author: yuanxunzhang Date: Fri Aug 19 07:45:04 2016 New Revision: 307994 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=307994 Log: EAPS: get eaps mode priority interface Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c soc2016/yuanxunzhang/head/sys/net/eaps.h soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c ============================================================================== --- soc2016/yuanxunzhang/head/sys/net/eaps.c Fri Aug 19 05:43:28 2016 (r307993) +++ soc2016/yuanxunzhang/head/sys/net/eaps.c Fri Aug 19 07:45:04 2016 (r307994) @@ -246,8 +246,9 @@ EAPS_RLOCK(sc, &tracker); es->state = sc->sc_eaps.state; es->status = sc->sc_eaps.status; + es->mode = sc->sc_eaps.mode; + es->priority = sc->sc_eaps.priority; (void) strlcpy(es->ifname, sc->sc_ifp->if_xname, sizeof(sc->sc_ifp->if_xname)); - printf("EAPS status: interface: %s, state: %d\n.", sc->sc_ifp->if_xname, es->state); EAPS_RUNLOCK(sc, &tracker); } @@ -258,6 +259,8 @@ EAPS_WLOCK(sc); sc->sc_eaps.state = EAPS_S_IDLE; sc->sc_eaps.status = EAPS_STATUS_NOT_ACTIVE; + sc->sc_eaps.mode = EAPS_MODE_TRANSIT; + sc->sc_eaps.priority = EAPS_PRIORITY_NORMAL; EAPS_WUNLOCK(sc); } Modified: soc2016/yuanxunzhang/head/sys/net/eaps.h ============================================================================== --- soc2016/yuanxunzhang/head/sys/net/eaps.h Fri Aug 19 05:43:28 2016 (r307993) +++ soc2016/yuanxunzhang/head/sys/net/eaps.h Fri Aug 19 07:45:04 2016 (r307994) @@ -38,6 +38,8 @@ char ifname[IFNAMSIZ]; /* name of the eaps */ uint8_t state; /* state of eaps */ uint8_t status; /* enable or disable eaps */ + uint8_t mode; /* switch mode for a node: transit or master, default transit */ + uint8_t priority; /* EAPS domain priority high or normal */ }; /* @@ -156,6 +158,12 @@ #define EAPS_STATUS_ACTIVE 0x00 /* Eaps is active */ #define EAPS_STATUS_NOT_ACTIVE 0x01 /* Eaps is not active */ +#define EAPS_MODE_TRANSIT 0x00 /* EAPS swith mode - transit (default) */ +#define EAPS_MODE_MASTER 0x01 /* EAPS swith mode - master */ + +#define EAPS_PRIORITY_NORMAL 0x00 /* EAPS domain priority - normal */ +#define EAPS_PRIORITY_HIGH 0x01 /* EAPS domain priority - high (default) */ + #define EAPS_LOCK_INIT(_sc) rm_init(&(_sc)->sc_mtx, "eaps rmlock") #define EAPS_LOCK_DESTROY(_sc) rm_destroy(&(_sc)->sc_mtx) #define EAPS_RLOCK(_sc, _p) rm_rlock(&(_sc)->sc_mtx, (_p)) Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c ============================================================================== --- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Fri Aug 19 05:43:28 2016 (r307993) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Fri Aug 19 07:45:04 2016 (r307994) @@ -67,12 +67,22 @@ static const char *eaps_state_message[] = { "idle", /* EAPS_S_IDLE */ - "complete" /* EAPS_S_COMPLETE */ - "failed" /* EAPS_S_FAILED */ - "link up" /* EAPS_S_LINKS_UP */ - "link down" /* EAPS_S_LINK_DOWN */ - "preforward" /* EAPS_S_PREFORWARD */ - "init" /* EAPS_S_INIT */ + "complete", /* EAPS_S_COMPLETE */ + "failed", /* EAPS_S_FAILED */ + "link up", /* EAPS_S_LINKS_UP */ + "link down", /* EAPS_S_LINK_DOWN */ + "preforward", /* EAPS_S_PREFORWARD */ + "init", /* EAPS_S_INIT */ +}; + +static const char *eaps_mode_message[] = { + "transit", /* EAPS_MODE_TRANSIT */ + "master", /* EAPS_MODE_MASTER */ +}; + +static const char *eaps_priority_message[] = { + "normal", /* EAPS_PRIORITY_NORMAL */ + "high", /* EAPS_PRIORITY_HIGH */ }; static struct keytab { @@ -202,8 +212,9 @@ if (ioctl(s, SIOCSEAPSDOMAIN, &es) == 0) { printf("%s: ", domain_name); printf("status: %s, ", eaps_status_message[es.status]); - printf("state: %s, ", eaps_state_message[es.state]); - putchar('\n'); + printf("state: %s\n", eaps_state_message[es.state]); + printf("\tswitch mode: %s\n", eaps_mode_message[es.mode]); + printf("\tpriority: %s\n", eaps_priority_message[es.priority]); } else { err(1, "SIOCSEAPSDOMAIN"); } Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h ============================================================================== --- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h Fri Aug 19 05:43:28 2016 (r307993) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h Fri Aug 19 07:45:04 2016 (r307994) @@ -45,8 +45,9 @@ char ifname[IFNAMSIZ]; /* name of the eaps */ uint8_t state; /* state of eaps */ uint8_t status; /* enable or disable eaps */ + uint8_t mode; /* switch mode for a node: transit or master, default transit */ + uint8_t priority; /* EAPS domain priority high or normal */ }; - /* * EAPS ring node states */