svn commit: r207150 - user/jmallett/octeon/sys/mips/cavium/octe
Juli Mallett
jmallett at FreeBSD.org
Sat Apr 24 10:22:08 UTC 2010
Author: jmallett
Date: Sat Apr 24 10:22:08 2010
New Revision: 207150
URL: http://svn.freebsd.org/changeset/base/207150
Log:
o) Move interface flags management to octe.c.
o) Allow MTU changing.
o) Add trivial init/stop methods.
Modified:
user/jmallett/octeon/sys/mips/cavium/octe/cavium-ethernet.h
user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.c
user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h
user/jmallett/octeon/sys/mips/cavium/octe/octe.c
Modified: user/jmallett/octeon/sys/mips/cavium/octe/cavium-ethernet.h
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/cavium-ethernet.h Sat Apr 24 09:57:18 2010 (r207149)
+++ user/jmallett/octeon/sys/mips/cavium/octe/cavium-ethernet.h Sat Apr 24 10:22:08 2010 (r207150)
@@ -112,6 +112,7 @@ typedef struct {
void (*uninit)(struct ifnet *ifp);
struct ifmedia media;
+ int if_flags;
} cvm_oct_private_t;
Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.c
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.c Sat Apr 24 09:57:18 2010 (r207149)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.c Sat Apr 24 10:22:08 2010 (r207150)
@@ -182,7 +182,7 @@ static int cvm_oct_common_set_mac_addres
* @param new_mtu The new MTU
* @return Zero on success
*/
-static int cvm_oct_common_change_mtu(struct ifnet *ifp, int new_mtu)
+int cvm_oct_common_change_mtu(struct ifnet *ifp, int new_mtu)
{
cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
int interface = INTERFACE(priv->port);
@@ -261,20 +261,10 @@ int cvm_oct_common_init(struct ifnet *if
#endif
count++;
- /*
- * XXX
- * Need to set:
- * if_init
- * if_ioctl
- * if_start
- */
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-
#if 0
ifp->get_stats = cvm_oct_common_get_stats;
ifp->set_mac_address = cvm_oct_common_set_mac_address;
ifp->set_multicast_list = cvm_oct_common_set_multicast_list;
- ifp->change_mtu = cvm_oct_common_change_mtu;
ifp->do_ioctl = cvm_oct_ioctl;
ifp->features |= NETIF_F_LLTX; /* We do our own locking, Linux doesn't need to */
SET_ETHTOOL_OPS(ifp, &cvm_oct_ethtool_ops);
Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h Sat Apr 24 09:57:18 2010 (r207149)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h Sat Apr 24 10:22:08 2010 (r207150)
@@ -30,6 +30,8 @@ AND WITH ALL FAULTS AND CAVIUM NETWORKS
int cvm_oct_common_init(struct ifnet *ifp);
void cvm_oct_common_uninit(struct ifnet *ifp);
+int cvm_oct_common_change_mtu(struct ifnet *ifp, int new_mtu);
+
int cvm_oct_init_module(device_t);
void cvm_oct_cleanup_module(void);
Modified: user/jmallett/octeon/sys/mips/cavium/octe/octe.c
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/octe.c Sat Apr 24 09:57:18 2010 (r207149)
+++ user/jmallett/octeon/sys/mips/cavium/octe/octe.c Sat Apr 24 10:22:08 2010 (r207150)
@@ -30,6 +30,8 @@
* Cavium Octeon Ethernet devices.
*
* XXX This file should be moved to if_octe.c
+ * XXX The driver may have sufficient locking but we need locking to protect
+ * the interfaces presented here, right?
*/
#include <sys/param.h>
@@ -53,11 +55,16 @@
#include "wrapper-cvmx-includes.h"
#include "cavium-ethernet.h"
+#include "ethernet-common.h"
+
static int octe_probe(device_t);
static int octe_attach(device_t);
static int octe_detach(device_t);
static int octe_shutdown(device_t);
+static void octe_init(void *);
+static void octe_stop(void *);
+
static int octe_medchange(struct ifnet *);
static void octe_medstat(struct ifnet *, struct ifmediareq *);
@@ -114,8 +121,12 @@ octe_attach(device_t dev)
ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO);
+ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+ ifp->if_init = octe_init;
ifp->if_ioctl = octe_ioctl;
+ priv->if_flags = ifp->if_flags;
+
return (0);
}
@@ -131,6 +142,32 @@ octe_shutdown(device_t dev)
return (octe_detach(dev));
}
+static void
+octe_init(void *arg)
+{
+ struct ifnet *ifp;
+ cvm_oct_private_t *priv;
+
+ priv = arg;
+ ifp = priv->ifp;
+
+ if (priv->open != NULL)
+ priv->open(ifp);
+}
+
+static void
+octe_stop(void *arg)
+{
+ struct ifnet *ifp;
+ cvm_oct_private_t *priv;
+
+ priv = arg;
+ ifp = priv->ifp;
+
+ if (priv->stop != NULL)
+ priv->stop(ifp);
+}
+
static int
octe_medchange(struct ifnet *ifp)
{
@@ -191,6 +228,23 @@ octe_ioctl(struct ifnet *ifp, u_long cmd
ifr = (struct ifreq *)data;
switch (cmd) {
+ case SIOCSIFFLAGS:
+ if ((ifp->if_flags & IFF_UP) != 0) {
+ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ octe_init(ifp);
+ } else {
+ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ octe_stop(ifp);
+ }
+ priv->if_flags = ifp->if_flags;
+ return (0);
+
+ case SIOCSIFMTU:
+ error = cvm_oct_common_change_mtu(ifp, ifr->ifr_mtu);
+ if (error != 0)
+ return (EINVAL);
+ return (0);
+
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &priv->media, cmd);
More information about the svn-src-user
mailing list