From owner-svn-soc-all@freebsd.org Mon Aug 31 08:04:16 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD0349C68CD for ; Mon, 31 Aug 2015 08:04:16 +0000 (UTC) (envelope-from mihai@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BDB381B47 for ; Mon, 31 Aug 2015 08:04:16 +0000 (UTC) (envelope-from mihai@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t7V84GAS044826 for ; Mon, 31 Aug 2015 08:04:16 GMT (envelope-from mihai@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t7V84GeM044819 for svn-soc-all@FreeBSD.org; Mon, 31 Aug 2015 08:04:16 GMT (envelope-from mihai@FreeBSD.org) Date: Mon, 31 Aug 2015 08:04:16 GMT Message-Id: <201508310804.t7V84GeM044819@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mihai@FreeBSD.org using -f From: mihai@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r290375 - soc2015/mihai/bhyve-on-arm-head/sys/arm/fvp_ve-cortex_a15x1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2015 08:04:16 -0000 Author: mihai Date: Mon Aug 31 08:04:15 2015 New Revision: 290375 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290375 Log: sys: arm: fvp_ve-cortex_a15x1: fvp_ve-cortex_a15x1_common.c: use decode function from arm_gic Modified: soc2015/mihai/bhyve-on-arm-head/sys/arm/fvp_ve-cortex_a15x1/fvp_ve-cortex_a15x1_common.c Modified: soc2015/mihai/bhyve-on-arm-head/sys/arm/fvp_ve-cortex_a15x1/fvp_ve-cortex_a15x1_common.c ============================================================================== --- soc2015/mihai/bhyve-on-arm-head/sys/arm/fvp_ve-cortex_a15x1/fvp_ve-cortex_a15x1_common.c Mon Aug 31 07:18:13 2015 (r290374) +++ soc2015/mihai/bhyve-on-arm-head/sys/arm/fvp_ve-cortex_a15x1/fvp_ve-cortex_a15x1_common.c Mon Aug 31 08:04:15 2015 (r290375) @@ -45,28 +45,13 @@ #include #include +#include struct fdt_fixup_entry fdt_fixup_table[] = { { NULL, NULL } }; -static int -fdt_intc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig, - int *pol) -{ - - if (!fdt_is_compatible(node, "arm,cortex-a15-gic")) - return (ENXIO); - - *interrupt = fdt32_to_cpu(intr[0]); - *trig = INTR_TRIGGER_CONFORM; - *pol = INTR_POLARITY_CONFORM; - - return (0); -} - - fdt_pic_decode_t fdt_pic_table[] = { - &fdt_intc_decode_ic, + &gic_decode_fdt, NULL }; From owner-svn-soc-all@freebsd.org Mon Aug 31 08:05:39 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AEB5C9C6A0E for ; Mon, 31 Aug 2015 08:05:39 +0000 (UTC) (envelope-from mihai@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 85C9E1C71 for ; Mon, 31 Aug 2015 08:05:39 +0000 (UTC) (envelope-from mihai@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t7V85d2Q046333 for ; Mon, 31 Aug 2015 08:05:39 GMT (envelope-from mihai@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t7V85cVr046258 for svn-soc-all@FreeBSD.org; Mon, 31 Aug 2015 08:05:38 GMT (envelope-from mihai@FreeBSD.org) Date: Mon, 31 Aug 2015 08:05:38 GMT Message-Id: <201508310805.t7V85cVr046258@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mihai@FreeBSD.org using -f From: mihai@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r290376 - soc2015/mihai/bhyve-on-arm-head/sys/arm/arm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2015 08:05:39 -0000 Author: mihai Date: Mon Aug 31 08:05:38 2015 New Revision: 290376 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290376 Log: sys: arm: arm: gic.c: active-high-level and rising-edge only is for SPI only Modified: soc2015/mihai/bhyve-on-arm-head/sys/arm/arm/gic.c Modified: soc2015/mihai/bhyve-on-arm-head/sys/arm/arm/gic.c ============================================================================== --- soc2015/mihai/bhyve-on-arm-head/sys/arm/arm/gic.c Mon Aug 31 08:04:15 2015 (r290375) +++ soc2015/mihai/bhyve-on-arm-head/sys/arm/arm/gic.c Mon Aug 31 08:05:38 2015 (r290376) @@ -62,6 +62,7 @@ #ifdef VMM_ARM_VGIC { SYS_RES_MEMORY, 2, RF_ACTIVE }, /* Virtual Interface Control */ { SYS_RES_MEMORY, 3, RF_ACTIVE }, /* Virtual CPU interface */ +// { SYS_RES_IRQ, 4, RF_ACTIVE }, /* vGIC maintenance interrupt */ #endif { -1, 0 } }; @@ -152,10 +153,6 @@ *trig = INTR_TRIGGER_CONFORM; *pol = INTR_POLARITY_CONFORM; } else { - if (fdt32_to_cpu(intr[0]) == 0) - *interrupt = fdt32_to_cpu(intr[1]) + GIC_FIRST_SPI; - else - *interrupt = fdt32_to_cpu(intr[1]) + GIC_FIRST_PPI; /* * In intr[2], bits[3:0] are trigger type and level flags. * 1 = low-to-high edge triggered @@ -164,13 +161,19 @@ * 8 = active low level-sensitive * The hardware only supports active-high-level or rising-edge. */ - if (fdt32_to_cpu(intr[2]) & 0x0a) { - printf("unsupported trigger/polarity configuration " - "0x%2x\n", fdt32_to_cpu(intr[2]) & 0x0f); - return (ENOTSUP); + if (fdt32_to_cpu(intr[0]) == 0) { + if (fdt32_to_cpu(intr[2]) & 0x0a) { + printf("unsupported trigger/polarity configuration " + "0x%2x\n", fdt32_to_cpu(intr[2]) & 0x0f); + return (ENOTSUP); + } + *interrupt = fdt32_to_cpu(intr[1]) + GIC_FIRST_SPI; + } else { + *interrupt = fdt32_to_cpu(intr[1]) + GIC_FIRST_PPI; } + *pol = INTR_POLARITY_CONFORM; - if (fdt32_to_cpu(intr[2]) & 0x01) + if (fdt32_to_cpu(intr[2]) & 0x03) *trig = INTR_TRIGGER_EDGE; else *trig = INTR_TRIGGER_LEVEL; From owner-svn-soc-all@freebsd.org Mon Aug 31 08:08:43 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82EF39C6B29 for ; Mon, 31 Aug 2015 08:08:43 +0000 (UTC) (envelope-from mihai@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 59B071CE1 for ; Mon, 31 Aug 2015 08:08:43 +0000 (UTC) (envelope-from mihai@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t7V88hqE049475 for ; Mon, 31 Aug 2015 08:08:43 GMT (envelope-from mihai@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t7V88gdC049473 for svn-soc-all@FreeBSD.org; Mon, 31 Aug 2015 08:08:42 GMT (envelope-from mihai@FreeBSD.org) Date: Mon, 31 Aug 2015 08:08:42 GMT Message-Id: <201508310808.t7V88gdC049473@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mihai@FreeBSD.org using -f From: mihai@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r290377 - soc2015/mihai/bhyve-on-arm-head/sys/boot/fdt/dts/arm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2015 08:08:43 -0000 Author: mihai Date: Mon Aug 31 08:08:42 2015 New Revision: 290377 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290377 Log: sys: boot: fdt: dts: arm: fvp_ve-cortex_a15x1.dts: improve interrupts with info about SPI/PPI and trigger type Modified: soc2015/mihai/bhyve-on-arm-head/sys/boot/fdt/dts/arm/fvp_ve-cortex_a15x1.dts Modified: soc2015/mihai/bhyve-on-arm-head/sys/boot/fdt/dts/arm/fvp_ve-cortex_a15x1.dts ============================================================================== --- soc2015/mihai/bhyve-on-arm-head/sys/boot/fdt/dts/arm/fvp_ve-cortex_a15x1.dts Mon Aug 31 08:05:38 2015 (r290376) +++ soc2015/mihai/bhyve-on-arm-head/sys/boot/fdt/dts/arm/fvp_ve-cortex_a15x1.dts Mon Aug 31 08:08:42 2015 (r290377) @@ -43,16 +43,20 @@ gic: interrupt-controller@2c001000 { compatible = "arm,cortex-a15-gic"; interrupt-controller; - #interrupt-cells = <1>; + #interrupt-cells = <3>; reg = <0x2c001000 0x1000>, <0x2c002000 0x2000>, <0x2c004000 0x2000>, <0x2c006000 0x2000>; + interrupts = <1 9 0x8>; }; generic_timer { compatible = "arm,armv7-timer"; clock-frequency = <24000000>; - interrupts = < 29 30 27 26 >; + interrupts = <1 13 0x4>, + <1 14 0x4>, + <1 11 0x4>, + <1 10 0x4>; interrupt-parent = <&gic>; }; @@ -60,41 +64,41 @@ compatible = "arm,pl011", "arm,primecell"; reg = <0x1c090000 0x1000>; interrupt-parent=<&gic>; - interrupts = <37>; + interrupts = <0 5 0x4>; }; v2m_serial1: uart@1c0a0000 { compatible = "arm,pl011", "arm,primecell"; reg = <0x1c0a0000 0x1000>; interrupt-parent=<&gic>; - interrupts = <38>; + interrupts = <0 6 0x4>; }; v2m_serial2: uart@1c0b0000 { compatible = "arm,pl011", "arm,primecell"; reg = <0x1c0b0000 0x1000>; interrupt-parent=<&gic>; - interrupts = <39>; + interrupts = <0 7 0x4>; }; v2m_serial3: uart@1c0c0000 { compatible = "arm,pl011", "arm,primecell"; reg = <0x1c0c0000 0x1000>; interrupt-parent=<&gic>; - interrupts = <40>; + interrupts = <0 8 0x4>; }; v2m_timer01: timer@1c110000 { compatible = "arm,sp804", "arm,primecell"; reg = <0x1c110000 0x1000>; interrupt-parent=<&gic>; - interrupts = <34>; + interrupts = <0 2 0x4>; }; v2m_timer23: timer@1c120000 { compatible = "arm,sp804", "arm,primecell"; reg = <0x1c120000 0x1000>; interrupt-parent=<&gic>; - interrupts = <35>; + interrupts = <0 3 0x4>; }; }; From owner-svn-soc-all@freebsd.org Mon Aug 31 10:29:18 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEC279C7B65 for ; Mon, 31 Aug 2015 10:29:18 +0000 (UTC) (envelope-from mihai@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B561B10CD for ; Mon, 31 Aug 2015 10:29:18 +0000 (UTC) (envelope-from mihai@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t7VATIVD068032 for ; Mon, 31 Aug 2015 10:29:18 GMT (envelope-from mihai@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t7VATImn068025 for svn-soc-all@FreeBSD.org; Mon, 31 Aug 2015 10:29:18 GMT (envelope-from mihai@FreeBSD.org) Date: Mon, 31 Aug 2015 10:29:18 GMT Message-Id: <201508311029.t7VATImn068025@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mihai@FreeBSD.org using -f From: mihai@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r290379 - soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2015 10:29:19 -0000 Author: mihai Date: Mon Aug 31 10:29:17 2015 New Revision: 290379 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290379 Log: sys: arm: vmm: vgic.c: discover maintenance interrupts for the vGIC Modified: soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm/vgic.c Modified: soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm/vgic.c ============================================================================== --- soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm/vgic.c Mon Aug 31 09:39:16 2015 (r290378) +++ soc2015/mihai/bhyve-on-arm-head/sys/arm/vmm/vgic.c Mon Aug 31 10:29:17 2015 (r290379) @@ -34,6 +34,13 @@ static uint32_t lr_num; +static struct resource_spec arm_vgic_maintenance_intr_spec[] = { + { SYS_RES_IRQ, 0, RF_ACTIVE }, /* vGIC maintenance interrupt */ + { -1, 0 } +}; +static struct resource *arm_vgic_maintenance_intr_res[1]; +static void *arm_vgic_maintenance_intr_ihl[1]; + static int vgic_dist_mmio_read(void *vm, int vcpuid, uint64_t gpa, uint64_t *rval, int size, void *arg) @@ -110,9 +117,24 @@ return (0); } +static int +vgic_maintenance_intr(void *arg) +{ + + static struct arm_gic_softc *sc; + + sc = (struct arm_gic_softc *)arg; + + printf("%s\n",__func__); + + return (FILTER_HANDLED); +} + int vgic_hyp_init(void) { + int error; + if (!(gic_sc = get_arm_gic_sc())) { printf("vgic_hyp_init: GIC no present\n"); return (ENXIO); @@ -136,6 +158,20 @@ lr_num = (gic_h_read_4(gic_sc, GICH_VTR) & 0x3f) + 1; + if (bus_alloc_resources(gic_sc->gic_dev, arm_vgic_maintenance_intr_spec, arm_vgic_maintenance_intr_res)) { + printf("vgic_hyp_init: Could not allocate maintenance IRQ resource\n"); + + return (ENXIO); + } + + /* Register the vGIC maintenance interrupt */ + error = bus_setup_intr(gic_sc->gic_dev, arm_vgic_maintenance_intr_res[0], INTR_TYPE_CLK, + vgic_maintenance_intr, NULL, gic_sc, &arm_vgic_maintenance_intr_ihl[0]); + if (error) { + printf("vgic_hyp_init: Unable to setup maintenance interrupt\n"); + return (ENXIO); + } + lpae_vmmmap_set(NULL, (lpae_vm_vaddr_t)virtual_int_ctrl_vaddr, (lpae_vm_paddr_t)virtual_int_ctrl_paddr, From owner-svn-soc-all@freebsd.org Mon Aug 31 13:43:06 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40B0E9C6A09 for ; Mon, 31 Aug 2015 13:43:06 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EFBE1A7F for ; Mon, 31 Aug 2015 13:43:06 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t7VDh6WU075369 for ; Mon, 31 Aug 2015 13:43:06 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t7VDh3J6075338 for svn-soc-all@FreeBSD.org; Mon, 31 Aug 2015 13:43:03 GMT (envelope-from btw@FreeBSD.org) Date: Mon, 31 Aug 2015 13:43:03 GMT Message-Id: <201508311343.t7VDh3J6075338@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r290383 - in soc2015/btw/head: . sys sys/netinet sys/netinet6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2015 13:43:06 -0000 Author: btw Date: Mon Aug 31 13:43:02 2015 New Revision: 290383 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290383 Log: Merge head r290330 through r290331. Modified: soc2015/btw/head/ (props changed) soc2015/btw/head/sys/ (props changed) soc2015/btw/head/sys/netinet/in_rss.c soc2015/btw/head/sys/netinet/in_rss.h soc2015/btw/head/sys/netinet/ip_input.c soc2015/btw/head/sys/netinet6/in6_rss.c soc2015/btw/head/sys/netinet6/in6_rss.h soc2015/btw/head/sys/netinet6/ip6_input.c soc2015/btw/head/sys/netinet6/ip6_var.h Modified: soc2015/btw/head/sys/netinet/in_rss.c ============================================================================== --- soc2015/btw/head/sys/netinet/in_rss.c Mon Aug 31 12:42:21 2015 (r290382) +++ soc2015/btw/head/sys/netinet/in_rss.c Mon Aug 31 13:43:02 2015 (r290383) @@ -332,7 +332,7 @@ * XXX TODO: definitely want statistics here! */ struct mbuf * -rss_soft_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid) +rss_soft_m2cpuid_v4(struct mbuf *m, uintptr_t source, u_int *cpuid) { uint32_t hash_val, hash_type; int ret; Modified: soc2015/btw/head/sys/netinet/in_rss.h ============================================================================== --- soc2015/btw/head/sys/netinet/in_rss.h Mon Aug 31 12:42:21 2015 (r290382) +++ soc2015/btw/head/sys/netinet/in_rss.h Mon Aug 31 13:43:02 2015 (r290383) @@ -51,7 +51,7 @@ struct in_addr dst, u_short src_port, u_short dst_port, int proto, uint32_t *hashval, uint32_t *hashtype); -struct mbuf * rss_soft_m2cpuid(struct mbuf *m, uintptr_t source, +struct mbuf * rss_soft_m2cpuid_v4(struct mbuf *m, uintptr_t source, u_int *cpuid); #endif /* !_NETINET_IN_RSS_H_ */ Modified: soc2015/btw/head/sys/netinet/ip_input.c ============================================================================== --- soc2015/btw/head/sys/netinet/ip_input.c Mon Aug 31 12:42:21 2015 (r290382) +++ soc2015/btw/head/sys/netinet/ip_input.c Mon Aug 31 13:43:02 2015 (r290383) @@ -139,7 +139,7 @@ .nh_handler = ip_input, .nh_proto = NETISR_IP, #ifdef RSS - .nh_m2cpuid = rss_soft_m2cpuid, + .nh_m2cpuid = rss_soft_m2cpuid_v4, .nh_policy = NETISR_POLICY_CPU, .nh_dispatch = NETISR_DISPATCH_HYBRID, #else Modified: soc2015/btw/head/sys/netinet6/in6_rss.c ============================================================================== --- soc2015/btw/head/sys/netinet6/in6_rss.c Mon Aug 31 12:42:21 2015 (r290382) +++ soc2015/btw/head/sys/netinet6/in6_rss.c Mon Aug 31 13:43:02 2015 (r290383) @@ -58,7 +58,8 @@ #include /* for software rss hash support */ -#include +#include +#include #include #include @@ -150,3 +151,207 @@ RSS_DEBUG("no available hashtypes!\n"); return (-1); } + +/* + * Do a software calculation of the RSS for the given mbuf. + * + * This is typically used by the input path to recalculate the RSS after + * some form of packet processing (eg de-capsulation, IP fragment reassembly.) + * + * dir is the packet direction - RSS_HASH_PKT_INGRESS for incoming and + * RSS_HASH_PKT_EGRESS for outgoing. + * + * Returns 0 if a hash was done, -1 if no hash was done, +1 if + * the mbuf already had a valid RSS flowid. + * + * This function doesn't modify the mbuf. It's up to the caller to + * assign flowid/flowtype as appropriate. + */ +int +rss_mbuf_software_hash_v6(const struct mbuf *m, int dir, uint32_t *hashval, + uint32_t *hashtype) +{ + const struct ip6_hdr *ip6; + const struct tcphdr *th; + const struct udphdr *uh; + uint32_t flowtype; + uint8_t proto; + int off, newoff; + int nxt; + + /* + * XXX For now this only handles hashing on incoming mbufs. + */ + if (dir != RSS_HASH_PKT_INGRESS) { + RSS_DEBUG("called on EGRESS packet!\n"); + return (-1); + } + + off = sizeof(struct ip6_hdr); + + /* + * First, validate that the mbuf we have is long enough + * to have an IPv6 header in it. + */ + if (m->m_pkthdr.len < off) { + RSS_DEBUG("short mbuf pkthdr\n"); + return (-1); + } + if (m->m_len < off) { + RSS_DEBUG("short mbuf len\n"); + return (-1); + } + + /* Ok, let's dereference that */ + ip6 = mtod(m, struct ip6_hdr *); + proto = ip6->ip6_nxt; + + /* + * Find the beginning of the TCP/UDP header. + * + * If this is a fragment then it shouldn't be four-tuple + * hashed just yet. Once it's reassembled into a full + * frame it should be re-hashed. + */ + while (proto != IPPROTO_FRAGMENT) { + newoff = ip6_nexthdr(m, off, proto, &nxt); + if (newoff < 0) + break; + off = newoff; + proto = nxt; + } + + /* + * If the mbuf flowid/flowtype matches the packet type, + * and we don't support the 4-tuple version of the given protocol, + * then signal to the owner that it can trust the flowid/flowtype + * details. + * + * This is a little picky - eg, if TCPv6 / UDPv6 hashing + * is supported but we got a TCP/UDP frame only 2-tuple hashed, + * then we shouldn't just "trust" the 2-tuple hash. We need + * a 4-tuple hash. + */ + flowtype = M_HASHTYPE_GET(m); + + if (flowtype != M_HASHTYPE_NONE) { + switch (proto) { + case IPPROTO_UDP: + if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV6) && + (flowtype == M_HASHTYPE_RSS_UDP_IPV6)) { + return (1); + } + /* + * Only allow 2-tuple for UDP frames if we don't also + * support 4-tuple for UDP. + */ + if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV6) && + ((rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV6) == 0) && + flowtype == M_HASHTYPE_RSS_IPV6) { + return (1); + } + break; + case IPPROTO_TCP: + if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV6) && + (flowtype == M_HASHTYPE_RSS_TCP_IPV6)) { + return (1); + } + /* + * Only allow 2-tuple for TCP frames if we don't also + * support 4-tuple for TCP. + */ + if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV6) && + ((rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV6) == 0) && + flowtype == M_HASHTYPE_RSS_IPV6) { + return (1); + } + break; + default: + if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV6) && + flowtype == M_HASHTYPE_RSS_IPV6) { + return (1); + } + break; + } + } + + /* + * Decode enough information to make a hash decision. + */ + if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV6) && + (proto == IPPROTO_TCP)) { + if (m->m_len < off + sizeof(struct tcphdr)) { + RSS_DEBUG("short TCP frame?\n"); + return (-1); + } + th = (const struct tcphdr *)((c_caddr_t)ip6 + off); + return rss_proto_software_hash_v6(&ip6->ip6_src, &ip6->ip6_dst, + th->th_sport, + th->th_dport, + proto, + hashval, + hashtype); + } else if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV6) && + (proto == IPPROTO_UDP)) { + if (m->m_len < off + sizeof(struct udphdr)) { + RSS_DEBUG("short UDP frame?\n"); + return (-1); + } + uh = (const struct udphdr *)((c_caddr_t)ip6 + off); + return rss_proto_software_hash_v6(&ip6->ip6_src, &ip6->ip6_dst, + uh->uh_sport, + uh->uh_dport, + proto, + hashval, + hashtype); + } else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV6) { + /* Default to 2-tuple hash */ + return rss_proto_software_hash_v6(&ip6->ip6_src, &ip6->ip6_dst, + 0, /* source port */ + 0, /* destination port */ + 0, /* IPPROTO_IP */ + hashval, + hashtype); + } else { + RSS_DEBUG("no available hashtypes!\n"); + return (-1); + } +} + +/* + * Similar to rss_m2cpuid, but designed to be used by the IPv6 NETISR + * on incoming frames. + * + * If an existing RSS hash exists and it matches what the configured + * hashing is, then use it. + * + * If there's an existing RSS hash but the desired hash is different, + * or if there's no useful RSS hash, then calculate it via + * the software path. + * + * XXX TODO: definitely want statistics here! + */ +struct mbuf * +rss_soft_m2cpuid_v6(struct mbuf *m, uintptr_t source, u_int *cpuid) +{ + uint32_t hash_val, hash_type; + int ret; + + M_ASSERTPKTHDR(m); + + ret = rss_mbuf_software_hash_v6(m, RSS_HASH_PKT_INGRESS, + &hash_val, &hash_type); + if (ret > 0) { + /* mbuf has a valid hash already; don't need to modify it */ + *cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m)); + } else if (ret == 0) { + /* hash was done; update */ + m->m_pkthdr.flowid = hash_val; + M_HASHTYPE_SET(m, hash_type); + *cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m)); + } else { /* ret < 0 */ + /* no hash was done */ + *cpuid = NETISR_CPUID_NONE; + } + return (m); +} Modified: soc2015/btw/head/sys/netinet6/in6_rss.h ============================================================================== --- soc2015/btw/head/sys/netinet6/in6_rss.h Mon Aug 31 12:42:21 2015 (r290382) +++ soc2015/btw/head/sys/netinet6/in6_rss.h Mon Aug 31 13:43:02 2015 (r290383) @@ -46,9 +46,13 @@ * Functions to calculate a software RSS hash for a given mbuf or * packet detail. */ +int rss_mbuf_software_hash_v6(const struct mbuf *m, int dir, + uint32_t *hashval, uint32_t *hashtype); int rss_proto_software_hash_v6(const struct in6_addr *src, const struct in6_addr *dst, u_short src_port, u_short dst_port, int proto, uint32_t *hashval, uint32_t *hashtype); +struct mbuf * rss_soft_m2cpuid_v6(struct mbuf *m, uintptr_t source, + u_int *cpuid); #endif /* !_NETINET6_IN6_RSS_H_ */ Modified: soc2015/btw/head/sys/netinet6/ip6_input.c ============================================================================== --- soc2015/btw/head/sys/netinet6/ip6_input.c Mon Aug 31 12:42:21 2015 (r290382) +++ soc2015/btw/head/sys/netinet6/ip6_input.c Mon Aug 31 13:43:02 2015 (r290383) @@ -68,6 +68,7 @@ #include "opt_ipfw.h" #include "opt_ipsec.h" #include "opt_route.h" +#include "opt_rss.h" #include #include @@ -110,6 +111,7 @@ #include #include #include +#include #ifdef IPSEC #include @@ -130,7 +132,13 @@ .nh_name = "ip6", .nh_handler = ip6_input, .nh_proto = NETISR_IPV6, +#ifdef RSS + .nh_m2cpuid = rss_soft_m2cpuid_v6, + .nh_policy = NETISR_POLICY_CPU, + .nh_dispatch = NETISR_DISPATCH_HYBRID, +#else .nh_policy = NETISR_POLICY_FLOW, +#endif }; VNET_DECLARE(struct callout, in6_tmpaddrtimer_ch); @@ -1440,7 +1448,7 @@ * we develop `neater' mechanism to process extension headers. */ char * -ip6_get_prevhdr(struct mbuf *m, int off) +ip6_get_prevhdr(const struct mbuf *m, int off) { struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); @@ -1479,7 +1487,7 @@ * get next header offset. m will be retained. */ int -ip6_nexthdr(struct mbuf *m, int off, int proto, int *nxtp) +ip6_nexthdr(const struct mbuf *m, int off, int proto, int *nxtp) { struct ip6_hdr ip6; struct ip6_ext ip6e; @@ -1547,14 +1555,14 @@ return -1; } - return -1; + /* NOTREACHED */ } /* * get offset for the last header in the chain. m will be kept untainted. */ int -ip6_lasthdr(struct mbuf *m, int off, int proto, int *nxtp) +ip6_lasthdr(const struct mbuf *m, int off, int proto, int *nxtp) { int newoff; int nxt; Modified: soc2015/btw/head/sys/netinet6/ip6_var.h ============================================================================== --- soc2015/btw/head/sys/netinet6/ip6_var.h Mon Aug 31 12:42:21 2015 (r290382) +++ soc2015/btw/head/sys/netinet6/ip6_var.h Mon Aug 31 13:43:02 2015 (r290383) @@ -356,9 +356,9 @@ void ip6_freepcbopts(struct ip6_pktopts *); int ip6_unknown_opt(u_int8_t *, struct mbuf *, int); -char * ip6_get_prevhdr(struct mbuf *, int); -int ip6_nexthdr(struct mbuf *, int, int, int *); -int ip6_lasthdr(struct mbuf *, int, int, int *); +char * ip6_get_prevhdr(const struct mbuf *, int); +int ip6_nexthdr(const struct mbuf *, int, int, int *); +int ip6_lasthdr(const struct mbuf *, int, int, int *); extern int (*ip6_mforward)(struct ip6_hdr *, struct ifnet *, struct mbuf *);