Date: Wed, 20 Mar 2013 14:16:56 +0000 (UTC) From: Aleksandr Rybalko <ray@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r248556 - in projects/efika_mx: contrib/llvm/tools/clang/lib/Driver lib/libc/sys sbin/ipfw sbin/ldconfig sbin/shutdown share/man/man4 sys/cam sys/cam/ata sys/cam/scsi sys/dev/ahci sys/d... Message-ID: <201303201416.r2KEGuA6057442@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ray Date: Wed Mar 20 14:16:56 2013 New Revision: 248556 URL: http://svnweb.freebsd.org/changeset/base/248556 Log: MFC @r248554. Modified: projects/efika_mx/contrib/llvm/tools/clang/lib/Driver/Tools.cpp projects/efika_mx/lib/libc/sys/recv.2 projects/efika_mx/lib/libc/sys/socket.2 projects/efika_mx/lib/libc/sys/socketpair.2 projects/efika_mx/sbin/ipfw/ipfw.8 projects/efika_mx/sbin/ipfw/ipfw2.c projects/efika_mx/sbin/ipfw/ipfw2.h projects/efika_mx/sbin/ldconfig/ldconfig.c projects/efika_mx/sbin/shutdown/shutdown.8 projects/efika_mx/share/man/man4/unix.4 projects/efika_mx/sys/cam/ata/ata_da.c projects/efika_mx/sys/cam/cam_ccb.h projects/efika_mx/sys/cam/cam_periph.c projects/efika_mx/sys/cam/scsi/scsi_all.c projects/efika_mx/sys/cam/scsi/scsi_all.h projects/efika_mx/sys/cam/scsi/scsi_cd.c projects/efika_mx/sys/cam/scsi/scsi_da.c projects/efika_mx/sys/dev/ahci/ahci.c projects/efika_mx/sys/dev/ath/if_ath.c projects/efika_mx/sys/dev/ath/if_ath_beacon.c projects/efika_mx/sys/dev/ath/if_ath_rx.c projects/efika_mx/sys/dev/ath/if_ath_rx_edma.c projects/efika_mx/sys/dev/ath/if_ath_tx.c projects/efika_mx/sys/dev/ath/if_ath_tx_edma.c projects/efika_mx/sys/dev/ath/if_athvar.h projects/efika_mx/sys/dev/md/md.c projects/efika_mx/sys/dev/mii/rgephy.c projects/efika_mx/sys/dev/mii/rgephyreg.h projects/efika_mx/sys/dev/siis/siis.c projects/efika_mx/sys/dev/usb/controller/xhci.c projects/efika_mx/sys/geom/geom_disk.c projects/efika_mx/sys/geom/geom_disk.h projects/efika_mx/sys/geom/part/g_part.c projects/efika_mx/sys/kern/kern_physio.c projects/efika_mx/sys/kern/uipc_socket.c projects/efika_mx/sys/kern/uipc_syscalls.c projects/efika_mx/sys/kern/uipc_usrreq.c projects/efika_mx/sys/kern/vfs_aio.c projects/efika_mx/sys/kern/vfs_bio.c projects/efika_mx/sys/net80211/ieee80211_freebsd.c projects/efika_mx/sys/netinet/ip_fw.h projects/efika_mx/sys/netpfil/ipfw/ip_fw2.c projects/efika_mx/sys/netpfil/ipfw/ip_fw_log.c projects/efika_mx/sys/netpfil/ipfw/ip_fw_sockopt.c projects/efika_mx/sys/sys/buf.h projects/efika_mx/sys/sys/domain.h projects/efika_mx/sys/sys/socket.h projects/efika_mx/sys/ufs/ffs/ffs_alloc.c projects/efika_mx/sys/ufs/ffs/ffs_balloc.c projects/efika_mx/sys/ufs/ffs/ffs_rawread.c projects/efika_mx/sys/ufs/ffs/ffs_vfsops.c projects/efika_mx/sys/ufs/ffs/ffs_vnops.c projects/efika_mx/sys/ufs/ufs/ufs_extern.h projects/efika_mx/sys/vm/swap_pager.c projects/efika_mx/sys/vm/swap_pager.h projects/efika_mx/sys/vm/vnode_pager.c Directory Properties: projects/efika_mx/ (props changed) projects/efika_mx/contrib/llvm/ (props changed) projects/efika_mx/contrib/llvm/tools/clang/ (props changed) projects/efika_mx/lib/libc/ (props changed) projects/efika_mx/sbin/ (props changed) projects/efika_mx/sbin/ipfw/ (props changed) projects/efika_mx/share/man/man4/ (props changed) projects/efika_mx/sys/ (props changed) Modified: projects/efika_mx/contrib/llvm/tools/clang/lib/Driver/Tools.cpp ============================================================================== --- projects/efika_mx/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Wed Mar 20 14:16:56 2013 (r248556) @@ -5438,6 +5438,7 @@ void freebsd::Assemble::ConstructJob(Com switch(getToolChain().getTriple().getEnvironment()) { case llvm::Triple::GNUEABI: case llvm::Triple::EABI: + CmdArgs.push_back("-meabi=5"); break; default: Modified: projects/efika_mx/lib/libc/sys/recv.2 ============================================================================== --- projects/efika_mx/lib/libc/sys/recv.2 Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/lib/libc/sys/recv.2 Wed Mar 20 14:16:56 2013 (r248556) @@ -28,7 +28,7 @@ .\" @(#)recv.2 8.3 (Berkeley) 2/21/94 .\" $FreeBSD$ .\" -.Dd September 12, 2012 +.Dd March 19, 2013 .Dt RECV 2 .Os .Sh NAME @@ -121,11 +121,12 @@ argument to a function is formed by .Em or Ap ing one or more of the values: -.Bl -column ".Dv MSG_DONTWAIT" -offset indent +.Bl -column ".Dv MSG_CMSG_CLOEXEC" -offset indent .It Dv MSG_OOB Ta process out-of-band data .It Dv MSG_PEEK Ta peek at incoming message .It Dv MSG_WAITALL Ta wait for full request or error .It Dv MSG_DONTWAIT Ta do not block +.It Dv MSG_CMSG_CLOEXEC Ta set received fds close-on-exec .El .Pp The @@ -227,6 +228,10 @@ and .Fa cmsg_type set to .Dv SCM_RIGHTS . +The close-on-exec flag on received descriptors is set according to the +.Dv MSG_CMSG_CLOEXEC +flag passed to +.Fn recvmsg . .Pp Process credentials can also be passed as ancillary data for .Dv AF_UNIX Modified: projects/efika_mx/lib/libc/sys/socket.2 ============================================================================== --- projects/efika_mx/lib/libc/sys/socket.2 Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/lib/libc/sys/socket.2 Wed Mar 20 14:16:56 2013 (r248556) @@ -28,7 +28,7 @@ .\" From: @(#)socket.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd December 7, 2012 +.Dd March 19, 2013 .Dt SOCKET 2 .Os .Sh NAME @@ -115,6 +115,15 @@ which is available only to the super-use which is planned, but not yet implemented, are not described here. .Pp +Additionally, the following flags are allowed in the +.Fa type +argument: +.Pp +.Bd -literal -offset indent -compact +SOCK_CLOEXEC Set close-on-exec on the new descriptor, +SOCK_NONBLOCK Set non-blocking mode on the new socket +.Ed +.Pp The .Fa protocol argument Modified: projects/efika_mx/lib/libc/sys/socketpair.2 ============================================================================== --- projects/efika_mx/lib/libc/sys/socketpair.2 Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/lib/libc/sys/socketpair.2 Wed Mar 20 14:16:56 2013 (r248556) @@ -28,7 +28,7 @@ .\" @(#)socketpair.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd March 19, 2013 .Dt SOCKETPAIR 2 .Os .Sh NAME @@ -57,6 +57,14 @@ are returned in and .Fa sv Ns [1] . The two sockets are indistinguishable. +.Pp +The +.Dv SOCK_CLOEXEC +and +.Dv SOCK_NONBLOCK +flags in the +.Fa type +argument apply to both descriptors. .Sh RETURN VALUES .Rv -std socketpair .Sh ERRORS @@ -79,6 +87,7 @@ process address space. .Sh SEE ALSO .Xr pipe 2 , .Xr read 2 , +.Xr socket 2 , .Xr write 2 .Sh HISTORY The Modified: projects/efika_mx/sbin/ipfw/ipfw.8 ============================================================================== --- projects/efika_mx/sbin/ipfw/ipfw.8 Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sbin/ipfw/ipfw.8 Wed Mar 20 14:16:56 2013 (r248556) @@ -960,6 +960,61 @@ It is possible to use the keyword with setfib. If the tablearg value is not within the compiled range of fibs, the packet's fib is set to 0. +.It Cm setdscp Ar DSCP | number | tablearg +Set specified DiffServ codepoint for an IPv4/IPv6 packet. +Processing continues at the next rule. +Supported values are: +.Pp +.Cm CS0 +.Pq Dv 000000 , +.Cm CS1 +.Pq Dv 001000 , +.Cm CS2 +.Pq Dv 010000 , +.Cm CS3 +.Pq Dv 011000 , +.Cm CS4 +.Pq Dv 100000 , +.Cm CS5 +.Pq Dv 101000 , +.Cm CS6 +.Pq Dv 110000 , +.Cm CS7 +.Pq Dv 111000 , +.Cm AF11 +.Pq Dv 001010 , +.Cm AF12 +.Pq Dv 001100 , +.Cm AF13 +.Pq Dv 001110 , +.Cm AF21 +.Pq Dv 010010 , +.Cm AF22 +.Pq Dv 010100 , +.Cm AF23 +.Pq Dv 010110 , +.Cm AF31 +.Pq Dv 011010 , +.Cm AF32 +.Pq Dv 011100 , +.Cm AF33 +.Pq Dv 011110 , +.Cm AF41 +.Pq Dv 100010 , +.Cm AF42 +.Pq Dv 100100 , +.Cm AF43 +.Pq Dv 100110 , +.Cm EF +.Pq Dv 101110 , +.Cm BE +.Pq Dv 000000 . +Additionally, DSCP value can be specified by number (0..64). +It is also possible to use the +.Cm tablearg +keyword with setdscp. +If the tablearg value is not within the 0..64 range, lower 6 bits of supplied +value are used. .It Cm reass Queue and reassemble IP fragments. If the packet is not fragmented, counters are updated and @@ -1454,6 +1509,17 @@ The supported IP types of service are: The absence of a particular type may be denoted with a .Ql \&! . +.It Cm dscp spec Ns Op , Ns Ar spec +Matches IPv4/IPv6 packets whose +.Cm DS +field value is contained in +.Ar spec +mask. +Multiple values can be specified via +the comma separated list. +Value can be one of keywords used in +.Cm setdscp +action or exact number. .It Cm ipttl Ar ttl-list Matches IPv4 packets whose time to live is included in .Ar ttl-list , @@ -2976,6 +3042,23 @@ configured on but coming in on .Li fxp1 would be dropped. +.Pp +The +.Cm setdscp +option could be used to (re)mark user traffic, +by adding the following to the appropriate place in ruleset: +.Pp +.Dl "ipfw add setdscp be ip from any to any dscp af11,af21" +.Pp +This rule drops all incoming packets that appear to be coming from another +directly connected system but on the wrong interface. +For example, a packet with a source address of +.Li 192.168.0.0/24 , +configured on +.Li fxp0 , +but coming in on +.Li fxp1 +would be dropped. .Ss DYNAMIC RULES In order to protect a site from flood attacks involving fake TCP packets, it is safer to use dynamic rules: Modified: projects/efika_mx/sbin/ipfw/ipfw2.c ============================================================================== --- projects/efika_mx/sbin/ipfw/ipfw2.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sbin/ipfw/ipfw2.c Wed Mar 20 14:16:56 2013 (r248556) @@ -167,6 +167,32 @@ static struct _s_x f_iptos[] = { { NULL, 0 } }; +static struct _s_x f_ipdscp[] = { + { "af11", IPTOS_DSCP_AF11 >> 2 }, /* 001010 */ + { "af12", IPTOS_DSCP_AF12 >> 2 }, /* 001100 */ + { "af13", IPTOS_DSCP_AF13 >> 2 }, /* 001110 */ + { "af21", IPTOS_DSCP_AF21 >> 2 }, /* 010010 */ + { "af22", IPTOS_DSCP_AF22 >> 2 }, /* 010100 */ + { "af23", IPTOS_DSCP_AF23 >> 2 }, /* 010110 */ + { "af31", IPTOS_DSCP_AF31 >> 2 }, /* 011010 */ + { "af32", IPTOS_DSCP_AF32 >> 2 }, /* 011100 */ + { "af33", IPTOS_DSCP_AF33 >> 2 }, /* 011110 */ + { "af41", IPTOS_DSCP_AF41 >> 2 }, /* 100010 */ + { "af42", IPTOS_DSCP_AF42 >> 2 }, /* 100100 */ + { "af43", IPTOS_DSCP_AF43 >> 2 }, /* 100110 */ + { "be", IPTOS_DSCP_CS0 >> 2 }, /* 000000 */ + { "ef", IPTOS_DSCP_EF >> 2 }, /* 101110 */ + { "cs0", IPTOS_DSCP_CS0 >> 2 }, /* 000000 */ + { "cs1", IPTOS_DSCP_CS1 >> 2 }, /* 001000 */ + { "cs2", IPTOS_DSCP_CS2 >> 2 }, /* 010000 */ + { "cs3", IPTOS_DSCP_CS3 >> 2 }, /* 011000 */ + { "cs4", IPTOS_DSCP_CS4 >> 2 }, /* 100000 */ + { "cs5", IPTOS_DSCP_CS5 >> 2 }, /* 101000 */ + { "cs6", IPTOS_DSCP_CS6 >> 2 }, /* 110000 */ + { "cs7", IPTOS_DSCP_CS7 >> 2 }, /* 100000 */ + { NULL, 0 } +}; + static struct _s_x limit_masks[] = { {"all", DYN_SRC_ADDR|DYN_SRC_PORT|DYN_DST_ADDR|DYN_DST_PORT}, {"src-addr", DYN_SRC_ADDR}, @@ -237,6 +263,7 @@ static struct _s_x rule_actions[] = { { "nat", TOK_NAT }, { "reass", TOK_REASS }, { "setfib", TOK_SETFIB }, + { "setdscp", TOK_SETDSCP }, { "call", TOK_CALL }, { "return", TOK_RETURN }, { NULL, 0 } /* terminator */ @@ -714,6 +741,51 @@ fill_newports(ipfw_insn_u16 *cmd, char * return (i); } +/* + * Fill the body of the command with the list of DiffServ codepoints. + */ +static void +fill_dscp(ipfw_insn *cmd, char *av, int cblen) +{ + uint32_t *low, *high; + char *s = av, *a; + int code; + + cmd->opcode = O_DSCP; + cmd->len |= F_INSN_SIZE(ipfw_insn_u32) + 1; + + CHECK_CMDLEN; + + low = (uint32_t *)(cmd + 1); + high = low + 1; + + *low = 0; + *high = 0; + + while (s != NULL) { + a = strchr(s, ','); + + if (a != NULL) + *a++ = '\0'; + + if (isalpha(*s)) { + if ((code = match_token(f_ipdscp, s)) == -1) + errx(EX_DATAERR, "Unknown DSCP code"); + } else { + code = strtoul(s, NULL, 10); + if (code < 0 || code > 63) + errx(EX_DATAERR, "Invalid DSCP value"); + } + + if (code > 32) + *high |= 1 << (code - 32); + else + *low |= 1 << code; + + s = a; + } +} + static struct _s_x icmpcodes[] = { { "net", ICMP_UNREACH_NET }, { "host", ICMP_UNREACH_HOST }, @@ -972,6 +1044,32 @@ print_icmptypes(ipfw_insn_u32 *cmd) } } +static void +print_dscp(ipfw_insn_u32 *cmd) +{ + int i, c; + uint32_t *v; + char sep= ' '; + const char *code; + + printf(" dscp"); + i = 0; + c = 0; + v = cmd->d; + while (i < 64) { + if (*v & (1 << i)) { + if ((code = match_value(f_ipdscp, i)) != NULL) + printf("%c%s", sep, code); + else + printf("%c%d", sep, i); + sep = ','; + } + + if ((++i % 32) == 0) + v++; + } +} + /* * show_ipfw() prints the body of an ipfw rule. * Because the standard rule has at least proto src_ip dst_ip, we use @@ -1205,6 +1303,17 @@ show_ipfw(struct ip_fw *rule, int pcwidt PRINT_UINT_ARG("setfib ", cmd->arg1); break; + case O_SETDSCP: + { + const char *code; + + if ((code = match_value(f_ipdscp, cmd->arg1)) != NULL) + printf("setdscp %s", code); + else + PRINT_UINT_ARG("setdscp ", cmd->arg1); + } + break; + case O_REASS: printf("reass"); break; @@ -1500,6 +1609,10 @@ show_ipfw(struct ip_fw *rule, int pcwidt printf(" ipprecedence %u", (cmd->arg1) >> 5 ); break; + case O_DSCP: + print_dscp((ipfw_insn_u32 *)cmd); + break; + case O_IPLEN: if (F_LEN(cmd) == 1) printf(" iplen %u", cmd->arg1 ); @@ -3036,6 +3149,24 @@ chkarg: break; } + case TOK_SETDSCP: + { + int code; + + action->opcode = O_SETDSCP; + NEED1("missing DSCP code"); + if (_substrcmp(*av, "tablearg") == 0) { + action->arg1 = IP_FW_TABLEARG; + } else if (isalpha(*av[0])) { + if ((code = match_token(f_ipdscp, *av)) == -1) + errx(EX_DATAERR, "Unknown DSCP code"); + action->arg1 = code; + } else + action->arg1 = strtoul(*av, NULL, 10); + av++; + break; + } + case TOK_REASS: action->opcode = O_REASS; break; @@ -3448,6 +3579,12 @@ read_options: av++; break; + case TOK_DSCP: + NEED1("missing DSCP code"); + fill_dscp(cmd, *av, cblen); + av++; + break; + case TOK_IPOPTS: NEED1("missing argument for ipoptions"); fill_flags(cmd, O_IPOPT, f_ipopts, *av); @@ -3985,10 +4122,9 @@ ipfw_table_handler(int ac, char *av[]) int do_add; int is_all; size_t len; - uint32_t a, mask; + uint32_t a; uint32_t tables_max; - mask = 0; // XXX uninitialized ? len = sizeof(tables_max); if (sysctlbyname("net.inet.ip.fw.tables_max", &tables_max, &len, NULL, 0) == -1) { Modified: projects/efika_mx/sbin/ipfw/ipfw2.h ============================================================================== --- projects/efika_mx/sbin/ipfw/ipfw2.h Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sbin/ipfw/ipfw2.h Wed Mar 20 14:16:56 2013 (r248556) @@ -203,6 +203,7 @@ enum tokens { TOK_SETFIB, TOK_LOOKUP, TOK_SOCKARG, + TOK_SETDSCP, }; /* * the following macro returns an error message if we run out of Modified: projects/efika_mx/sbin/ldconfig/ldconfig.c ============================================================================== --- projects/efika_mx/sbin/ldconfig/ldconfig.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sbin/ldconfig/ldconfig.c Wed Mar 20 14:16:56 2013 (r248556) @@ -97,6 +97,13 @@ static void listhints(void); static int readhints(void); static void usage(void); +/* + * Note on aout/a.out support. + * To properly support shared libraries for compat2x, which are a.out, we need + * to support a.out here. As of 2013, bug reports are still coming in for this + * feature (on amd64 no less), so we know it is still in use. + */ + int main(int argc, char **argv) { Modified: projects/efika_mx/sbin/shutdown/shutdown.8 ============================================================================== --- projects/efika_mx/sbin/shutdown/shutdown.8 Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sbin/shutdown/shutdown.8 Wed Mar 20 14:16:56 2013 (r248556) @@ -28,7 +28,7 @@ .\" @(#)shutdown.8 8.2 (Berkeley) 4/27/95 .\" $FreeBSD$ .\" -.Dd July 13, 2011 +.Dd March 19, 2013 .Dt SHUTDOWN 8 .Os .Sh NAME @@ -189,6 +189,11 @@ tells .Xr login 1 not to let anyone log in .El +.Sh EXAMPLES +Reboot the system in 30 minutes and display a warning message on the terminals +of all users currently logged in: +.Pp +.Dl # shutdown -r +30 \&"System will reboot\&" .Sh COMPATIBILITY The hours and minutes in the second time format may be separated by a colon (``:'') for backward compatibility. Modified: projects/efika_mx/share/man/man4/unix.4 ============================================================================== --- projects/efika_mx/share/man/man4/unix.4 Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/share/man/man4/unix.4 Wed Mar 20 14:16:56 2013 (r248556) @@ -32,7 +32,7 @@ .\" @(#)unix.4 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd November 16, 2012 +.Dd March 19, 2013 .Dt UNIX 4 .Os .Sh NAME @@ -153,13 +153,15 @@ plus the size of the array of file descr .Pp The received descriptor is a .Em duplicate -of the sender's descriptor, as if it were created with a call to -.Xr dup 2 . -Per-process descriptor flags, set with -.Xr fcntl 2 , -are -.Em not -passed to a receiver. +of the sender's descriptor, as if it were created via +.Li dup(fd) +or +.Li fcntl(fd, F_DUPFD_CLOEXEC, 0) +depending on whether +.Dv MSG_CMSG_CLOEXEC +is passed in the +.Xr recvmsg 2 +call. Descriptors that are awaiting delivery, or that are purposely not received, are automatically closed by the system when the destination socket is closed. Modified: projects/efika_mx/sys/cam/ata/ata_da.c ============================================================================== --- projects/efika_mx/sys/cam/ata/ata_da.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/cam/ata/ata_da.c Wed Mar 20 14:16:56 2013 (r248556) @@ -1167,6 +1167,8 @@ adaregister(struct cam_periph *periph, v ((softc->flags & ADA_FLAG_CAN_CFA) && !(softc->flags & ADA_FLAG_CAN_48BIT))) softc->disk->d_flags |= DISKFLAG_CANDELETE; + if ((cpi.hba_misc & PIM_UNMAPPED) != 0) + softc->disk->d_flags |= DISKFLAG_UNMAPPED_BIO; strlcpy(softc->disk->d_descr, cgd->ident_data.model, MIN(sizeof(softc->disk->d_descr), sizeof(cgd->ident_data.model))); strlcpy(softc->disk->d_ident, cgd->ident_data.serial, @@ -1431,13 +1433,19 @@ adastart(struct cam_periph *periph, unio return; } #endif + KASSERT((bp->bio_flags & BIO_UNMAPPED) == 0 || + round_page(bp->bio_bcount + bp->bio_ma_offset) / + PAGE_SIZE == bp->bio_ma_n, + ("Short bio %p", bp)); cam_fill_ataio(ataio, ada_retry_count, adadone, - bp->bio_cmd == BIO_READ ? - CAM_DIR_IN : CAM_DIR_OUT, + (bp->bio_cmd == BIO_READ ? CAM_DIR_IN : + CAM_DIR_OUT) | ((bp->bio_flags & BIO_UNMAPPED) + != 0 ? CAM_DATA_BIO : 0), tag_code, - bp->bio_data, + ((bp->bio_flags & BIO_UNMAPPED) != 0) ? (void *)bp : + bp->bio_data, bp->bio_bcount, ada_default_timeout*1000); Modified: projects/efika_mx/sys/cam/cam_ccb.h ============================================================================== --- projects/efika_mx/sys/cam/cam_ccb.h Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/cam/cam_ccb.h Wed Mar 20 14:16:56 2013 (r248556) @@ -42,7 +42,6 @@ #include <cam/scsi/scsi_all.h> #include <cam/ata/ata_all.h> - /* General allocation length definitions for CCB structures */ #define IOCDBLEN CAM_MAX_CDBLEN /* Space for CDB bytes/pointer */ #define VUHBALEN 14 /* Vendor Unique HBA length */ @@ -100,7 +99,7 @@ typedef enum { CAM_MSGB_VALID = 0x10000000,/* Message buffer valid */ CAM_STATUS_VALID = 0x20000000,/* Status buffer valid */ CAM_DATAB_VALID = 0x40000000,/* Data buffer valid */ - + /* Host target Mode flags */ CAM_SEND_SENSE = 0x08000000,/* Send sense data with status */ CAM_TERM_IO = 0x10000000,/* Terminate I/O Message sup. */ @@ -572,7 +571,8 @@ typedef enum { PIM_NOINITIATOR = 0x20, /* Initiator role not supported. */ PIM_NOBUSRESET = 0x10, /* User has disabled initial BUS RESET */ PIM_NO_6_BYTE = 0x08, /* Do not send 6-byte commands */ - PIM_SEQSCAN = 0x04 /* Do bus scans sequentially, not in parallel */ + PIM_SEQSCAN = 0x04, /* Do bus scans sequentially, not in parallel */ + PIM_UNMAPPED = 0x02, } pi_miscflag; /* Path Inquiry CCB */ Modified: projects/efika_mx/sys/cam/cam_periph.c ============================================================================== --- projects/efika_mx/sys/cam/cam_periph.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/cam/cam_periph.c Wed Mar 20 14:16:56 2013 (r248556) @@ -850,7 +850,7 @@ cam_periph_mapmem(union ccb *ccb, struct * into a larger area of VM, or if userland races against * vmapbuf() after the useracc() check. */ - if (vmapbuf(mapinfo->bp[i]) < 0) { + if (vmapbuf(mapinfo->bp[i], 1) < 0) { for (j = 0; j < i; ++j) { *data_ptrs[j] = mapinfo->bp[j]->b_saveaddr; vunmapbuf(mapinfo->bp[j]); Modified: projects/efika_mx/sys/cam/scsi/scsi_all.c ============================================================================== --- projects/efika_mx/sys/cam/scsi/scsi_all.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/cam/scsi/scsi_all.c Wed Mar 20 14:16:56 2013 (r248556) @@ -5679,7 +5679,11 @@ scsi_read_write(struct ccb_scsiio *csio, u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, u_int32_t timeout) { + int read; u_int8_t cdb_len; + + read = (readop & SCSI_RW_DIRMASK) == SCSI_RW_READ; + /* * Use the smallest possible command to perform the operation * as some legacy hardware does not support the 10 byte commands. @@ -5696,7 +5700,7 @@ scsi_read_write(struct ccb_scsiio *csio, struct scsi_rw_6 *scsi_cmd; scsi_cmd = (struct scsi_rw_6 *)&csio->cdb_io.cdb_bytes; - scsi_cmd->opcode = readop ? READ_6 : WRITE_6; + scsi_cmd->opcode = read ? READ_6 : WRITE_6; scsi_ulto3b(lba, scsi_cmd->addr); scsi_cmd->length = block_count & 0xff; scsi_cmd->control = 0; @@ -5715,7 +5719,7 @@ scsi_read_write(struct ccb_scsiio *csio, struct scsi_rw_10 *scsi_cmd; scsi_cmd = (struct scsi_rw_10 *)&csio->cdb_io.cdb_bytes; - scsi_cmd->opcode = readop ? READ_10 : WRITE_10; + scsi_cmd->opcode = read ? READ_10 : WRITE_10; scsi_cmd->byte2 = byte2; scsi_ulto4b(lba, scsi_cmd->addr); scsi_cmd->reserved = 0; @@ -5738,7 +5742,7 @@ scsi_read_write(struct ccb_scsiio *csio, struct scsi_rw_12 *scsi_cmd; scsi_cmd = (struct scsi_rw_12 *)&csio->cdb_io.cdb_bytes; - scsi_cmd->opcode = readop ? READ_12 : WRITE_12; + scsi_cmd->opcode = read ? READ_12 : WRITE_12; scsi_cmd->byte2 = byte2; scsi_ulto4b(lba, scsi_cmd->addr); scsi_cmd->reserved = 0; @@ -5760,7 +5764,7 @@ scsi_read_write(struct ccb_scsiio *csio, struct scsi_rw_16 *scsi_cmd; scsi_cmd = (struct scsi_rw_16 *)&csio->cdb_io.cdb_bytes; - scsi_cmd->opcode = readop ? READ_16 : WRITE_16; + scsi_cmd->opcode = read ? READ_16 : WRITE_16; scsi_cmd->byte2 = byte2; scsi_u64to8b(lba, scsi_cmd->addr); scsi_cmd->reserved = 0; @@ -5771,7 +5775,8 @@ scsi_read_write(struct ccb_scsiio *csio, cam_fill_csio(csio, retries, cbfcnp, - /*flags*/readop ? CAM_DIR_IN : CAM_DIR_OUT, + (read ? CAM_DIR_IN : CAM_DIR_OUT) | + ((readop & SCSI_RW_BIO) != 0 ? CAM_DATA_BIO : 0), tag_action, data_ptr, dxfer_len, Modified: projects/efika_mx/sys/cam/scsi/scsi_all.h ============================================================================== --- projects/efika_mx/sys/cam/scsi/scsi_all.h Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/cam/scsi/scsi_all.h Wed Mar 20 14:16:56 2013 (r248556) @@ -2354,6 +2354,10 @@ void scsi_write_buffer(struct ccb_scsiio uint8_t *data_ptr, uint32_t param_list_length, uint8_t sense_len, uint32_t timeout); +#define SCSI_RW_READ 0x0001 +#define SCSI_RW_WRITE 0x0002 +#define SCSI_RW_DIRMASK 0x0003 +#define SCSI_RW_BIO 0x1000 void scsi_read_write(struct ccb_scsiio *csio, u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, int readop, u_int8_t byte2, Modified: projects/efika_mx/sys/cam/scsi/scsi_cd.c ============================================================================== --- projects/efika_mx/sys/cam/scsi/scsi_cd.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/cam/scsi/scsi_cd.c Wed Mar 20 14:16:56 2013 (r248556) @@ -1575,7 +1575,8 @@ cdstart(struct cam_periph *periph, union /*retries*/ cd_retry_count, /* cbfcnp */ cddone, MSG_SIMPLE_Q_TAG, - /* read */bp->bio_cmd == BIO_READ, + /* read */bp->bio_cmd == BIO_READ ? + SCSI_RW_READ : SCSI_RW_WRITE, /* byte2 */ 0, /* minimum_cmd_size */ 10, /* lba */ bp->bio_offset / Modified: projects/efika_mx/sys/cam/scsi/scsi_da.c ============================================================================== --- projects/efika_mx/sys/cam/scsi/scsi_da.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/cam/scsi/scsi_da.c Wed Mar 20 14:16:56 2013 (r248556) @@ -1184,7 +1184,7 @@ dadump(void *arg, void *virtual, vm_offs /*retries*/0, dadone, MSG_ORDERED_Q_TAG, - /*read*/FALSE, + /*read*/SCSI_RW_WRITE, /*byte2*/0, /*minimum_cmd_size*/ softc->minimum_cmd_size, offset / secsize, @@ -1757,6 +1757,8 @@ daregister(struct cam_periph *periph, vo softc->disk->d_flags = 0; if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0) softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE; + if ((cpi.hba_misc & PIM_UNMAPPED) != 0) + softc->disk->d_flags |= DISKFLAG_UNMAPPED_BIO; cam_strvis(softc->disk->d_descr, cgd->inq_data.vendor, sizeof(cgd->inq_data.vendor), sizeof(softc->disk->d_descr)); strlcat(softc->disk->d_descr, " ", sizeof(softc->disk->d_descr)); @@ -1985,14 +1987,18 @@ dastart(struct cam_periph *periph, union /*retries*/da_retry_count, /*cbfcnp*/dadone, /*tag_action*/tag_code, - /*read_op*/bp->bio_cmd - == BIO_READ, + /*read_op*/(bp->bio_cmd == BIO_READ ? + SCSI_RW_READ : SCSI_RW_WRITE) | + ((bp->bio_flags & BIO_UNMAPPED) != 0 ? + SCSI_RW_BIO : 0), /*byte2*/0, softc->minimum_cmd_size, /*lba*/bp->bio_pblkno, /*block_count*/bp->bio_bcount / softc->params.secsize, - /*data_ptr*/ bp->bio_data, + /*data_ptr*/ (bp->bio_flags & + BIO_UNMAPPED) != 0 ? (void *)bp : + bp->bio_data, /*dxfer_len*/ bp->bio_bcount, /*sense_len*/SSD_FULL_SIZE, da_default_timeout * 1000); Modified: projects/efika_mx/sys/dev/ahci/ahci.c ============================================================================== --- projects/efika_mx/sys/dev/ahci/ahci.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/dev/ahci/ahci.c Wed Mar 20 14:16:56 2013 (r248556) @@ -2903,7 +2903,7 @@ ahciaction(struct cam_sim *sim, union cc if (ch->caps & AHCI_CAP_SPM) cpi->hba_inquiry |= PI_SATAPM; cpi->target_sprt = 0; - cpi->hba_misc = PIM_SEQSCAN; + cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED; cpi->hba_eng_cnt = 0; if (ch->caps & AHCI_CAP_SPM) cpi->max_target = 15; Modified: projects/efika_mx/sys/dev/ath/if_ath.c ============================================================================== --- projects/efika_mx/sys/dev/ath/if_ath.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/dev/ath/if_ath.c Wed Mar 20 14:16:56 2013 (r248556) @@ -837,6 +837,11 @@ ath_attach(u_int16_t devid, struct ath_s } /* + * Initialise the deferred completed RX buffer list. + */ + TAILQ_INIT(&sc->sc_rx_rxlist); + + /* * Indicate we need the 802.11 header padded to a * 32-bit boundary for 4-address and QoS frames. */ @@ -1711,7 +1716,7 @@ ath_intr(void *arg) * traffic so any frames held on the staging * queue are aged and potentially flushed. */ - taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); + sc->sc_rx.recv_sched(sc, 1); #endif } } @@ -1751,13 +1756,13 @@ ath_intr(void *arg) if (! sc->sc_kickpcu) sc->sc_rxlink = NULL; sc->sc_kickpcu = 1; + ATH_PCU_UNLOCK(sc); /* * Enqueue an RX proc, to handled whatever * is in the RX queue. * This will then kick the PCU. */ - taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); - ATH_PCU_UNLOCK(sc); + sc->sc_rx.recv_sched(sc, 1); } if (status & HAL_INT_TXURN) { sc->sc_stats.ast_txurn++; @@ -1770,7 +1775,7 @@ ath_intr(void *arg) */ if (status & (HAL_INT_RX | HAL_INT_RXHP | HAL_INT_RXLP)) { sc->sc_stats.ast_rx_intr++; - taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); + sc->sc_rx.recv_sched(sc, 1); } if (status & HAL_INT_TX) { sc->sc_stats.ast_tx_intr++; Modified: projects/efika_mx/sys/dev/ath/if_ath_beacon.c ============================================================================== --- projects/efika_mx/sys/dev/ath/if_ath_beacon.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/dev/ath/if_ath_beacon.c Wed Mar 20 14:16:56 2013 (r248556) @@ -570,7 +570,14 @@ ath_beacon_generate(struct ath_softc *sc /* * Move frames from the s/w mcast q to the h/w cab q. - * XXX MORE_DATA bit + * XXX TODO: walk the list, update MORE_DATA bit + * XXX TODO: or maybe, set the MORE data bit in the + * TX descriptor(s) here? + * + * XXX TODO: we're still pushing a CABQ frame list to + * AR9380 hosts; but we don't (yet) populate + * the ATH_BUF_BUSY flag in the EDMA + * completion task (for CABQ, though!) */ bfm = TAILQ_FIRST(&avp->av_mcastq.axq_q); if (cabq->axq_link != NULL) { Modified: projects/efika_mx/sys/dev/ath/if_ath_rx.c ============================================================================== --- projects/efika_mx/sys/dev/ath/if_ath_rx.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/dev/ath/if_ath_rx.c Wed Mar 20 14:16:56 2013 (r248556) @@ -1030,7 +1030,7 @@ rx_proc_next: * will reduce latency. */ if (npkts >= ATH_RX_MAX) - taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); + sc->sc_rx.recv_sched(sc, resched); ATH_PCU_LOCK(sc); sc->sc_rxproc_cnt--; @@ -1181,6 +1181,21 @@ ath_legacy_dma_rxteardown(struct ath_sof return (0); } +static void +ath_legacy_recv_sched(struct ath_softc *sc, int dosched) +{ + + taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); +} + +static void +ath_legacy_recv_sched_queue(struct ath_softc *sc, HAL_RX_QUEUE q, + int dosched) +{ + + taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); +} + void ath_recv_setup_legacy(struct ath_softc *sc) { @@ -1200,4 +1215,6 @@ ath_recv_setup_legacy(struct ath_softc * sc->sc_rx.recv_setup = ath_legacy_dma_rxsetup; sc->sc_rx.recv_teardown = ath_legacy_dma_rxteardown; + sc->sc_rx.recv_sched = ath_legacy_recv_sched; + sc->sc_rx.recv_sched_queue = ath_legacy_recv_sched_queue; } Modified: projects/efika_mx/sys/dev/ath/if_ath_rx_edma.c ============================================================================== --- projects/efika_mx/sys/dev/ath/if_ath_rx_edma.c Wed Mar 20 13:45:15 2013 (r248555) +++ projects/efika_mx/sys/dev/ath/if_ath_rx_edma.c Wed Mar 20 14:16:56 2013 (r248556) @@ -132,12 +132,8 @@ MALLOC_DECLARE(M_ATHDEV); /* * XXX TODO: * - * + Add an RX lock, just to ensure we don't have things clash; * + Make sure the FIFO is correctly flushed and reinitialised * through a reset; - * + Handle the "kickpcu" state where the FIFO overflows. - * + Implement a "flush" routine, which doesn't push any - * new frames into the FIFO. * + Verify multi-descriptor frames work! * + There's a "memory use after free" which needs to be tracked down * and fixed ASAP. I've seen this in the legacy path too, so it @@ -152,7 +148,9 @@ static int ath_edma_rxfifo_alloc(struct int nbufs); static int ath_edma_rxfifo_flush(struct ath_softc *sc, HAL_RX_QUEUE qtype); static void ath_edma_rxbuf_free(struct ath_softc *sc, struct ath_buf *bf); -static int ath_edma_recv_proc_queue(struct ath_softc *sc, +static void ath_edma_recv_proc_queue(struct ath_softc *sc, + HAL_RX_QUEUE qtype, int dosched); +static int ath_edma_recv_proc_deferred_queue(struct ath_softc *sc, HAL_RX_QUEUE qtype, int dosched); static void @@ -283,6 +281,24 @@ ath_edma_startrecv(struct ath_softc *sc) } static void +ath_edma_recv_sched_queue(struct ath_softc *sc, HAL_RX_QUEUE qtype, + int dosched) +{ + + ath_edma_recv_proc_queue(sc, qtype, dosched); + taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); +} + +static void +ath_edma_recv_sched(struct ath_softc *sc, int dosched) +{ + + ath_edma_recv_proc_queue(sc, HAL_RX_QUEUE_HP, dosched); + ath_edma_recv_proc_queue(sc, HAL_RX_QUEUE_LP, dosched); + taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); +} + +static void ath_edma_recv_flush(struct ath_softc *sc) { @@ -292,27 +308,27 @@ ath_edma_recv_flush(struct ath_softc *sc sc->sc_rxproc_cnt++; ATH_PCU_UNLOCK(sc); + /* + * Flush any active frames from FIFO -> deferred list + */ ath_edma_recv_proc_queue(sc, HAL_RX_QUEUE_HP, 0); ath_edma_recv_proc_queue(sc, HAL_RX_QUEUE_LP, 0); + /* + * Process what's in the deferred queue + */ + ath_edma_recv_proc_deferred_queue(sc, HAL_RX_QUEUE_HP, 0); + ath_edma_recv_proc_deferred_queue(sc, HAL_RX_QUEUE_LP, 0); + ATH_PCU_LOCK(sc); sc->sc_rxproc_cnt--; ATH_PCU_UNLOCK(sc); } /* - * Process frames from the current queue. - * - * TODO: - * - * + Add a "dosched" flag, so we don't reschedule any FIFO frames - * to the hardware or re-kick the PCU after 'kickpcu' is set. - * - * + Perhaps split "check FIFO contents" and "handle frames", so - * we can run the "check FIFO contents" in ath_intr(), but - * "handle frames" in the RX tasklet. + * Process frames from the current queue into the deferred queue. */ -static int +static void ath_edma_recv_proc_queue(struct ath_softc *sc, HAL_RX_QUEUE qtype, int dosched) { @@ -323,12 +339,8 @@ ath_edma_recv_proc_queue(struct ath_soft struct mbuf *m; struct ath_hal *ah = sc->sc_ah; uint64_t tsf; - int16_t nf; - int ngood = 0, npkts = 0; - ath_bufhead rxlist; - struct ath_buf *next; - - TAILQ_INIT(&rxlist); + uint16_t nf; + int npkts = 0; tsf = ath_hal_gettsf64(ah); nf = ath_hal_getchannoise(ah, sc->sc_curchan); @@ -386,7 +398,7 @@ ath_edma_recv_proc_queue(struct ath_soft * queue. */ re->m_fifo[re->m_fifo_head] = NULL; - TAILQ_INSERT_TAIL(&rxlist, bf, bf_list); + TAILQ_INSERT_TAIL(&sc->sc_rx_rxlist, bf, bf_list); /* Bump the descriptor FIFO stats */ INCR(re->m_fifo_head, re->m_fifolen); @@ -400,6 +412,78 @@ ath_edma_recv_proc_queue(struct ath_soft ATH_RX_UNLOCK(sc); + /* rx signal state monitoring */ + ath_hal_rxmonitor(ah, &sc->sc_halstats, sc->sc_curchan); + + ATH_KTR(sc, ATH_KTR_INTERRUPTS, 1, + "ath edma rx proc: npkts=%d\n", + npkts); + + /* Handle resched and kickpcu appropriately */ + ATH_PCU_LOCK(sc); + if (dosched && sc->sc_kickpcu) { + ATH_KTR(sc, ATH_KTR_ERROR, 0, + "ath_edma_recv_proc_queue(): kickpcu"); + device_printf(sc->sc_dev, + "%s: handled npkts %d\n", + __func__, npkts); + + /* + * XXX TODO: what should occur here? Just re-poke and + * re-enable the RX FIFO? + */ + sc->sc_kickpcu = 0; + } + ATH_PCU_UNLOCK(sc); + + return; +} + +/* + * Flush the deferred queue. + * + * This destructively flushes the deferred queue - it doesn't + * call the wireless stack on each mbuf. + */ +static void +ath_edma_flush_deferred_queue(struct ath_softc *sc) +{ + struct ath_buf *bf, *next; + + ATH_RX_LOCK_ASSERT(sc); + /* Free in one set, inside the lock */ + TAILQ_FOREACH_SAFE(bf, &sc->sc_rx_rxlist, bf_list, next) { + /* Free the buffer/mbuf */ + ath_edma_rxbuf_free(sc, bf); + } +} + +static int +ath_edma_recv_proc_deferred_queue(struct ath_softc *sc, HAL_RX_QUEUE qtype, + int dosched) +{ + int ngood = 0; + uint64_t tsf; + struct ath_buf *bf, *next; + struct ath_rx_status *rs; + int16_t nf; + ath_bufhead rxlist; + + TAILQ_INIT(&rxlist); + + nf = ath_hal_getchannoise(sc->sc_ah, sc->sc_curchan); + /* *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303201416.r2KEGuA6057442>