summaryrefslogtreecommitdiffstats
path: root/sys/dev/firewire
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
committerbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
commit567ba9b00a248431e7c1147c4e079fd7a11b9ecf (patch)
treef65b6d7834b40dfcd48534829a0a1e9529ab87ee /sys/dev/firewire
parent3eaa67c3ad947d85be5350e0e184cd6ee5b93a52 (diff)
downloadFreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.zip
FreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.tar.gz
Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have been replaced with a struct ifnet pointer to be filled by a call to the new function, if_alloc(). The layer 2 common structure is also allocated via if_alloc() based on the interface type. It is hung off the new struct ifnet member, if_l2com. This change removes the size of these structures from the kernel ABI and will allow us to better manage them as interfaces come and go. Other changes of note: - Struct arpcom is no longer referenced in normal interface code. Instead the Ethernet address is accessed via the IFP2ENADDR() macro. To enforce this ac_enaddr has been renamed to _ac_enaddr. - The second argument to ether_ifattach is now always the mac address from driver private storage rather than sometimes being ac_enaddr. Reviewed by: sobomax, sam
Diffstat (limited to 'sys/dev/firewire')
-rw-r--r--sys/dev/firewire/if_fwe.c33
-rw-r--r--sys/dev/firewire/if_fwevar.h4
-rw-r--r--sys/dev/firewire/if_fwip.c22
-rw-r--r--sys/dev/firewire/if_fwipvar.h4
4 files changed, 39 insertions, 24 deletions
diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c
index 34e540b..df57f27 100644
--- a/sys/dev/firewire/if_fwe.c
+++ b/sys/dev/firewire/if_fwe.c
@@ -52,6 +52,7 @@
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
+#include <net/if_types.h>
#ifdef __DragonFly__
#include <net/vlan/if_vlan_var.h>
#include <bus/firewire/firewire.h>
@@ -159,7 +160,11 @@ fwe_attach(device_t dev)
struct fwe_softc *fwe;
struct ifnet *ifp;
int unit, s;
+#if defined(__DragonFly__) || __FreeBSD_version < 500000
u_char *eaddr;
+#else
+ u_char eaddr[6];
+#endif
struct fw_eui64 *eui;
fwe = ((struct fwe_softc *)device_get_softc(dev));
@@ -185,7 +190,10 @@ fwe_attach(device_t dev)
/* generate fake MAC address: first and last 3bytes from eui64 */
#define LOCAL (0x02)
#define GROUP (0x01)
- eaddr = &fwe->eth_softc.arpcom.ac_enaddr[0];
+#if defined(__DragonFly__) || __FreeBSD_version < 500000
+ eaddr = &IFP2ENADDR(fwe->eth_softc.ifp)[0];
+#endif
+
eui = &fwe->fd.fc->eui;
eaddr[0] = (FW_EUI64_BYTE(eui, 0) | LOCAL) & ~GROUP;
@@ -199,7 +207,11 @@ fwe_attach(device_t dev)
eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
/* fill the rest and attach interface */
- ifp = &fwe->fwe_if;
+ ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
ifp->if_softc = &fwe->eth_softc;
#if __FreeBSD_version >= 501113 || defined(__DragonFly__)
@@ -244,7 +256,7 @@ fwe_stop(struct fwe_softc *fwe)
{
struct firewire_comm *fc;
struct fw_xferq *xferq;
- struct ifnet *ifp = &fwe->fwe_if;
+ struct ifnet *ifp = fwe->eth_softc.ifp;
struct fw_xfer *xfer, *next;
int i;
@@ -284,16 +296,19 @@ static int
fwe_detach(device_t dev)
{
struct fwe_softc *fwe;
+ struct ifnet *ifp;
int s;
- fwe = (struct fwe_softc *)device_get_softc(dev);
+ fwe = device_get_softc(dev);
+ ifp = fwe->eth_softc.ifp;
s = splimp();
fwe_stop(fwe);
#if defined(__DragonFly__) || __FreeBSD_version < 500000
- ether_ifdetach(&fwe->fwe_if, 1);
+ ether_ifdetach(ifp, 1);
#else
- ether_ifdetach(&fwe->fwe_if);
+ ether_ifdetach(ifp);
+ if_free(ifp);
#endif
splx(s);
@@ -305,7 +320,7 @@ fwe_init(void *arg)
{
struct fwe_softc *fwe = ((struct fwe_eth_softc *)arg)->fwe;
struct firewire_comm *fc;
- struct ifnet *ifp = &fwe->fwe_if;
+ struct ifnet *ifp = fwe->eth_softc.ifp;
struct fw_xferq *xferq;
struct fw_xfer *xfer;
struct mbuf *m;
@@ -464,7 +479,7 @@ fwe_output_callback(struct fw_xfer *xfer)
int s;
fwe = (struct fwe_softc *)xfer->sc;
- ifp = &fwe->fwe_if;
+ ifp = fwe->eth_softc.ifp;
/* XXX error check */
FWEDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
@@ -593,7 +608,7 @@ fwe_as_input(struct fw_xferq *xferq)
#endif
fwe = (struct fwe_softc *)xferq->sc;
- ifp = &fwe->fwe_if;
+ ifp = fwe->eth_softc.ifp;
#if 0
FWE_POLL_REGISTER(fwe_poll, fwe, ifp);
#endif
diff --git a/sys/dev/firewire/if_fwevar.h b/sys/dev/firewire/if_fwevar.h
index 805301a..73fcb3d 100644
--- a/sys/dev/firewire/if_fwevar.h
+++ b/sys/dev/firewire/if_fwevar.h
@@ -45,9 +45,7 @@ struct fwe_softc {
struct fw_pkt pkt_hdr;
STAILQ_HEAD(, fw_xfer) xferlist;
struct fwe_eth_softc {
- /* XXX this must be the first for if_ethersub.c */
- struct arpcom arpcom; /* ethernet common data */
- #define fwe_if eth_softc.arpcom.ac_if
+ struct ifnet *ifp;
struct fwe_softc *fwe;
} eth_softc;
};
diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c
index 23e812a..3d12ad2 100644
--- a/sys/dev/firewire/if_fwip.c
+++ b/sys/dev/firewire/if_fwip.c
@@ -55,6 +55,7 @@
#include <net/if.h>
#include <net/firewire.h>
#include <net/if_arp.h>
+#include <net/if_types.h>
#ifdef __DragonFly__
#include <bus/firewire/firewire.h>
#include <bus/firewire/firewirereg.h>
@@ -170,6 +171,9 @@ fwip_attach(device_t dev)
fwip = ((struct fwip_softc *)device_get_softc(dev));
unit = device_get_unit(dev);
+ ifp = fwip->fw_softc.fwip_ifp = if_alloc(IFT_IEEE1394);
+ if (ifp == NULL)
+ return (ENOSPC);
bzero(fwip, sizeof(struct fwip_softc));
/* XXX */
@@ -188,7 +192,7 @@ fwip_attach(device_t dev)
/*
* Encode our hardware the way that arp likes it.
*/
- hwaddr = &fwip->fw_softc.fwcom.fc_hwaddr;
+ hwaddr = &IFP2FWC(fwip->fw_softc.fwip_ifp)->fc_hwaddr;
hwaddr->sender_unique_ID_hi = htonl(fwip->fd.fc->eui.hi);
hwaddr->sender_unique_ID_lo = htonl(fwip->fd.fc->eui.lo);
hwaddr->sender_max_rec = fwip->fd.fc->maxrec;
@@ -197,7 +201,6 @@ fwip_attach(device_t dev)
hwaddr->sender_unicast_FIFO_lo = htonl((uint32_t)INET_FIFO);
/* fill the rest and attach interface */
- ifp = &fwip->fwip_if;
ifp->if_softc = &fwip->fw_softc;
#if __FreeBSD_version >= 501113 || defined(__DragonFly__)
@@ -226,7 +229,7 @@ fwip_stop(struct fwip_softc *fwip)
{
struct firewire_comm *fc;
struct fw_xferq *xferq;
- struct ifnet *ifp = &fwip->fwip_if;
+ struct ifnet *ifp = fwip->fw_softc.fwip_ifp;
struct fw_xfer *xfer, *next;
int i;
@@ -279,7 +282,8 @@ fwip_detach(device_t dev)
s = splimp();
fwip_stop(fwip);
- firewire_ifdetach(&fwip->fwip_if);
+ firewire_ifdetach(fwip->fw_softc.fwip_ifp);
+ if_free(fwip->fw_softc.fwip_ifp);
splx(s);
return 0;
@@ -290,7 +294,7 @@ fwip_init(void *arg)
{
struct fwip_softc *fwip = ((struct fwip_eth_softc *)arg)->fwip;
struct firewire_comm *fc;
- struct ifnet *ifp = &fwip->fwip_if;
+ struct ifnet *ifp = fwip->fw_softc.fwip_ifp;
struct fw_xferq *xferq;
struct fw_xfer *xfer;
struct mbuf *m;
@@ -473,7 +477,7 @@ fwip_post_busreset(void *arg)
fwip->last_dest.hi = 0;
fwip->last_dest.lo = 0;
- firewire_busreset(&fwip->fwip_if);
+ firewire_busreset(fwip->fw_softc.fwip_ifp);
}
static void
@@ -486,7 +490,7 @@ fwip_output_callback(struct fw_xfer *xfer)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xfer->sc;
- ifp = &fwip->fwip_if;
+ ifp = fwip->fw_softc.fwip_ifp;
/* XXX error check */
FWIPDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
@@ -728,7 +732,7 @@ fwip_stream_input(struct fw_xferq *xferq)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xferq->sc;
- ifp = &fwip->fwip_if;
+ ifp = fwip->fw_softc.fwip_ifp;
#if 0
FWIP_POLL_REGISTER(fwip_poll, fwip, ifp);
#endif
@@ -858,7 +862,7 @@ fwip_unicast_input(struct fw_xfer *xfer)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xfer->sc;
- ifp = &fwip->fwip_if;
+ ifp = fwip->fw_softc.fwip_ifp;
m = xfer->mbuf;
xfer->mbuf = 0;
fp = &xfer->recv.hdr;
diff --git a/sys/dev/firewire/if_fwipvar.h b/sys/dev/firewire/if_fwipvar.h
index 0a9ef24..153ce94 100644
--- a/sys/dev/firewire/if_fwipvar.h
+++ b/sys/dev/firewire/if_fwipvar.h
@@ -55,9 +55,7 @@ struct fwip_softc {
struct crom_chunk spec6; /* specifier description IPv6 */
struct crom_chunk ver6; /* version description IPv6 */
struct fwip_eth_softc {
- /* XXX this must be the first for if_fwsubr.c */
- struct fw_com fwcom; /* firewire common data */
- #define fwip_if fw_softc.fwcom.fc_if
+ struct ifnet *fwip_ifp;
struct fwip_softc *fwip;
} fw_softc;
};
OpenPOWER on IntegriCloud