From d35ce612b151dc1c7689bd42b55904af2803cf27 Mon Sep 17 00:00:00 2001 From: Max Khon Date: Tue, 14 Sep 2010 13:30:54 +0000 Subject: [PATCH] New port: FreeBSD driver for ATA over Ethernet (AoE) Port author is Stacey D. Son. Two additional patches are added: - a patch to fix build on FreeBSD 7 and later [1] - a patch to fix device detection >2TB [2] Submitted by: pluknet [1], fjoe [2] Tested by: George Mamalakis --- net/Makefile | 1 + net/aoe/Makefile | 36 ++++++++++++++++++++ net/aoe/distinfo | 3 ++ net/aoe/files/aoe.in | 65 ++++++++++++++++++++++++++++++++++++ net/aoe/files/patch-aoecmd.c | 57 +++++++++++++++++++++++++++++++ net/aoe/files/patch-aoenet.c | 25 ++++++++++++++ net/aoe/pkg-descr | 3 ++ net/aoe/pkg-message | 41 +++++++++++++++++++++++ net/aoe/pkg-plist | 2 ++ 9 files changed, 233 insertions(+) create mode 100644 net/aoe/Makefile create mode 100644 net/aoe/distinfo create mode 100644 net/aoe/files/aoe.in create mode 100644 net/aoe/files/patch-aoecmd.c create mode 100644 net/aoe/files/patch-aoenet.c create mode 100644 net/aoe/pkg-descr create mode 100644 net/aoe/pkg-message create mode 100644 net/aoe/pkg-plist diff --git a/net/Makefile b/net/Makefile index ca82304fd6ab..43fd7a5efe94 100644 --- a/net/Makefile +++ b/net/Makefile @@ -17,6 +17,7 @@ SUBDIR += acx100 SUBDIR += aget SUBDIR += amqp08 + SUBDIR += aoe SUBDIR += apinger SUBDIR += arp-scan SUBDIR += arp-sk diff --git a/net/aoe/Makefile b/net/aoe/Makefile new file mode 100644 index 000000000000..29da5efad00b --- /dev/null +++ b/net/aoe/Makefile @@ -0,0 +1,36 @@ +# Ports collection makefile for: aoe (ATA Over Ethernet) driver +# Date created: 22 May 2006 +# Whom: Stacey D. Son +# +# $FreeBSD$ +# + +PORTNAME= aoe +PORTVERSION= 1.2.0 +CATEGORIES= net +MASTER_SITES= http://www.son.org/download/ +DISTNAME= ${PORTNAME}-freebsd-${PORTVERSION} + +MAINTAINER= fjoe@FreeBSD.org +COMMENT= FreeBSD driver for ATA over Ethernet (AoE) + +NO_PACKAGE= Should be in sync with the kernel to work correctly + +WRKSRC= ${WRKDIR}/dev/aoe +MAN4= aoe.4 +USE_RC_SUBR= aoe + +pre-everything:: + @if [ ! -f /usr/src/sys/Makefile ]; then \ + ${ECHO_MSG} ">> The AoE port needs FreeBSD kernel source code to compile."; \ + ${ECHO_MSG} ">> Please install FreeBSD kernel source code in /usr/src/sys."; \ + ${FALSE}; \ + fi + +do-install: + ${MKDIR} ${PREFIX}/lib/aoe + ${INSTALL_KLD} ${WRKSRC}/aoe.ko ${PREFIX}/lib/aoe + ${INSTALL_MAN} ${WRKDIR}/aoe.4 ${PREFIX}/man/man4 + ${CAT} ${PKGMESSAGE} + +.include diff --git a/net/aoe/distinfo b/net/aoe/distinfo new file mode 100644 index 000000000000..c66d6cb31e83 --- /dev/null +++ b/net/aoe/distinfo @@ -0,0 +1,3 @@ +MD5 (aoe-freebsd-1.2.0.tar.gz) = b7ca0221fba6542a05b6be8ab4d676e7 +SHA256 (aoe-freebsd-1.2.0.tar.gz) = 4fcfde7c4b758dfaba36b28e94df7c74eb7609cf26261720475c5479a8323a24 +SIZE (aoe-freebsd-1.2.0.tar.gz) = 16529 diff --git a/net/aoe/files/aoe.in b/net/aoe/files/aoe.in new file mode 100644 index 000000000000..714a9dc71a98 --- /dev/null +++ b/net/aoe/files/aoe.in @@ -0,0 +1,65 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: netdisks +# REQUIRE: NETWORKING sysctl +# KEYWORD: nojail + +. /etc/rc.subr + +name="aoe" +rcvar="`set_rcvar`" +start_cmd="aoe_start" +stop_cmd=":" + +# discover the AoE devices on requested interfaces and tell vinum +# about the disks requested +aoe_start() +{ + echo -n 1>&2 "Starting AoE:" + if [ -z "${aoe_iflist}" ]; then + echo 2>&1 " aoe_start: unset aoe_iflist." + return + fi + sysctl net.aoe > /dev/null 2>&1 + if [ $? -eq 1 ]; then + kldconfig -mf %%PREFIX%%/lib/aoe + kldload aoe > /dev/null 2>&1 + fi + if [ $? -eq 0 ]; then + # Make sure the net interfaces are "up" + for i in ${aoe_iflist}; do + echo -n 1>&2 " $i" + ifconfig $i up + done + echo 1>&2 "." + + # give the interfaces a chance to come up + sleep 3 + sysctl net.aoe.wc=${aoe_wc} > /dev/null 2>&1 + sysctl net.aoe.iflist="${aoe_iflist}" > /dev/null 2>&1 + sleep 1 + sysctl net.aoe.devices + + # Needs to be updated for gvinum + #if checkyesno start_vinum; then + #if [ -n "${aoe_vinum_drives}" ]; then + # vinum read "${aoe_vinum_drives}" + #fi + #fi + echo -n 1>&2 "Mounting AoE blades:" + + for i in ${aoe_mounts}; do + echo -n 1>&2 " $i" + mount $i + done + echo 1>&2 "." + else + echo 1>&2 Failure initializing AoE + fi +} + +load_rc_config $name +run_rc_command "$1" diff --git a/net/aoe/files/patch-aoecmd.c b/net/aoe/files/patch-aoecmd.c new file mode 100644 index 000000000000..6868561e5ffb --- /dev/null +++ b/net/aoe/files/patch-aoecmd.c @@ -0,0 +1,57 @@ +--- aoecmd.c.orig 2006-05-26 00:13:09.000000000 +0700 ++++ aoecmd.c 2010-09-13 20:15:55.000000000 +0700 +@@ -44,6 +44,7 @@ + #include + #include + #include ++#include + + #include + +@@ -427,29 +428,6 @@ + goto loop; + } + +-static u_short +-lhget16(u_char *p) +-{ +- u_short n; +- +- n = p[1]; +- n <<= 8; +- n |= p[0]; +- return (n); +-} +- +-static u_long +-lhget32(u_char *p) +-{ +- u_long n; +- +- n = lhget16(p+2); +- n <<= 16; +- n |= lhget16(p); +- return (n); +-} +- +- + static void + ataid_complete(struct aoedev *d, char *id) + { +@@ -457,13 +435,13 @@ + + memcpy(d->ad_ident, id, sizeof d->ad_ident); + +- n = lhget16(id + (83<<1)); /* Command set supported. */ ++ n = le16toh(*(uint16_t *) (id + (83<<1))); /* Command set supported. */ + if (n & (1<<10)) { /* Lba48 */ + atomic_set_32(&d->ad_flags, DEVFL_EXT); +- d->ad_nsectors = lhget32(id + (100<<1)); /* n lba48 sectors. */ ++ d->ad_nsectors = le64toh(*(uint64_t *) (id + (100<<1))); /* n lba48 sectors. */ + } else { + atomic_clear_32(&d->ad_flags, DEVFL_EXT); +- d->ad_nsectors = lhget32(id + (60<<1)); /* n lba28 sectors. */ ++ d->ad_nsectors = le32toh(*(uint32_t *) (id + (60<<1))); /* n lba28 sectors. */ + } + if (aoeblk_register(d) != 0) + IPRINTK("could not register disk\n"); diff --git a/net/aoe/files/patch-aoenet.c b/net/aoe/files/patch-aoenet.c new file mode 100644 index 000000000000..91c6f12262da --- /dev/null +++ b/net/aoe/files/patch-aoenet.c @@ -0,0 +1,25 @@ +--- aoenet.c.orig 2010-09-13 12:24:34.000000000 +0700 ++++ aoenet.c 2010-09-13 12:26:12.000000000 +0700 +@@ -77,8 +77,11 @@ + #define NECODES (sizeof(aoe_errlist) / sizeof(char *) - 1) + #if (__FreeBSD_version < 600000) + #define IFPADDR(ifp) (((struct arpcom *) (ifp))->ac_enaddr) +-#else ++#elif (__FreeBSD_version < 700000) + #define IFPADDR(ifp) IFP2ENADDR(ifp) ++#else ++#include ++#define IFPADDR(ifp) IF_LLADDR(ifp) + #endif + #define IFLISTSZ 1024 + +@@ -223,6 +226,9 @@ + + m1->m_ext.ref_cnt = NULL; + MEXTADD(m1, f->f_data, len, nilfn, ++#if (__FreeBSD_version >= 800000) ++ f->f_data, ++#endif + NULL, 0, EXT_NET_DRV); + m1->m_len = len; + m1->m_next = NULL; diff --git a/net/aoe/pkg-descr b/net/aoe/pkg-descr new file mode 100644 index 000000000000..2ef12900d90a --- /dev/null +++ b/net/aoe/pkg-descr @@ -0,0 +1,3 @@ +FreeBSD driver for ATA over Ethernet (AoE) + +WWW: http://www.coraid.com/support/freebsd/ diff --git a/net/aoe/pkg-message b/net/aoe/pkg-message new file mode 100644 index 000000000000..e7c09e95113d --- /dev/null +++ b/net/aoe/pkg-message @@ -0,0 +1,41 @@ +------------------------------------------------------------------------------- +IMPORTANT! MAKE SURE TO READ THE FOLLOWING! + +Please remember to reinstall this port after kernel source update. Using AoE +devices on boot is a little tricky because the network must be up before the +system can access an AoE device. The current rc boot method for automounting +filesystems will not work with AoE devices; vinum and mount -a are both run +before bringing up the network. + +In order to use AoE devices on boot a few rc.conf variables have been defined +that permit the boot script (/etc/rc.d/aoe) to initialize systems using AoE +devices after the network is up. They are as follows: + + aoe_enable Set to "Yes" to enable the aoe startup script. + aoe_iflist A space separated string of interfaces valid for AoE. + aoe_wc Set to "1" to enable write cache on AoE device. + aoe_mounts A space seperated string of AoE device nodes to be mounted. + (An entry for each needs to be in /etc/fstab as well with the + "noauto" option.) + +For example, the following added to /etc/rc.conf: + + aoe_enable="Yes" + aoe_iflist="em0 em1" + aoe_wc="1" + aoe_mounts="/dev/aoed0s1a /dev/aoed1s1a" + +and the following added to /etc/fstab: + + # Device Mountpoint FStype Options Dump Pass# + /dev/aoed0s1a /mnt/a ufs rw,noauto 0 0 + /dev/aoed1s1a /mnt/b ufs rw,noauto 0 0 + +will automatically start the AoE driver and mount the /mnt/a and /mnt/b +"blades". See aoe(4) and http://www.coraid.com/support/freebsd/usingaoe.html +for more information. + +-stacey. + +IMPORTANT! MAKE SURE TO READ THE ABOVE! +------------------------------------------------------------------------------- diff --git a/net/aoe/pkg-plist b/net/aoe/pkg-plist new file mode 100644 index 000000000000..3b620b45484c --- /dev/null +++ b/net/aoe/pkg-plist @@ -0,0 +1,2 @@ +lib/aoe/aoe.ko +@dirrm lib/aoe