diff --git a/sys/config/X86_64_GENERIC b/sys/config/X86_64_GENERIC index 2b24938..716a3e6 100644 --- a/sys/config/X86_64_GENERIC +++ b/sys/config/X86_64_GENERIC @@ -335,3 +335,4 @@ device fwe # Ethernet over FireWire (non-standard!) device mmc device mmcsd device sdhci +device aoe diff --git a/sys/dev/disk/aoe/Makefile b/sys/dev/disk/aoe/Makefile index 9186f60..7aad812 100644 --- a/sys/dev/disk/aoe/Makefile +++ b/sys/dev/disk/aoe/Makefile @@ -2,6 +2,5 @@ KMOD= aoe SRCS= aoecmd.c aoedev.c aoenet.c aoeblk.c aoemain.c -CFLAGS+= -DFORCE_NETWORK_HOOK -I../.. .include diff --git a/sys/dev/disk/aoe/aoeblk.c b/sys/dev/disk/aoe/aoeblk.c index fc929b3..063fe75 100644 --- a/sys/dev/disk/aoe/aoeblk.c +++ b/sys/dev/disk/aoe/aoeblk.c @@ -212,6 +212,8 @@ disk_create_task(void *ctx, int useless __unused) atomic_clear_32(&d->ad_flags, DEVFL_TASKON); atomic_set_32(&d->ad_flags, DEVFL_UP); + + KKASSERT(d->dev_t == dsk); } /* @@ -261,7 +263,7 @@ int aoeblk_register(struct aoedev *d) { int n; - + kprintf("%s called\n", __func__); n = runtask(disk_create_task, d); if (n != 0) IPRINTK("runtask failure.\n"); @@ -272,7 +274,7 @@ int aoeblk_unregister(struct aoedev *d) { int n; - + kprintf("%s called\n", __func__); n = runtask(disk_destroy_task, d); if (n != 0) IPRINTK("runtask failure.\n"); diff --git a/sys/dev/disk/aoe/aoecmd.c b/sys/dev/disk/aoe/aoecmd.c index 83535a8..1060f1d 100644 --- a/sys/dev/disk/aoe/aoecmd.c +++ b/sys/dev/disk/aoe/aoecmd.c @@ -437,7 +437,7 @@ static void ataid_complete(struct aoedev *d, char *id) { int n; - + kprintf("%s called\n", __func__); memcpy(d->ad_ident, id, sizeof d->ad_ident); n = le16toh(*(uint16_t *) (id + (83<<1))); /* Command set supported. */ @@ -485,7 +485,7 @@ aoecmd_ata_rsp(struct mbuf *m) struct bio *bio; struct buf *bp; register long n; - + kprintf("%s called\n", __func__); hin = mtod(m, struct aoe_hdr *); d = aoedev_byunit(AOEUNIT(ntohs(hin->ah_major), hin->ah_minor)); diff --git a/sys/dev/disk/aoe/aoedev.c b/sys/dev/disk/aoe/aoedev.c index 4623c72..a0334bb 100644 --- a/sys/dev/disk/aoe/aoedev.c +++ b/sys/dev/disk/aoe/aoedev.c @@ -269,6 +269,9 @@ sysctl_aoe_devices(SYSCTL_HANDLER_ARGS) n = 0; for (d=devlist; d; d=d->ad_next) { + kprintf("%s: d=%p d->ad_unit=%ld d->ad_ifp->if_xname=%s " + "d->ad_flags=%d d->dev_t->si_iosize_max", __func__, d, + d->ad_unit, d->ad_ifp->if_xname, d->ad_flags); n += ksnprintf(buf+n, LINESZ, "\naoed%-6ld\t%s\t%s%s%s\t(%d)", d->ad_unit, d->ad_ifp->if_xname, diff --git a/sys/dev/disk/aoe/aoenet.c b/sys/dev/disk/aoe/aoenet.c index e809865..8e579d3 100644 --- a/sys/dev/disk/aoe/aoenet.c +++ b/sys/dev/disk/aoe/aoenet.c @@ -50,26 +50,18 @@ #include -/* XXX swildner: module Makefile has this too */ -#ifndef FORCE_NETWORK_HOOK -#define FORCE_NETWORK_HOOK -#endif - -/* XXX swildner: do we need it? */ -#define IFNET_RLOCK() -#define IFNET_RUNLOCK() +void aoeintr(struct mbuf *); /* - * FORCE_NETWORK_HOOK is defined to support kernels that have not been patched - * to recognize AoE packets. + * NOTE + * + * In original AoE FreeBSD module, FORCE_NETWORK_HOOK was used to manipulate + * ifp->if_input chain in order to be able to handle AoE ethernet frames + * in a different way than the rest of ethernet frames. + * + * DragonFly does this handling in ether_demux_oncpu() as AoE ethernet + * type is properly handled. */ -#ifdef FORCE_NETWORK_HOOK -#if 0 /* XXX swildner */ -static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] = - { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -#endif -static void (*old_ether_input)(struct ifnet *, struct mbuf *) = NULL; -#endif extern boolean_t aoe_exiting; struct ifqueue aoeintrq; @@ -184,7 +176,7 @@ is_aoe_netif(struct ifnet *ifp) return (TRUE); if (q == p) break; - } + } return (FALSE); } @@ -275,7 +267,6 @@ aoenet_xmitbcast(u_short aoemajor, u_char aoeminor) h->ah_minor = aoeminor; h->ah_cmd = AOECMD_CFG; - IFNET_RLOCK(); TAILQ_FOREACH(ifp, &ifnet, if_link) { if (!is_aoe_netif(ifp)) continue; @@ -287,7 +278,6 @@ aoenet_xmitbcast(u_short aoemajor, u_char aoeminor) } ether_output_frame(ifp, m); } - IFNET_RUNLOCK(); m_freem(m0); } @@ -307,12 +297,12 @@ aoenet_maxsize(struct ifnet *ifp) /* (1) The tag high bit is not permitted to be set for our responses. */ -static void +void aoeintr(struct mbuf *m) { struct aoe_hdr *h; uint32_t n; - + kprintf("%s called\n", __func__); if (aoe_exiting) { m_freem(m); return; @@ -320,11 +310,6 @@ aoeintr(struct mbuf *m) do { -#ifndef FORCE_NETWORK_HOOK - if (!is_aoe_netif(m->m_pkthdr.rcvif)) - break; -#endif - h = mtod(m, struct aoe_hdr *); n = ntohl(h->ah_tag); if ((h->ah_verfl & AOEFL_RSP) == 0 || (n & 1<<31)) /* (1) */ @@ -353,7 +338,7 @@ aoeintr(struct mbuf *m) m_freem(m); } -#ifdef FORCE_NETWORK_HOOK +#ifdef mimimi static void aoe_ether_input(struct ifnet *ifp, struct mbuf *m) { @@ -435,27 +420,8 @@ static int sysctl_aoe_iflist(SYSCTL_HANDLER_ARGS) { int error; -#ifdef FORCE_NETWORK_HOOK - struct ifnet *ifp; -#endif error = sysctl_handle_string(oidp, arg1, arg2, req); - -#ifdef FORCE_NETWORK_HOOK - IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &ifnet, if_link) { - if (!is_aoe_netif(ifp)) { - if (ifp->if_input == aoe_ether_input) - ifp->if_input = old_ether_input; - continue; - } - if (ifp->if_input != aoe_ether_input) - ifp->if_input = aoe_ether_input; - - } - IFNET_RUNLOCK(); -#endif /* FORCE_NETWORK_HOOK */ - aoecmd_cfg(0xffff, 0xff); return (error); @@ -464,54 +430,12 @@ sysctl_aoe_iflist(SYSCTL_HANDLER_ARGS) void aoenet_init(void) { -#ifdef FORCE_NETWORK_HOOK - struct ifnet *ifp; - - IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &ifnet, if_link) { - switch (ifp->if_data.ifi_type) { - case IFT_ETHER: - case IFT_FASTETHER: - case IFT_GIGABITETHERNET: - break; - default: - continue; - } - if (old_ether_input == NULL) - old_ether_input = ifp->if_input; - else if (old_ether_input != ifp->if_input) - IPRINTK("ifp->if_input != ether_input\n"); - } - IFNET_RUNLOCK(); -#else aoeintrq.ifq_maxlen = IFQ_MAXLEN; - lockinit(&aoeintrq.ifq_lock, "aoe_inq", 0, LK_CANRECURSE); - netisr_register(NETISR_AOE, aoeintr, &aoeintrq, NETISR_MPSAFE); -#endif /* ! FORCE_NETWORK_HOOK */ +// lockinit(&aoeintrq.ifq_lock, "aoe_inq", 0, LK_CANRECURSE); +// netisr_register(NETISR_AOE, aoeintr, &aoeintrq, NETISR_MPSAFE); } void aoenet_exit(void) { -#ifdef FORCE_NETWORK_HOOK - struct ifnet *ifp; - - IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &ifnet, if_link) { - switch (ifp->if_data.ifi_type) { - case IFT_ETHER: - case IFT_FASTETHER: - case IFT_GIGABITETHERNET: - break; - default: - continue; - } - if (ifp->if_input == aoe_ether_input) - ifp->if_input = old_ether_input; - } - IFNET_RUNLOCK(); -#else - netisr_unregister(NETISR_AOE); - lockuninit(&aoeintrq.ifq_lock); -#endif /* ! FORCE_NETWORK_HOOK */ } diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index 7668ef2..366c746 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -339,6 +339,7 @@ extern const uint8_t etherbroadcastaddr[ETHER_ADDR_LEN]; #define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ #define ETHERTYPE_LANPROBE 0x8888 /* HP LanProbe test? */ #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ +#define ETHERTYPE_AOE 0x88a2 /* ATA over Ethernet - ethernet type */ #define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ #define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ #define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index bd6cf5d..c1e1e69 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -96,6 +96,7 @@ int (*ef_inputp)(struct ifnet*, const struct ether_header *eh, struct mbuf *m); int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, short *tp, int *hlen); #endif +extern void aoeintr(struct mbuf *); #ifdef MPLS #include @@ -1079,6 +1080,10 @@ post_stats: */ m->m_flags &= ~M_ETHER_FLAGS; + if (ether_type == ETHERTYPE_AOE) { + aoeintr(m); + return; + } /* Strip ethernet header. */ m_adj(m, sizeof(struct ether_header));