From owner-svn-src-stable-10@freebsd.org Sun Jun 12 02:42:10 2016 Return-Path: Delivered-To: svn-src-stable-10@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 F3114AF08D6; Sun, 12 Jun 2016 02:42:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C0311246F; Sun, 12 Jun 2016 02:42:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5C2g8WT046899; Sun, 12 Jun 2016 02:42:08 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5C2g8N2046898; Sun, 12 Jun 2016 02:42:08 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606120242.u5C2g8N2046898@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 12 Jun 2016 02:42:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301835 - stable/10/sys/amd64/amd64 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jun 2016 02:42:10 -0000 Author: kib Date: Sun Jun 12 02:42:08 2016 New Revision: 301835 URL: https://svnweb.freebsd.org/changeset/base/301835 Log: MFC r301457: Avoid spurious EINVAL in amd64 pmap_change_attr(). Modified: stable/10/sys/amd64/amd64/pmap.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/amd64/pmap.c ============================================================================== --- stable/10/sys/amd64/amd64/pmap.c Sat Jun 11 14:46:49 2016 (r301834) +++ stable/10/sys/amd64/amd64/pmap.c Sun Jun 12 02:42:08 2016 (r301835) @@ -6480,7 +6480,7 @@ static int pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode) { vm_offset_t base, offset, tmpva; - vm_paddr_t pa_start, pa_end; + vm_paddr_t pa_start, pa_end, pa_end1; pdp_entry_t *pdpe; pd_entry_t *pde; pt_entry_t *pte; @@ -6660,9 +6660,12 @@ pmap_change_attr_locked(vm_offset_t va, tmpva += PAGE_SIZE; } } - if (error == 0 && pa_start != pa_end) - error = pmap_change_attr_locked(PHYS_TO_DMAP(pa_start), - pa_end - pa_start, mode); + if (error == 0 && pa_start != pa_end && pa_start < dmaplimit) { + pa_end1 = MIN(pa_end, dmaplimit); + if (pa_start != pa_end1) + error = pmap_change_attr_locked(PHYS_TO_DMAP(pa_start), + pa_end1 - pa_start, mode); + } /* * Flush CPU caches if required to make sure any data isn't cached that From owner-svn-src-stable-10@freebsd.org Sun Jun 12 05:57:44 2016 Return-Path: Delivered-To: svn-src-stable-10@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 9D188AF0508; Sun, 12 Jun 2016 05:57:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 531CA2544; Sun, 12 Jun 2016 05:57:44 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5C5vhFm016948; Sun, 12 Jun 2016 05:57:43 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5C5vghj016935; Sun, 12 Jun 2016 05:57:42 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201606120557.u5C5vghj016935@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 12 Jun 2016 05:57:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301836 - stable/10/contrib/top X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jun 2016 05:57:44 -0000 Author: ngie Date: Sun Jun 12 05:57:42 2016 New Revision: 301836 URL: https://svnweb.freebsd.org/changeset/base/301836 Log: MFC r300395: Silence top(1) compiler warnings The contrib/top code is no longer maintained upstream (last pulled 16 years ago). The K&R-style followed by the code spews -Wimplicit-int and -Wreturn-type warnings, amongst others. This silences 131 warnings with as little modification as possible by adding necessary return types, definitions, headers, and header guards, and missing header includes. The 5 warnings that remain are due to undeclared ncurses references. I didn't include curses.h and term.h because there are several local functions and macros that conflict with those definitions. Added: stable/10/contrib/top/commands.h - copied unchanged from r300395, head/contrib/top/commands.h stable/10/contrib/top/username.h - copied unchanged from r300395, head/contrib/top/username.h Modified: stable/10/contrib/top/commands.c stable/10/contrib/top/display.c stable/10/contrib/top/display.h stable/10/contrib/top/machine.h stable/10/contrib/top/screen.c stable/10/contrib/top/screen.h stable/10/contrib/top/top.c stable/10/contrib/top/top.h stable/10/contrib/top/username.c stable/10/contrib/top/utils.h stable/10/contrib/top/version.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/top/commands.c ============================================================================== --- stable/10/contrib/top/commands.c Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/commands.c Sun Jun 12 05:57:42 2016 (r301836) @@ -19,16 +19,21 @@ */ #include "os.h" -#include -#include -#include + #include #include +#include +#include +#include +#include + +#include "commands.h" #include "sigdesc.h" /* generated automatically */ #include "top.h" #include "boolean.h" #include "utils.h" +#include "machine.h" extern int errno; @@ -39,12 +44,15 @@ extern int overstrike; int err_compar(); char *err_string(); +static int str_adderr(char *str, int len, int err); +static int str_addarg(char *str, int len, char *arg, int first); /* * show_help() - display the help screen; invoked in response to * either 'h' or '?'. */ +void show_help() { @@ -123,6 +131,7 @@ register char *str; return(*str == '\0' ? NULL : str); } +int scanint(str, intp) char *str; @@ -262,6 +271,7 @@ char *err_string() * the string "str". */ +static int str_adderr(str, len, err) char *str; @@ -289,6 +299,7 @@ int err; * is set (indicating that a comma should NOT be added to the front). */ +static int str_addarg(str, len, arg, first) char *str; @@ -321,6 +332,7 @@ int first; * for sorting errors. */ +int err_compar(p1, p2) register struct errs *p1, *p2; @@ -339,6 +351,7 @@ register struct errs *p1, *p2; * error_count() - return the number of errors currently logged. */ +int error_count() { @@ -349,6 +362,7 @@ error_count() * show_errors() - display on stdout the current log of errors. */ +void show_errors() { Copied: stable/10/contrib/top/commands.h (from r300395, head/contrib/top/commands.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/top/commands.h Sun Jun 12 05:57:42 2016 (r301836, copy of r300395, head/contrib/top/commands.h) @@ -0,0 +1,21 @@ +/* + * Top users/processes display for Unix + * Version 3 + * + * This program may be freely redistributed, + * but this entire comment MUST remain intact. + * + * Copyright (c) 1984, 1989, William LeFebvre, Rice University + * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University + * Copyright (c) 2016, Randy Westlund + * + * $FreeBSD$ + */ +#ifndef COMMANDS_H +#define COMMANDS_H + +void show_errors(void); +int error_count(void); +void show_help(void); + +#endif /* COMMANDS_H */ Modified: stable/10/contrib/top/display.c ============================================================================== --- stable/10/contrib/top/display.c Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/display.c Sun Jun 12 05:57:42 2016 (r301836) @@ -29,9 +29,12 @@ */ #include "os.h" + +#include + #include #include -#include +#include #include "screen.h" /* interface to screen package */ #include "layout.h" /* defines for screen position layout */ @@ -56,7 +59,6 @@ static int display_width = MAX_COLS; #define lineindex(l) ((l)*display_width) -char *printable(); /* things initialized by display_init and used thruout */ @@ -239,6 +241,7 @@ struct statics *statics; return(lines); } +void i_loadave(mpid, avenrun) int mpid; @@ -267,6 +270,7 @@ double *avenrun; lmpid = mpid; } +void u_loadave(mpid, avenrun) int mpid; @@ -306,6 +310,7 @@ double *avenrun; } } +void i_timeofday(tod) time_t *tod; @@ -351,6 +356,7 @@ static char procstates_buffer[MAX_COLS]; * lastline is valid */ +void i_procstates(total, brkdn) int total; @@ -378,6 +384,7 @@ int *brkdn; memcpy(lprocstates, brkdn, num_procstates * sizeof(int)); } +void u_procstates(total, brkdn) int total; @@ -460,9 +467,10 @@ char *cpustates_tag() } #endif +void i_cpustates(states) -register int *states; +int *states; { register int i = 0; @@ -505,9 +513,10 @@ for (cpu = 0; cpu < num_cpus; cpu++) { memcpy(lcpustates, states, num_cpustates * sizeof(int) * num_cpus); } +void u_cpustates(states) -register int *states; +int *states; { register int value; @@ -557,6 +566,7 @@ for (cpu = 0; cpu < num_cpus; cpu++) { } } +void z_cpustates() { @@ -606,6 +616,7 @@ for (cpu = 0; cpu < num_cpus; cpu++) { char memory_buffer[MAX_COLS]; +void i_memory(stats) int *stats; @@ -619,6 +630,7 @@ int *stats; fputs(memory_buffer, stdout); } +void u_memory(stats) int *stats; @@ -639,13 +651,14 @@ int *stats; */ char arc_buffer[MAX_COLS]; +void i_arc(stats) int *stats; { if (arc_names == NULL) - return (0); + return; fputs("\nARC: ", stdout); lastline++; @@ -655,6 +668,7 @@ int *stats; fputs(arc_buffer, stdout); } +void u_arc(stats) int *stats; @@ -663,7 +677,7 @@ int *stats; static char new[MAX_COLS]; if (arc_names == NULL) - return (0); + return; /* format the new line */ summary_format(new, stats, arc_names); @@ -680,6 +694,7 @@ int *stats; char swap_buffer[MAX_COLS]; +void i_swap(stats) int *stats; @@ -693,6 +708,7 @@ int *stats; fputs(swap_buffer, stdout); } +void u_swap(stats) int *stats; @@ -724,6 +740,7 @@ static int msglen = 0; /* Invariant: msglen is always the length of the message currently displayed on the screen (even when next_msg doesn't contain that message). */ +void i_message() { @@ -745,6 +762,7 @@ i_message() } } +void u_message() { @@ -786,6 +804,7 @@ char *text; * Assumptions: cursor is on the previous line and lastline is consistent */ +void i_header(text) char *text; @@ -811,9 +830,10 @@ char *text; } /*ARGSUSED*/ +void u_header(text) -char *text; /* ignored */ +char *text __unused; /* ignored */ { @@ -832,6 +852,7 @@ char *text; /* ignored */ * Assumptions: lastline is consistent */ +void i_process(line, thisline) int line; @@ -862,6 +883,7 @@ char *thisline; memzero(p, display_width - (p - base)); } +void u_process(line, newline) int line; @@ -909,9 +931,10 @@ char *newline; } } +void u_endscreen(hi) -register int hi; +int hi; { register int screen_line = hi + Header_lines; @@ -969,6 +992,7 @@ register int hi; } } +void display_header(t) int t; @@ -985,6 +1009,7 @@ int t; } /*VARARGS2*/ +void new_message(type, msgfmt, a1, a2, a3) int type; @@ -1025,6 +1050,7 @@ caddr_t a1, a2, a3; } } +void clear_message() { @@ -1034,6 +1060,7 @@ clear_message() } } +int readline(buffer, size, numeric) char *buffer; @@ -1336,6 +1363,7 @@ char *str; return(str); } +void i_uptime(bt, tod) struct timeval* bt; Modified: stable/10/contrib/top/display.h ============================================================================== --- stable/10/contrib/top/display.h Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/display.h Sun Jun 12 05:57:42 2016 (r301836) @@ -5,3 +5,37 @@ #define MT_standout 1 #define MT_delayed 2 +#include "machine.h" + +int display_updatecpus(struct statics *statics); +void clear_message(void); +int display_resize(void); +void i_header(char *text); +char *printable(char *string); +char *cpustates_tag(void); +void display_header(int t); +int display_init(struct statics *statics); +void i_arc(int *stats); +void i_cpustates(int *states); +void i_loadave(int mpid, double *avenrun); +void i_memory(int *stats); +void i_message(void); +void i_process(int line, char *thisline); +void i_procstates(int total, int *brkdn); +void i_swap(int *stats); +void i_timeofday(time_t *tod); +void i_uptime(struct timeval *bt, time_t *tod); +void new_message(); +int readline(char *buffer, int size, int numeric); +char *trim_header(char *text); +void u_arc(int *stats); +void u_cpustates(int *states); +void u_endscreen(int hi); +void u_header(char *text); +void u_loadave(int mpid, double *avenrun); +void u_memory(int *stats); +void u_message(void); +void u_process(int line, char *newline); +void u_procstates(int total, int *brkdn); +void u_swap(int *stats); +void z_cpustates(void); Modified: stable/10/contrib/top/machine.h ============================================================================== --- stable/10/contrib/top/machine.h Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/machine.h Sun Jun 12 05:57:42 2016 (r301836) @@ -7,6 +7,10 @@ * module. It is NOT machine dependent and should not need to be changed * for any specific machine. */ +#ifndef MACHINE_H +#define MACHINE_H + +#include "top.h" /* * the statics struct is filled in by machine_init @@ -74,8 +78,14 @@ struct process_select /* routines defined by the machine dependent module */ -char *format_header(); -char *format_next_process(); +char *format_header(); +char *format_next_process(); +void toggle_pcpustats(void); +void get_system_info(struct system_info *si); +int machine_init(struct statics *statics, char do_unames); +int proc_owner(int pid); /* non-int routines typically used by the machine dependent module */ -char *printable(); +char *printable(); + +#endif /* MACHINE_H */ Modified: stable/10/contrib/top/screen.c ============================================================================== --- stable/10/contrib/top/screen.c Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/screen.c Sun Jun 12 05:57:42 2016 (r301836) @@ -50,7 +50,6 @@ extern char *myname; -int putstdout(); int overstrike; int screen_length; @@ -236,6 +235,7 @@ int interactive; #endif } +void init_screen() { @@ -326,6 +326,7 @@ init_screen() } } +void end_screen() { @@ -356,6 +357,7 @@ end_screen() } } +void reinit_screen() { @@ -383,6 +385,7 @@ reinit_screen() } } +void get_screensize() { @@ -428,6 +431,7 @@ get_screensize() lower_left[sizeof(lower_left) - 1] = '\0'; } +void standout(msg) char *msg; @@ -445,6 +449,7 @@ char *msg; } } +void clear() { @@ -454,6 +459,7 @@ clear() } } +int clear_eol(len) int len; @@ -478,6 +484,7 @@ int len; return(-1); } +void go_home() { @@ -489,6 +496,7 @@ go_home() /* This has to be defined as a subroutine for tputs (instead of a macro) */ +void putstdout(ch) char ch; Modified: stable/10/contrib/top/screen.h ============================================================================== --- stable/10/contrib/top/screen.h Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/screen.h Sun Jun 12 05:57:42 2016 (r301836) @@ -28,4 +28,14 @@ extern int screen_length; extern int screen_width; /* a function that puts a single character on stdout */ -int putstdout(); +void putstdout(char ch); +int clear_eol(int len); +void standout(char *msg); +void clear(void); +void go_home(void); +void reinit_screen(void); +void get_screensize(void); +void init_termcap(int interactive); +void end_screen(void); +void init_screen(void); + Modified: stable/10/contrib/top/top.c ============================================================================== --- stable/10/contrib/top/top.c Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/top.c Sun Jun 12 05:57:42 2016 (r301836) @@ -34,15 +34,19 @@ char *copyright = */ #include "os.h" -#include -#include -#include -#include + #include #include + +#include +#include #include +#include +#include +#include /* includes specific to top */ +#include "commands.h" #include "display.h" /* interface to display package */ #include "screen.h" /* interface to screen package */ #include "top.h" @@ -50,6 +54,7 @@ char *copyright = #include "boolean.h" #include "machine.h" #include "utils.h" +#include "username.h" /* Size of the stdio buffer given to stdout */ #define Buffersize 2048 @@ -114,38 +119,21 @@ caddr_t get_process_info(); char *username(); char *itoa7(); -/* display routines that need to be predeclared */ -int i_loadave(); -int u_loadave(); -int i_procstates(); -int u_procstates(); -int i_cpustates(); -int u_cpustates(); -int i_memory(); -int u_memory(); -int i_arc(); -int u_arc(); -int i_swap(); -int u_swap(); -int i_message(); -int u_message(); -int i_header(); -int u_header(); -int i_process(); -int u_process(); - /* pointers to display routines */ -int (*d_loadave)() = i_loadave; -int (*d_procstates)() = i_procstates; -int (*d_cpustates)() = i_cpustates; -int (*d_memory)() = i_memory; -int (*d_arc)() = i_arc; -int (*d_swap)() = i_swap; -int (*d_message)() = i_message; -int (*d_header)() = i_header; -int (*d_process)() = i_process; +void (*d_loadave)() = i_loadave; +void (*d_procstates)() = i_procstates; +void (*d_cpustates)() = i_cpustates; +void (*d_memory)() = i_memory; +void (*d_arc)() = i_arc; +void (*d_swap)() = i_swap; +void (*d_message)() = i_message; +void (*d_header)() = i_header; +void (*d_process)() = i_process; + +void reset_display(void); +int main(argc, argv) int argc; @@ -1178,6 +1166,7 @@ restart: * screen will get redrawn. */ +void reset_display() { Modified: stable/10/contrib/top/top.h ============================================================================== --- stable/10/contrib/top/top.h Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/top.h Sun Jun 12 05:57:42 2016 (r301836) @@ -7,6 +7,9 @@ * General (global) definitions */ +#ifndef TOP_H +#define TOP_H + /* Current major version number */ #define VERSION 3 @@ -47,3 +50,5 @@ enum displaymodes { DISP_CPU = 0, DISP_I extern enum displaymodes displaymode; extern int pcpu_stats; + +#endif /* TOP_H */ Modified: stable/10/contrib/top/username.c ============================================================================== --- stable/10/contrib/top/username.c Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/username.c Sun Jun 12 05:57:42 2016 (r301836) @@ -32,11 +32,15 @@ #include #include -#include + #include +#include +#include +#include #include "top.local.h" #include "utils.h" +#include "username.h" struct hash_el { int uid; @@ -55,6 +59,8 @@ struct hash_el { /* We depend on that for hash_table and YOUR compiler had BETTER do it! */ struct hash_el hash_table[Table_size]; + +void init_hash() { @@ -67,7 +73,7 @@ init_hash() char *username(uid) -register int uid; +int uid; { register int hashindex; @@ -106,8 +112,8 @@ char *username; int enter_user(uid, name, wecare) -register int uid; -register char *name; +int uid; +char *name; int wecare; /* 1 = enter it always, 0 = nice to have */ { @@ -142,7 +148,7 @@ int wecare; /* 1 = enter it always, 0 = int get_user(uid) -register int uid; +int uid; { struct passwd *pwd; Copied: stable/10/contrib/top/username.h (from r300395, head/contrib/top/username.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/top/username.h Sun Jun 12 05:57:42 2016 (r301836, copy of r300395, head/contrib/top/username.h) @@ -0,0 +1,23 @@ +/* + * Top users/processes display for Unix + * Version 3 + * + * This program may be freely redistributed, + * but this entire comment MUST remain intact. + * + * Copyright (c) 1984, 1989, William LeFebvre, Rice University + * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University + * Copyright (c) 2016, Randy Westlund + * + * $FreeBSD$ + */ +#ifndef USERNAME_H +#define USERNAME_H + +int enter_user(int uid, char *name, int wecare); +int get_user(int uid); +void init_hash(void); +char *username(int uid); +int userid(char *username); + +#endif /* USERNAME_H */ Modified: stable/10/contrib/top/utils.h ============================================================================== --- stable/10/contrib/top/utils.h Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/utils.h Sun Jun 12 05:57:42 2016 (r301836) @@ -22,3 +22,5 @@ char *errmsg(); char *format_time(); char *format_k(); char *format_k2(unsigned long long); +int string_index(char *string, char **array); + Modified: stable/10/contrib/top/version.c ============================================================================== --- stable/10/contrib/top/version.c Sun Jun 12 02:42:08 2016 (r301835) +++ stable/10/contrib/top/version.c Sun Jun 12 05:57:42 2016 (r301836) @@ -9,6 +9,9 @@ * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University */ +#include +#include + #include "top.h" #include "patchlevel.h" From owner-svn-src-stable-10@freebsd.org Sun Jun 12 11:45:46 2016 Return-Path: Delivered-To: svn-src-stable-10@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 B198EAF012C; Sun, 12 Jun 2016 11:45:46 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 82BCB2DD4; Sun, 12 Jun 2016 11:45:46 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5CBjjOi047480; Sun, 12 Jun 2016 11:45:45 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5CBjjfD047479; Sun, 12 Jun 2016 11:45:45 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201606121145.u5CBjjfD047479@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 12 Jun 2016 11:45:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301839 - stable/10/sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jun 2016 11:45:46 -0000 Author: dim Date: Sun Jun 12 11:45:45 2016 New Revision: 301839 URL: https://svnweb.freebsd.org/changeset/base/301839 Log: MFC r300967: Stop exposing the C11 _Atomic() macro in , when compiling for C++. It clashes with the one in libc++'s header. (Previously, the _Atomic() macro was defined in , which is only for use with C11, but for various reasons it was moved to its current location in r251804.) Discussed with: bdrewery, ed Modified: stable/10/sys/sys/cdefs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sys/cdefs.h ============================================================================== --- stable/10/sys/sys/cdefs.h Sun Jun 12 11:13:38 2016 (r301838) +++ stable/10/sys/sys/cdefs.h Sun Jun 12 11:45:45 2016 (r301839) @@ -273,7 +273,8 @@ #define _Alignof(x) __alignof(x) #endif -#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic) +#if !defined(__cplusplus) && !__has_extension(c_atomic) && \ + !__has_extension(cxx_atomic) /* * No native support for _Atomic(). Place object in structure to prevent * most forms of direct non-atomic access. From owner-svn-src-stable-10@freebsd.org Mon Jun 13 02:54:59 2016 Return-Path: Delivered-To: svn-src-stable-10@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 C5F74AF0557; Mon, 13 Jun 2016 02:54:59 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 88B0323F0; Mon, 13 Jun 2016 02:54:59 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D2swLk083760; Mon, 13 Jun 2016 02:54:58 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D2swKI083759; Mon, 13 Jun 2016 02:54:58 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130254.u5D2swKI083759@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 02:54:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301847 - stable/10/contrib/hyperv/tools X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 02:54:59 -0000 Author: sephe Date: Mon Jun 13 02:54:58 2016 New Revision: 301847 URL: https://svnweb.freebsd.org/changeset/base/301847 Log: MFC 293653 hyperv/kvp_daemon: Make poll(2) block indefinitely Submitted by: Jun Su Reviewed by: Dexuan Cui , me, adrain Approved by: adrian Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D4762 Modified: stable/10/contrib/hyperv/tools/hv_kvp_daemon.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/hyperv/tools/hv_kvp_daemon.c ============================================================================== --- stable/10/contrib/hyperv/tools/hv_kvp_daemon.c Mon Jun 13 01:33:02 2016 (r301846) +++ stable/10/contrib/hyperv/tools/hv_kvp_daemon.c Mon Jun 13 02:54:58 2016 (r301847) @@ -1437,7 +1437,7 @@ main(int argc, char *argv[]) for (;;) { - r = poll (hv_kvp_poll_fd, 1, 100); + r = poll (hv_kvp_poll_fd, 1, INFTIM); KVP_LOG(LOG_DEBUG, "poll returned r = %d, revent = 0x%x\n", r, hv_kvp_poll_fd[0].revents); From owner-svn-src-stable-10@freebsd.org Mon Jun 13 03:03:10 2016 Return-Path: Delivered-To: svn-src-stable-10@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 15E32AF0762; Mon, 13 Jun 2016 03:03:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B95A82BA4; Mon, 13 Jun 2016 03:03:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D338WY087980; Mon, 13 Jun 2016 03:03:08 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D338IN087978; Mon, 13 Jun 2016 03:03:08 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130303.u5D338IN087978@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 03:03:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301848 - stable/10/sys/dev/bge X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 03:03:10 -0000 Author: sephe Date: Mon Jun 13 03:03:08 2016 New Revision: 301848 URL: https://svnweb.freebsd.org/changeset/base/301848 Log: MFC 300985, 301103 r300985 bge: Support 5717 C0, which is almost same as 5720 A0 PR: 209758 Obtained from: DragonFlyBSD d79f5d8f5fe94cd6769207b2901422977d502bc0 MFC after: 1 week ============ r301103 bge: Force chipid to 5720 A0 for 5717 C0 in an early place Discussed with: yongari MFC after: 1 week Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/bge/if_bge.c stable/10/sys/dev/bge/if_bgereg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/bge/if_bge.c ============================================================================== --- stable/10/sys/dev/bge/if_bge.c Mon Jun 13 02:54:58 2016 (r301847) +++ stable/10/sys/dev/bge/if_bge.c Mon Jun 13 03:03:08 2016 (r301848) @@ -170,6 +170,7 @@ static const struct bge_type { { BCOM_VENDORID, BCOM_DEVICEID_BCM5715 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5715S }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5717 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5717C }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5718 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5719 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5720 }, @@ -310,6 +311,7 @@ static const struct bge_revision { { BGE_CHIPID_BCM5715_A3, "BCM5715 A3" }, { BGE_CHIPID_BCM5717_A0, "BCM5717 A0" }, { BGE_CHIPID_BCM5717_B0, "BCM5717 B0" }, + { BGE_CHIPID_BCM5717_C0, "BCM5717 C0" }, { BGE_CHIPID_BCM5719_A0, "BCM5719 A0" }, { BGE_CHIPID_BCM5720_A0, "BCM5720 A0" }, { BGE_CHIPID_BCM5755_A0, "BCM5755 A0" }, @@ -2689,6 +2691,10 @@ bge_chipid(device_t dev) * registers. */ switch (pci_get_device(dev)) { + case BCOM_DEVICEID_BCM5717C: + /* 5717 C0 seems to belong to 5720 line. */ + id = BGE_CHIPID_BCM5720_A0; + break; case BCOM_DEVICEID_BCM5717: case BCOM_DEVICEID_BCM5718: case BCOM_DEVICEID_BCM5719: Modified: stable/10/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/10/sys/dev/bge/if_bgereg.h Mon Jun 13 02:54:58 2016 (r301847) +++ stable/10/sys/dev/bge/if_bgereg.h Mon Jun 13 03:03:08 2016 (r301848) @@ -329,6 +329,7 @@ #define BGE_CHIPID_BCM57780_A1 0x57780001 #define BGE_CHIPID_BCM5717_A0 0x05717000 #define BGE_CHIPID_BCM5717_B0 0x05717100 +#define BGE_CHIPID_BCM5717_C0 0x05717200 #define BGE_CHIPID_BCM5719_A0 0x05719000 #define BGE_CHIPID_BCM5720_A0 0x05720000 #define BGE_CHIPID_BCM5762_A0 0x05762000 @@ -2452,6 +2453,7 @@ struct bge_status_block { #define BCOM_DEVICEID_BCM5715 0x1678 #define BCOM_DEVICEID_BCM5715S 0x1679 #define BCOM_DEVICEID_BCM5717 0x1655 +#define BCOM_DEVICEID_BCM5717C 0x1665 #define BCOM_DEVICEID_BCM5718 0x1656 #define BCOM_DEVICEID_BCM5719 0x1657 #define BCOM_DEVICEID_BCM5720_PP 0x1658 /* Not released to public. */ From owner-svn-src-stable-10@freebsd.org Mon Jun 13 03:28:38 2016 Return-Path: Delivered-To: svn-src-stable-10@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 9B4D1AF0D32; Mon, 13 Jun 2016 03:28:38 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 455412636; Mon, 13 Jun 2016 03:28:38 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D3SbLY095537; Mon, 13 Jun 2016 03:28:37 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D3Sbj1095534; Mon, 13 Jun 2016 03:28:37 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130328.u5D3Sbj1095534@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 03:28:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301850 - in stable/10/sys/dev/hyperv: netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 03:28:38 -0000 Author: sephe Date: Mon Jun 13 03:28:37 2016 New Revision: 301850 URL: https://svnweb.freebsd.org/changeset/base/301850 Log: MFC 294701,294702,294703,294705,294788 294701 hyperv/hn: Use m_copydata for chimney sending. While I'm here, move stack variables near their usage. Reviewed by: adrian, delphij, Jun Su Approved by: adrian (mentor) Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D4977 294702 hyperv/hn: Remove unnecessary zeroing out the netvsc_packet All used fields are setup one by one, so there is no need to zero out this large struct. While I'm here, move the stack variable near its usage. Reviewed by: adrian, delphij, Jun Su Approved by: adrian (mentor) Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D4978 294703 hyperv/hn: Trust host TCP segment checksum verification by default. According to all available information, VMSWITCH always does the TCP segment checksum verification before sending the segment to guest. Reviewed by: adrian, delphij, Hongjiang Zhang Approved by: adrian (mentor) Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D4991 294705 hyperv/vmbus: Avoid extra copy of page information. The page information array could contain up to 32 elements (i.e. 512B). And on network side w/ TSO, 11+ (176B+) elements, i.e. ~44K TSO packet, in the page information array is quite common. This saves us some cpu cycles. Reviewed by: adrian, delphij Approved by: adrian (mentor) Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D4992 294788 hyperv/hn: Improve sending performance - Avoid main lock contention by trylock for if_start, if that fails, schedule TX taskqueue for if_start - Don't do direct sending if the packet to be sent is large, e.g. TSO packet. This change gives me stable 9.1Gbps TCP sending performance w/ TSO over a 10Gbe directly connected network (the performance fluctuated between 4Gbps and 9Gbps before this commit). It also improves non- TSO TCP sending performance a lot. Reviewed by: adrian, royger Approved by: adrian (mentor) Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5074 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 03:17:00 2016 (r301849) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 03:28:37 2016 (r301850) @@ -39,9 +39,11 @@ #define __HV_NET_VSC_H__ #include +#include #include #include #include +#include #include #include @@ -1009,7 +1011,6 @@ typedef struct hn_softc { struct hv_device *hn_dev_obj; netvsc_dev *net_dev; - int hn_txdesc_cnt; struct hn_txdesc *hn_txdesc; bus_dma_tag_t hn_tx_data_dtag; bus_dma_tag_t hn_tx_rndis_dtag; @@ -1018,9 +1019,15 @@ typedef struct hn_softc { struct mtx hn_txlist_spin; struct hn_txdesc_list hn_txlist; + int hn_txdesc_cnt; int hn_txdesc_avail; int hn_txeof; + int hn_direct_tx_size; + struct taskqueue *hn_tx_taskq; + struct task hn_start_task; + struct task hn_txeof_task; + struct lro_ctrl hn_lro; int hn_lro_hiwat; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 03:17:00 2016 (r301849) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 03:28:37 2016 (r301850) @@ -146,6 +146,8 @@ __FBSDID("$FreeBSD$"); #define HN_TX_DATA_SEGCNT_MAX \ (NETVSC_PACKET_MAXPAGE - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) +#define HN_DIRECT_TX_SIZE_DEF 128 + struct hn_txdesc { SLIST_ENTRY(hn_txdesc) link; struct mbuf *m; @@ -194,6 +196,7 @@ struct hn_txdesc { #define NV_LOCK_INIT(_sc, _name) \ mtx_init(&(_sc)->hn_lock, _name, MTX_NETWORK_LOCK, MTX_DEF) #define NV_LOCK(_sc) mtx_lock(&(_sc)->hn_lock) +#define NV_TRYLOCK(_sc) mtx_trylock(&(_sc)->hn_lock) #define NV_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->hn_lock, MA_OWNED) #define NV_UNLOCK(_sc) mtx_unlock(&(_sc)->hn_lock) #define NV_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->hn_lock) @@ -206,7 +209,7 @@ struct hn_txdesc { int hv_promisc_mode = 0; /* normal mode by default */ /* Trust tcp segements verification on host side. */ -static int hn_trust_hosttcp = 0; +static int hn_trust_hosttcp = 1; TUNABLE_INT("dev.hn.trust_hosttcp", &hn_trust_hosttcp); #if __FreeBSD_version >= 1100045 @@ -219,6 +222,10 @@ TUNABLE_INT("dev.hn.tso_maxlen", &hn_tso static int hn_tx_chimney_size = 0; TUNABLE_INT("dev.hn.tx_chimney_size", &hn_tx_chimney_size); +/* Limit the size of packet for direct transmission */ +static int hn_direct_tx_size = HN_DIRECT_TX_SIZE_DEF; +TUNABLE_INT("dev.hn.direct_tx_size", &hn_direct_tx_size); + /* * Forward declarations */ @@ -226,8 +233,9 @@ static void hn_stop(hn_softc_t *sc); static void hn_ifinit_locked(hn_softc_t *sc); static void hn_ifinit(void *xsc); static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); -static void hn_start_locked(struct ifnet *ifp); +static int hn_start_locked(struct ifnet *ifp, int len); static void hn_start(struct ifnet *ifp); +static void hn_start_txeof(struct ifnet *ifp); static int hn_ifmedia_upd(struct ifnet *ifp); static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); #ifdef HN_LRO_HIWAT @@ -237,6 +245,8 @@ static int hn_tx_chimney_size_sysctl(SYS static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *sc); static void hn_destroy_tx_ring(struct hn_softc *sc); +static void hn_start_taskfunc(void *xsc, int pending); +static void hn_txeof_taskfunc(void *xsc, int pending); static __inline void hn_set_lro_hiwat(struct hn_softc *sc, int hiwat) @@ -384,6 +394,14 @@ netvsc_attach(device_t dev) sc->hn_dev = dev; sc->hn_lro_hiwat = HN_LRO_HIWAT_DEF; sc->hn_trust_hosttcp = hn_trust_hosttcp; + sc->hn_direct_tx_size = hn_direct_tx_size; + + sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_tx_taskq); + taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx", + device_get_nameunit(dev)); + TASK_INIT(&sc->hn_start_task, 0, hn_start_taskfunc, sc); + TASK_INIT(&sc->hn_txeof_task, 0, hn_txeof_taskfunc, sc); error = hn_create_tx_ring(sc); if (error) @@ -524,6 +542,9 @@ netvsc_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "tx_chimney_size", CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_tx_chimney_size_sysctl, "I", "Chimney send packet size limit"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "direct_tx_size", + CTLFLAG_RW, &sc->hn_direct_tx_size, 0, + "Size of the packet for direct transmission"); if (unit == 0) { struct sysctl_ctx_list *dc_ctx; @@ -548,6 +569,9 @@ netvsc_attach(device_t dev) SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "tso_maxlen", CTLFLAG_RD, &hn_tso_maxlen, 0, "TSO burst limit"); #endif + SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "direct_tx_size", + CTLFLAG_RD, &hn_direct_tx_size, 0, + "Size of the packet for direct transmission"); } return (0); @@ -583,6 +607,10 @@ netvsc_detach(device_t dev) hv_rf_on_device_remove(hv_device, HV_RF_NV_DESTROY_CHANNEL); + taskqueue_drain(sc->hn_tx_taskq, &sc->hn_start_task); + taskqueue_drain(sc->hn_tx_taskq, &sc->hn_txeof_task); + taskqueue_free(sc->hn_tx_taskq); + ifmedia_removeall(&sc->hn_media); #if defined(INET) || defined(INET6) tcp_lro_free(&sc->hn_lro); @@ -733,30 +761,23 @@ void netvsc_channel_rollup(struct hv_device *device_ctx) { struct hn_softc *sc = device_get_softc(device_ctx->device); - struct ifnet *ifp; if (!sc->hn_txeof) return; sc->hn_txeof = 0; - ifp = sc->hn_ifp; - NV_LOCK(sc); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - hn_start_locked(ifp); - NV_UNLOCK(sc); + hn_start_txeof(sc->hn_ifp); } /* * Start a transmit of one or more packets */ -static void -hn_start_locked(struct ifnet *ifp) +static int +hn_start_locked(struct ifnet *ifp, int len) { hn_softc_t *sc = ifp->if_softc; struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); netvsc_dev *net_dev = sc->net_dev; - netvsc_packet *packet; - struct mbuf *m_head, *m; struct ether_vlan_header *eh; rndis_msg *rndis_mesg; rndis_packet *rndis_pkt; @@ -767,36 +788,42 @@ hn_start_locked(struct ifnet *ifp) int ether_len; uint32_t rndis_msg_size = 0; uint32_t trans_proto_type; - uint32_t send_buf_section_idx = - NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) - return; + return 0; while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; int error, nsegs, i, send_failed = 0; struct hn_txdesc *txd; + netvsc_packet *packet; + struct mbuf *m_head; IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; + if (len > 0 && m_head->m_pkthdr.len > len) { + /* + * This sending could be time consuming; let callers + * dispatch this packet sending (and sending of any + * following up packets) to tx taskqueue. + */ + IF_PREPEND(&ifp->if_snd, m_head); + return 1; + } + txd = hn_txdesc_get(sc); if (txd == NULL) { sc->hn_no_txdescs++; IF_PREPEND(&ifp->if_snd, m_head); - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); break; } packet = &txd->netvsc_pkt; - /* XXX not necessary */ - memset(packet, 0, sizeof(*packet)); - packet->is_data_pkt = TRUE; - /* Initialize it from the mbuf */ packet->tot_data_buf_len = m_head->m_pkthdr.len; @@ -940,24 +967,21 @@ pre_send: /* send packet with send buffer */ if (packet->tot_data_buf_len < sc->hn_tx_chimney_size) { + uint32_t send_buf_section_idx; + send_buf_section_idx = hv_nv_get_next_send_section(net_dev); if (send_buf_section_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { - char *dest = ((char *)net_dev->send_buf + - send_buf_section_idx * - net_dev->send_section_size); + uint8_t *dest = ((uint8_t *)net_dev->send_buf + + (send_buf_section_idx * + net_dev->send_section_size)); memcpy(dest, rndis_mesg, rndis_msg_size); dest += rndis_msg_size; - for (m = m_head; m != NULL; m = m->m_next) { - if (m->m_len) { - memcpy(dest, - (void *)mtod(m, vm_offset_t), - m->m_len); - dest += m->m_len; - } - } + + m_copydata(m_head, 0, m_head->m_pkthdr.len, + dest); packet->send_buf_section_idx = send_buf_section_idx; @@ -1069,10 +1093,11 @@ again: sc->hn_send_failed++; IF_PREPEND(&ifp->if_snd, m_head); - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); break; } } + return 0; } /* @@ -1566,7 +1591,8 @@ hn_stop(hn_softc_t *sc) if (bootverbose) printf(" Closing Device ...\n"); - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + atomic_clear_int(&ifp->if_drv_flags, + (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); if_link_state_change(ifp, LINK_STATE_DOWN); sc->hn_initdone = 0; @@ -1582,13 +1608,43 @@ hn_start(struct ifnet *ifp) hn_softc_t *sc; sc = ifp->if_softc; - NV_LOCK(sc); - if (sc->temp_unusable) { + if (NV_TRYLOCK(sc)) { + int sched; + + sched = hn_start_locked(ifp, sc->hn_direct_tx_size); NV_UNLOCK(sc); - return; + if (!sched) + return; + } + taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_start_task); +} + +static void +hn_start_txeof(struct ifnet *ifp) +{ + hn_softc_t *sc; + + sc = ifp->if_softc; + if (NV_TRYLOCK(sc)) { + int sched; + + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + sched = hn_start_locked(ifp, sc->hn_direct_tx_size); + NV_UNLOCK(sc); + if (sched) { + taskqueue_enqueue_fast(sc->hn_tx_taskq, + &sc->hn_start_task); + } + } else { + /* + * Release the OACTIVE earlier, with the hope, that + * others could catch up. The task will clear the + * flag again with the NV_LOCK to avoid possible + * races. + */ + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_txeof_task); } - hn_start_locked(ifp); - NV_UNLOCK(sc); } /* @@ -1615,8 +1671,8 @@ hn_ifinit_locked(hn_softc_t *sc) } else { sc->hn_initdone = 1; } - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); if_link_state_change(ifp, LINK_STATE_UP); } @@ -1918,6 +1974,28 @@ hn_destroy_tx_ring(struct hn_softc *sc) mtx_destroy(&sc->hn_txlist_spin); } +static void +hn_start_taskfunc(void *xsc, int pending __unused) +{ + struct hn_softc *sc = xsc; + + NV_LOCK(sc); + hn_start_locked(sc->hn_ifp, 0); + NV_UNLOCK(sc); +} + +static void +hn_txeof_taskfunc(void *xsc, int pending __unused) +{ + struct hn_softc *sc = xsc; + struct ifnet *ifp = sc->hn_ifp; + + NV_LOCK(sc); + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + hn_start_locked(ifp, 0); + NV_UNLOCK(sc); +} + static device_method_t netvsc_methods[] = { /* Device interface */ DEVMETHOD(device_probe, netvsc_probe), Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Mon Jun 13 03:17:00 2016 (r301849) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Mon Jun 13 03:28:37 2016 (r301850) @@ -666,11 +666,11 @@ hv_vmbus_channel_send_packet_pagebuffer( { int ret = 0; - int i = 0; boolean_t need_sig; uint32_t packet_len; + uint32_t page_buflen; uint32_t packetLen_aligned; - hv_vmbus_sg_buffer_list buffer_list[3]; + hv_vmbus_sg_buffer_list buffer_list[4]; hv_vmbus_channel_packet_page_buffer desc; uint32_t descSize; uint64_t alignedData = 0; @@ -682,36 +682,33 @@ hv_vmbus_channel_send_packet_pagebuffer( * Adjust the size down since hv_vmbus_channel_packet_page_buffer * is the largest size we support */ - descSize = sizeof(hv_vmbus_channel_packet_page_buffer) - - ((HV_MAX_PAGE_BUFFER_COUNT - page_count) * - sizeof(hv_vmbus_page_buffer)); - packet_len = descSize + buffer_len; + descSize = __offsetof(hv_vmbus_channel_packet_page_buffer, range); + page_buflen = sizeof(hv_vmbus_page_buffer) * page_count; + packet_len = descSize + page_buflen + buffer_len; packetLen_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t)); /* Setup the descriptor */ desc.type = HV_VMBUS_PACKET_TYPE_DATA_USING_GPA_DIRECT; desc.flags = HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; - desc.data_offset8 = descSize >> 3; /* in 8-bytes granularity */ + /* in 8-bytes granularity */ + desc.data_offset8 = (descSize + page_buflen) >> 3; desc.length8 = (uint16_t) (packetLen_aligned >> 3); desc.transaction_id = request_id; desc.range_count = page_count; - for (i = 0; i < page_count; i++) { - desc.range[i].length = page_buffers[i].length; - desc.range[i].offset = page_buffers[i].offset; - desc.range[i].pfn = page_buffers[i].pfn; - } - buffer_list[0].data = &desc; buffer_list[0].length = descSize; - buffer_list[1].data = buffer; - buffer_list[1].length = buffer_len; + buffer_list[1].data = page_buffers; + buffer_list[1].length = page_buflen; - buffer_list[2].data = &alignedData; - buffer_list[2].length = packetLen_aligned - packet_len; + buffer_list[2].data = buffer; + buffer_list[2].length = buffer_len; - ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3, + buffer_list[3].data = &alignedData; + buffer_list[3].length = packetLen_aligned - packet_len; + + ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 4, &need_sig); /* TODO: We should determine if this is optional */ From owner-svn-src-stable-10@freebsd.org Mon Jun 13 05:06:09 2016 Return-Path: Delivered-To: svn-src-stable-10@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 68154AF1C84; Mon, 13 Jun 2016 05:06:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 387672981; Mon, 13 Jun 2016 05:06:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D5686B032613; Mon, 13 Jun 2016 05:06:08 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D567nv032607; Mon, 13 Jun 2016 05:06:07 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130506.u5D567nv032607@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 05:06:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301854 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 05:06:09 -0000 Author: sephe Date: Mon Jun 13 05:06:07 2016 New Revision: 301854 URL: https://svnweb.freebsd.org/changeset/base/301854 Log: MFC 294886 hyperv/vmbus: Event handling code refactor. - Use taskqueue instead of swi for event handling. - Scan the interrupt flags in filter - Disable ringbuffer interrupt mask in filter to ensure no unnecessary interrupts. Submitted by: Jun Su Reviewed by: adrian, sephe, Dexuan Approved by: adrian (mentor) MFC after: 2 weeks Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D4920 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_connection.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Mon Jun 13 03:45:08 2016 (r301853) +++ stable/10/sys/dev/hyperv/include/hyperv.h Mon Jun 13 05:06:07 2016 (r301854) @@ -755,6 +755,8 @@ typedef struct hv_vmbus_channel { struct mtx inbound_lock; + struct taskqueue * rxq; + struct task channel_task; hv_vmbus_pfn_channel_callback on_channel_callback; void* channel_callback_context; Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Mon Jun 13 03:45:08 2016 (r301853) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Mon Jun 13 05:06:07 2016 (r301854) @@ -52,6 +52,7 @@ static int vmbus_channel_create_gpadl_h uint32_t* message_count); static void vmbus_channel_set_event(hv_vmbus_channel* channel); +static void VmbusProcessChannelEvent(void* channel, int pending); /** * @brief Trigger an event notification on the specified channel @@ -115,6 +116,9 @@ hv_vmbus_channel_open( new_channel->on_channel_callback = pfn_on_channel_callback; new_channel->channel_callback_context = context; + new_channel->rxq = hv_vmbus_g_context.hv_event_queue[new_channel->target_cpu]; + TASK_INIT(&new_channel->channel_task, 0, VmbusProcessChannelEvent, new_channel); + /* Allocate the ring buffer */ out = contigmalloc((send_ring_buffer_size + recv_ring_buffer_size), M_DEVBUF, M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); @@ -518,6 +522,7 @@ static void hv_vmbus_channel_close_internal(hv_vmbus_channel *channel) { int ret = 0; + struct taskqueue *rxq = channel->rxq; hv_vmbus_channel_close_channel* msg; hv_vmbus_channel_msg_info* info; @@ -525,6 +530,11 @@ hv_vmbus_channel_close_internal(hv_vmbus channel->sc_creation_callback = NULL; /* + * set rxq to NULL to avoid more requests be scheduled + */ + channel->rxq = NULL; + taskqueue_drain(rxq, &channel->channel_task); + /* * Grab the lock to prevent race condition when a packet received * and unloading driver is in the process. */ @@ -877,3 +887,67 @@ hv_vmbus_channel_recv_packet_raw( return (0); } + + +/** + * Process a channel event notification + */ +static void +VmbusProcessChannelEvent(void* context, int pending) +{ + void* arg; + uint32_t bytes_to_read; + hv_vmbus_channel* channel = (hv_vmbus_channel*)context; + boolean_t is_batched_reading; + + /** + * Find the channel based on this relid and invokes + * the channel callback to process the event + */ + + if (channel == NULL) { + return; + } + /** + * To deal with the race condition where we might + * receive a packet while the relevant driver is + * being unloaded, dispatch the callback while + * holding the channel lock. The unloading driver + * will acquire the same channel lock to set the + * callback to NULL. This closes the window. + */ + + /* + * Disable the lock due to newly added WITNESS check in r277723. + * Will seek other way to avoid race condition. + * -- whu + */ + // mtx_lock(&channel->inbound_lock); + if (channel->on_channel_callback != NULL) { + arg = channel->channel_callback_context; + is_batched_reading = channel->batched_reading; + /* + * Optimize host to guest signaling by ensuring: + * 1. While reading the channel, we disable interrupts from + * host. + * 2. Ensure that we process all posted messages from the host + * before returning from this callback. + * 3. Once we return, enable signaling from the host. Once this + * state is set we check to see if additional packets are + * available to read. In this case we repeat the process. + */ + do { + if (is_batched_reading) + hv_ring_buffer_read_begin(&channel->inbound); + + channel->on_channel_callback(arg); + + if (is_batched_reading) + bytes_to_read = + hv_ring_buffer_read_end(&channel->inbound); + else + bytes_to_read = 0; + } while (is_batched_reading && (bytes_to_read != 0)); + } + // mtx_unlock(&channel->inbound_lock); +} Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_connection.c Mon Jun 13 03:45:08 2016 (r301853) +++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c Mon Jun 13 05:06:07 2016 (r301854) @@ -339,78 +339,12 @@ hv_vmbus_disconnect(void) { } /** - * Process a channel event notification - */ -static void -VmbusProcessChannelEvent(uint32_t relid) -{ - void* arg; - uint32_t bytes_to_read; - hv_vmbus_channel* channel; - boolean_t is_batched_reading; - - /** - * Find the channel based on this relid and invokes - * the channel callback to process the event - */ - - channel = hv_vmbus_g_connection.channels[relid]; - - if (channel == NULL) { - return; - } - /** - * To deal with the race condition where we might - * receive a packet while the relevant driver is - * being unloaded, dispatch the callback while - * holding the channel lock. The unloading driver - * will acquire the same channel lock to set the - * callback to NULL. This closes the window. - */ - - /* - * Disable the lock due to newly added WITNESS check in r277723. - * Will seek other way to avoid race condition. - * -- whu - */ - // mtx_lock(&channel->inbound_lock); - if (channel->on_channel_callback != NULL) { - arg = channel->channel_callback_context; - is_batched_reading = channel->batched_reading; - /* - * Optimize host to guest signaling by ensuring: - * 1. While reading the channel, we disable interrupts from - * host. - * 2. Ensure that we process all posted messages from the host - * before returning from this callback. - * 3. Once we return, enable signaling from the host. Once this - * state is set we check to see if additional packets are - * available to read. In this case we repeat the process. - */ - do { - if (is_batched_reading) - hv_ring_buffer_read_begin(&channel->inbound); - - channel->on_channel_callback(arg); - - if (is_batched_reading) - bytes_to_read = - hv_ring_buffer_read_end(&channel->inbound); - else - bytes_to_read = 0; - } while (is_batched_reading && (bytes_to_read != 0)); - } - // mtx_unlock(&channel->inbound_lock); -} - -/** * Handler for events */ void -hv_vmbus_on_events(void *arg) +hv_vmbus_on_events(int cpu) { int bit; - int cpu; int dword; void *page_addr; uint32_t* recv_interrupt_page = NULL; @@ -419,7 +353,6 @@ hv_vmbus_on_events(void *arg) hv_vmbus_synic_event_flags *event; /* int maxdword = PAGE_SIZE >> 3; */ - cpu = (int)(long)arg; KASSERT(cpu <= mp_maxid, ("VMBUS: hv_vmbus_on_events: " "cpu out of range!")); @@ -461,8 +394,14 @@ hv_vmbus_on_events(void *arg) */ continue; } else { - VmbusProcessChannelEvent(rel_id); - + hv_vmbus_channel * channel = hv_vmbus_g_connection.channels[rel_id]; + /* if channel is closed or closing */ + if (channel == NULL || channel->rxq == NULL) + continue; + + if (channel->batched_reading) + hv_ring_buffer_read_begin(&channel->inbound); + taskqueue_enqueue_fast(channel->rxq, &channel->channel_task); } } } Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Mon Jun 13 03:45:08 2016 (r301853) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Mon Jun 13 05:06:07 2016 (r301854) @@ -177,7 +177,7 @@ hv_vmbus_isr(struct trapframe *frame) (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7)) { /* Since we are a child, we only need to check bit 0 */ if (synch_test_and_clear_bit(0, &event->flags32[0])) { - swi_sched(hv_vmbus_g_context.event_swintr[cpu], 0); + hv_vmbus_on_events(cpu); } } else { /* @@ -187,7 +187,7 @@ hv_vmbus_isr(struct trapframe *frame) * Directly schedule the event software interrupt on * current cpu. */ - swi_sched(hv_vmbus_g_context.event_swintr[cpu], 0); + hv_vmbus_on_events(cpu); } /* Check if there are actual msgs to be process */ @@ -225,7 +225,6 @@ hv_vmbus_isr(struct trapframe *frame) return (FILTER_HANDLED); } -uint32_t hv_vmbus_swintr_event_cpu[MAXCPU]; u_long *hv_vmbus_intr_cpu[MAXCPU]; void @@ -455,6 +454,19 @@ vmbus_vector_free(int vector) #endif /* HYPERV */ +static void +vmbus_cpuset_setthread_task(void *xmask, int pending __unused) +{ + cpuset_t *mask = xmask; + int error; + + error = cpuset_setthread(curthread->td_tid, mask); + if (error) { + panic("curthread=%ju: can't pin; error=%d", + (uintmax_t)curthread->td_tid, error); + } +} + /** * @brief Main vmbus driver initialization routine. * @@ -472,6 +484,7 @@ vmbus_bus_init(void) { int i, j, n, ret; char buf[MAXCOMLEN + 1]; + cpuset_t cpu_mask; if (vmbus_inited) return (0); @@ -508,10 +521,7 @@ vmbus_bus_init(void) setup_args.vector = hv_vmbus_g_context.hv_cb_vector; CPU_FOREACH(j) { - hv_vmbus_swintr_event_cpu[j] = 0; - hv_vmbus_g_context.hv_event_intr_event[j] = NULL; hv_vmbus_g_context.hv_msg_intr_event[j] = NULL; - hv_vmbus_g_context.event_swintr[j] = NULL; hv_vmbus_g_context.msg_swintr[j] = NULL; snprintf(buf, sizeof(buf), "cpu%d:hyperv", j); @@ -525,6 +535,26 @@ vmbus_bus_init(void) * Per cpu setup. */ CPU_FOREACH(j) { + struct task cpuset_task; + + /* + * Setup taskqueue to handle events + */ + hv_vmbus_g_context.hv_event_queue[j] = taskqueue_create_fast("hyperv event", M_WAITOK, + taskqueue_thread_enqueue, &hv_vmbus_g_context.hv_event_queue[j]); + if (hv_vmbus_g_context.hv_event_queue[j] == NULL) { + if (bootverbose) + printf("VMBUS: failed to setup taskqueue\n"); + goto cleanup1; + } + taskqueue_start_threads(&hv_vmbus_g_context.hv_event_queue[j], 1, PI_NET, + "hvevent%d", j); + + CPU_SETOF(j, &cpu_mask); + TASK_INIT(&cpuset_task, 0, vmbus_cpuset_setthread_task, &cpu_mask); + taskqueue_enqueue(hv_vmbus_g_context.hv_event_queue[j], &cpuset_task); + taskqueue_drain(hv_vmbus_g_context.hv_event_queue[j], &cpuset_task); + /* * Setup software interrupt thread and handler for msg handling. */ @@ -543,7 +573,7 @@ vmbus_bus_init(void) */ ret = intr_event_bind(hv_vmbus_g_context.hv_msg_intr_event[j], j); - if (ret) { + if (ret) { if(bootverbose) printf("VMBUS: failed to bind msg swi thread " "to cpu %d\n", j); @@ -551,20 +581,6 @@ vmbus_bus_init(void) } /* - * Setup software interrupt thread and handler for - * event handling. - */ - ret = swi_add(&hv_vmbus_g_context.hv_event_intr_event[j], - "hv_event", hv_vmbus_on_events, (void *)(long)j, - SWI_CLOCK, 0, &hv_vmbus_g_context.event_swintr[j]); - if (ret) { - if(bootverbose) - printf("VMBUS: failed to setup event swi for " - "cpu %d\n", j); - goto cleanup1; - } - - /* * Prepare the per cpu msg and event pages to be called on each cpu. */ for(i = 0; i < 2; i++) { @@ -607,12 +623,11 @@ vmbus_bus_init(void) * remove swi and vmbus callback vector; */ CPU_FOREACH(j) { + if (hv_vmbus_g_context.hv_event_queue[j] != NULL) + taskqueue_free(hv_vmbus_g_context.hv_event_queue[j]); if (hv_vmbus_g_context.msg_swintr[j] != NULL) swi_remove(hv_vmbus_g_context.msg_swintr[j]); - if (hv_vmbus_g_context.event_swintr[j] != NULL) - swi_remove(hv_vmbus_g_context.event_swintr[j]); hv_vmbus_g_context.hv_msg_intr_event[j] = NULL; - hv_vmbus_g_context.hv_event_intr_event[j] = NULL; } vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector); @@ -677,12 +692,11 @@ vmbus_bus_exit(void) /* remove swi */ CPU_FOREACH(i) { + if (hv_vmbus_g_context.hv_event_queue[i] != NULL) + taskqueue_free(hv_vmbus_g_context.hv_event_queue[i]); if (hv_vmbus_g_context.msg_swintr[i] != NULL) swi_remove(hv_vmbus_g_context.msg_swintr[i]); - if (hv_vmbus_g_context.event_swintr[i] != NULL) - swi_remove(hv_vmbus_g_context.event_swintr[i]); hv_vmbus_g_context.hv_msg_intr_event[i] = NULL; - hv_vmbus_g_context.hv_event_intr_event[i] = NULL; } vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector); Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Jun 13 03:45:08 2016 (r301853) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Mon Jun 13 05:06:07 2016 (r301854) @@ -202,9 +202,8 @@ typedef struct { * Each cpu has its own software interrupt handler for channel * event and msg handling. */ - struct intr_event *hv_event_intr_event[MAXCPU]; + struct taskqueue *hv_event_queue[MAXCPU]; struct intr_event *hv_msg_intr_event[MAXCPU]; - void *event_swintr[MAXCPU]; void *msg_swintr[MAXCPU]; /* * Host use this vector to intrrupt guest for vmbus channel @@ -717,7 +716,7 @@ int hv_vmbus_connect(void); int hv_vmbus_disconnect(void); int hv_vmbus_post_message(void *buffer, size_t buf_size); int hv_vmbus_set_event(hv_vmbus_channel *channel); -void hv_vmbus_on_events(void *); +void hv_vmbus_on_events(int cpu); /** * Event Timer interfaces From owner-svn-src-stable-10@freebsd.org Mon Jun 13 05:13:53 2016 Return-Path: Delivered-To: svn-src-stable-10@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 72531AF1ECA; Mon, 13 Jun 2016 05:13:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 258232E90; Mon, 13 Jun 2016 05:13:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D5DqwR036116; Mon, 13 Jun 2016 05:13:52 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D5DqD0036115; Mon, 13 Jun 2016 05:13:52 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130513.u5D5DqD0036115@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 05:13:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301855 - stable/10/sys/dev/hyperv/storvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 05:13:53 -0000 Author: sephe Date: Mon Jun 13 05:13:52 2016 New Revision: 301855 URL: https://svnweb.freebsd.org/changeset/base/301855 Log: MFC 295295 hyperv/stor: Fix the NULL pointer dereference Reported by: Netapp Submitted by: Hongjiang Zhang Reviewed by: adrian, sephe, Dexuan Cui Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5097 Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Jun 13 05:06:07 2016 (r301854) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Jun 13 05:13:52 2016 (r301855) @@ -1561,13 +1561,12 @@ static void storvsc_destroy_bounce_buffer(struct sglist *sgl) { struct hv_sgl_node *sgl_node = NULL; - - sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.in_use_sgl_list); - LIST_REMOVE(sgl_node, link); - if (NULL == sgl_node) { + if (LIST_EMPTY(&g_hv_sgl_page_pool.in_use_sgl_list)) { printf("storvsc error: not enough in use sgl\n"); return; } + sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.in_use_sgl_list); + LIST_REMOVE(sgl_node, link); sgl_node->sgl_data = sgl; LIST_INSERT_HEAD(&g_hv_sgl_page_pool.free_sgl_list, sgl_node, link); } @@ -1593,12 +1592,12 @@ storvsc_create_bounce_buffer(uint16_t se struct hv_sgl_node *sgl_node = NULL; /* get struct sglist from free_sgl_list */ - sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); - LIST_REMOVE(sgl_node, link); - if (NULL == sgl_node) { + if (LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { printf("storvsc error: not enough free sgl\n"); return NULL; } + sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); + LIST_REMOVE(sgl_node, link); bounce_sgl = sgl_node->sgl_data; LIST_INSERT_HEAD(&g_hv_sgl_page_pool.in_use_sgl_list, sgl_node, link); From owner-svn-src-stable-10@freebsd.org Mon Jun 13 05:43:43 2016 Return-Path: Delivered-To: svn-src-stable-10@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 59CDFAF066C; Mon, 13 Jun 2016 05:43:43 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 1E2BB2B16; Mon, 13 Jun 2016 05:43:43 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D5hgY2046907; Mon, 13 Jun 2016 05:43:42 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D5hgak046905; Mon, 13 Jun 2016 05:43:42 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130543.u5D5hgak046905@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 05:43:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301856 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 05:43:43 -0000 Author: sephe Date: Mon Jun 13 05:43:42 2016 New Revision: 301856 URL: https://svnweb.freebsd.org/changeset/base/301856 Log: MFC 295296,295297,295298,295299,295300,295301 295296 hyperv/hn: Avoid duplicate csum features settings - Record csum features in softc, so we don't need to duplicate the logic from attach path to ioctl path. - Protect if_capenable and if_hwassist changes by main lock. - Prefer turn on/off bits in if_hwassist explicitly instead of using XOR. Reviewed by: adrian, Hongjiang Zhang Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5085 295297 hyperv/hn: Reorganize TX csum offloading - For non-TSO offloading, we don't need to access mbuf to know which csum offloading is requested, we can just use the CSUM_{IP,TCP,UDP} in the csum_flags. - For TSO offloading, we still can depend on CSUM_{TSO4,TSO6} in the csum_flags to tell whether the TSO packet is an IPv4 TSO packet or an IPv6 TSO packet. This streamlines csum offloading handling (remove the two goto) and allows us the nuke the unnecessary get_transport_proto_type(). Reviewed by: adrian, Hongjiang Zhang Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5098 295298 hyperv/hn: Enable IP header checksum offloading So that: - TCP/IP stack will not do unnecessary IP header checksum for TSO packets. - Reduce guest load for non-TSO IP packets. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5099 295299 hyperv/hn: Enable UDP RXCSUM Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5102 295300 hyperv/hn: Add sysctls to trust host side UDP and IP csum verification Reviewed by: adrian, Hongjiang Zhang Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5103 295301 hyperv/hn: Obey IFCAP_RXCSUM configure Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5104 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 05:13:52 2016 (r301855) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 05:43:42 2016 (r301856) @@ -1016,6 +1016,7 @@ typedef struct hn_softc { bus_dma_tag_t hn_tx_rndis_dtag; int hn_tx_chimney_size; int hn_tx_chimney_max; + uint64_t hn_csum_assist; struct mtx hn_txlist_spin; struct hn_txdesc_list hn_txlist; @@ -1031,11 +1032,12 @@ typedef struct hn_softc { struct lro_ctrl hn_lro; int hn_lro_hiwat; - /* Trust tcp segments verification on host side */ - int hn_trust_hosttcp; + /* Trust csum verification on host side */ + int hn_trust_hcsum; /* HN_TRUST_HCSUM_ */ u_long hn_csum_ip; u_long hn_csum_tcp; + u_long hn_csum_udp; u_long hn_csum_trusted; u_long hn_lro_tried; u_long hn_small_pkts; @@ -1046,6 +1048,9 @@ typedef struct hn_softc { u_long hn_tx_chimney; } hn_softc_t; +#define HN_TRUST_HCSUM_IP 0x0001 +#define HN_TRUST_HCSUM_TCP 0x0002 +#define HN_TRUST_HCSUM_UDP 0x0004 /* * Externs Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 05:13:52 2016 (r301855) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 05:43:42 2016 (r301856) @@ -167,14 +167,12 @@ struct hn_txdesc { #define HN_TXD_FLAG_DMAMAP 0x2 /* - * A unified flag for all outbound check sum flags is useful, - * and it helps avoiding unnecessary check sum calculation in - * network forwarding scenario. + * Only enable UDP checksum offloading when it is on 2012R2 or + * later. UDP checksum offloading doesn't work on earlier + * Windows releases. */ -#define HV_CSUM_FOR_OUTBOUND \ - (CSUM_IP|CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP|CSUM_IP_TSO| \ - CSUM_IP_ISCSI|CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP| \ - CSUM_IP6_TSO|CSUM_IP6_ISCSI) +#define HN_CSUM_ASSIST_WIN8 (CSUM_TCP) +#define HN_CSUM_ASSIST (CSUM_IP | CSUM_UDP | CSUM_TCP) /* XXX move to netinet/tcp_lro.h */ #define HN_LRO_HIWAT_MAX 65535 @@ -212,6 +210,14 @@ int hv_promisc_mode = 0; /* normal mo static int hn_trust_hosttcp = 1; TUNABLE_INT("dev.hn.trust_hosttcp", &hn_trust_hosttcp); +/* Trust udp datagrams verification on host side. */ +static int hn_trust_hostudp = 1; +TUNABLE_INT("dev.hn.trust_hostudp", &hn_trust_hostudp); + +/* Trust ip packets verification on host side. */ +static int hn_trust_hostip = 1; +TUNABLE_INT("dev.hn.trust_hostip", &hn_trust_hostip); + #if __FreeBSD_version >= 1100045 /* Limit TSO burst size */ static int hn_tso_maxlen = 0; @@ -241,6 +247,7 @@ static void hn_ifmedia_sts(struct ifnet #ifdef HN_LRO_HIWAT static int hn_lro_hiwat_sysctl(SYSCTL_HANDLER_ARGS); #endif +static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *sc); @@ -257,62 +264,6 @@ hn_set_lro_hiwat(struct hn_softc *sc, in #endif } -/* - * NetVsc get message transport protocol type - */ -static uint32_t get_transport_proto_type(struct mbuf *m_head) -{ - uint32_t ret_val = TRANSPORT_TYPE_NOT_IP; - uint16_t ether_type = 0; - int ether_len = 0; - struct ether_vlan_header *eh; -#ifdef INET - struct ip *iph; -#endif -#ifdef INET6 - struct ip6_hdr *ip6; -#endif - - eh = mtod(m_head, struct ether_vlan_header*); - if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) { - ether_len = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; - ether_type = eh->evl_proto; - } else { - ether_len = ETHER_HDR_LEN; - ether_type = eh->evl_encap_proto; - } - - switch (ntohs(ether_type)) { -#ifdef INET6 - case ETHERTYPE_IPV6: - ip6 = (struct ip6_hdr *)(m_head->m_data + ether_len); - - if (IPPROTO_TCP == ip6->ip6_nxt) { - ret_val = TRANSPORT_TYPE_IPV6_TCP; - } else if (IPPROTO_UDP == ip6->ip6_nxt) { - ret_val = TRANSPORT_TYPE_IPV6_UDP; - } - break; -#endif -#ifdef INET - case ETHERTYPE_IP: - iph = (struct ip *)(m_head->m_data + ether_len); - - if (IPPROTO_TCP == iph->ip_p) { - ret_val = TRANSPORT_TYPE_IPV4_TCP; - } else if (IPPROTO_UDP == iph->ip_p) { - ret_val = TRANSPORT_TYPE_IPV4_UDP; - } - break; -#endif - default: - ret_val = TRANSPORT_TYPE_NOT_IP; - break; - } - - return (ret_val); -} - static int hn_ifmedia_upd(struct ifnet *ifp __unused) { @@ -393,8 +344,13 @@ netvsc_attach(device_t dev) sc->hn_unit = unit; sc->hn_dev = dev; sc->hn_lro_hiwat = HN_LRO_HIWAT_DEF; - sc->hn_trust_hosttcp = hn_trust_hosttcp; sc->hn_direct_tx_size = hn_direct_tx_size; + if (hn_trust_hosttcp) + sc->hn_trust_hcsum |= HN_TRUST_HCSUM_TCP; + if (hn_trust_hostudp) + sc->hn_trust_hcsum |= HN_TRUST_HCSUM_UDP; + if (hn_trust_hostip) + sc->hn_trust_hcsum |= HN_TRUST_HCSUM_IP; sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK, taskqueue_thread_enqueue, &sc->hn_tx_taskq); @@ -444,15 +400,12 @@ netvsc_attach(device_t dev) ifp->if_capenable |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO; - /* - * Only enable UDP checksum offloading when it is on 2012R2 or - * later. UDP checksum offloading doesn't work on earlier - * Windows releases. - */ + if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1) - ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_TSO; + sc->hn_csum_assist = HN_CSUM_ASSIST; else - ifp->if_hwassist = CSUM_TCP | CSUM_TSO; + sc->hn_csum_assist = HN_CSUM_ASSIST_WIN8; + ifp->if_hwassist = sc->hn_csum_assist | CSUM_TSO; error = hv_rf_on_device_add(device_ctx, &device_info); if (error) @@ -509,17 +462,30 @@ netvsc_attach(device_t dev) CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_lro_hiwat_sysctl, "I", "LRO high watermark"); #endif - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "trust_hosttcp", - CTLFLAG_RW, &sc->hn_trust_hosttcp, 0, + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hosttcp", + CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_TCP, + hn_trust_hcsum_sysctl, "I", "Trust tcp segement verification on host side, " "when csum info is missing"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hostudp", + CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_UDP, + hn_trust_hcsum_sysctl, "I", + "Trust udp datagram verification on host side, " + "when csum info is missing"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hostip", + CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_IP, + hn_trust_hcsum_sysctl, "I", + "Trust ip packet verification on host side, " + "when csum info is missing"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_ip", CTLFLAG_RW, &sc->hn_csum_ip, "RXCSUM IP"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_tcp", CTLFLAG_RW, &sc->hn_csum_tcp, "RXCSUM TCP"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_udp", + CTLFLAG_RW, &sc->hn_csum_udp, "RXCSUM UDP"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_trusted", CTLFLAG_RW, &sc->hn_csum_trusted, - "# of TCP segements that we trust host's csum verification"); + "# of packets that we trust host's csum verification"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "small_pkts", CTLFLAG_RW, &sc->hn_small_pkts, "# of small packets received"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "no_txdescs", @@ -562,6 +528,14 @@ netvsc_attach(device_t dev) CTLFLAG_RD, &hn_trust_hosttcp, 0, "Trust tcp segement verification on host side, " "when csum info is missing (global setting)"); + SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hostudp", + CTLFLAG_RD, &hn_trust_hostudp, 0, + "Trust udp datagram verification on host side, " + "when csum info is missing (global setting)"); + SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hostip", + CTLFLAG_RD, &hn_trust_hostip, 0, + "Trust ip packet verification on host side, " + "when csum info is missing (global setting)"); SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "tx_chimney_size", CTLFLAG_RD, &hn_tx_chimney_size, 0, "Chimney send packet size limit"); @@ -778,16 +752,13 @@ hn_start_locked(struct ifnet *ifp, int l hn_softc_t *sc = ifp->if_softc; struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); netvsc_dev *net_dev = sc->net_dev; - struct ether_vlan_header *eh; rndis_msg *rndis_mesg; rndis_packet *rndis_pkt; rndis_per_packet_info *rppi; ndis_8021q_info *rppi_vlan_info; rndis_tcp_ip_csum_info *csum_info; rndis_tcp_tso_info *tso_info; - int ether_len; uint32_t rndis_msg_size = 0; - uint32_t trans_proto_type; if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) @@ -867,101 +838,81 @@ hn_start_locked(struct ifnet *ifp, int l m_head->m_pkthdr.ether_vtag & 0xfff; } - /* Only check the flags for outbound and ignore the ones for inbound */ - if (0 == (m_head->m_pkthdr.csum_flags & HV_CSUM_FOR_OUTBOUND)) { - goto pre_send; - } - - eh = mtod(m_head, struct ether_vlan_header*); - if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) { - ether_len = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; - } else { - ether_len = ETHER_HDR_LEN; - } - - trans_proto_type = get_transport_proto_type(m_head); - if (TRANSPORT_TYPE_NOT_IP == trans_proto_type) { - goto pre_send; - } - - /* - * TSO packet needless to setup the send side checksum - * offload. - */ if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { - goto do_tso; - } + struct ether_vlan_header *eh; + int ether_len; - /* setup checksum offload */ - rndis_msg_size += RNDIS_CSUM_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_CSUM_PPI_SIZE, - tcpip_chksum_info); - csum_info = (rndis_tcp_ip_csum_info *)((char*)rppi + - rppi->per_packet_info_offset); + eh = mtod(m_head, struct ether_vlan_header*); + if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) { + ether_len = ETHER_HDR_LEN + + ETHER_VLAN_ENCAP_LEN; + } else { + ether_len = ETHER_HDR_LEN; + } - if (trans_proto_type & (TYPE_IPV4 << 16)) { - csum_info->xmit.is_ipv4 = 1; - } else { - csum_info->xmit.is_ipv6 = 1; - } + rndis_msg_size += RNDIS_TSO_PPI_SIZE; + rppi = hv_set_rppi_data(rndis_mesg, RNDIS_TSO_PPI_SIZE, + tcp_large_send_info); - if (trans_proto_type & TYPE_TCP) { - csum_info->xmit.tcp_csum = 1; - csum_info->xmit.tcp_header_offset = 0; - } else if (trans_proto_type & TYPE_UDP) { - csum_info->xmit.udp_csum = 1; - } - - goto pre_send; + tso_info = (rndis_tcp_tso_info *)((char *)rppi + + rppi->per_packet_info_offset); + tso_info->lso_v2_xmit.type = + RNDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE; -do_tso: - /* setup TCP segmentation offload */ - rndis_msg_size += RNDIS_TSO_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_TSO_PPI_SIZE, - tcp_large_send_info); - - tso_info = (rndis_tcp_tso_info *)((char *)rppi + - rppi->per_packet_info_offset); - tso_info->lso_v2_xmit.type = - RNDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE; - #ifdef INET - if (trans_proto_type & (TYPE_IPV4 << 16)) { - struct ip *ip = - (struct ip *)(m_head->m_data + ether_len); - unsigned long iph_len = ip->ip_hl << 2; - struct tcphdr *th = - (struct tcphdr *)((caddr_t)ip + iph_len); - - tso_info->lso_v2_xmit.ip_version = - RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV4; - ip->ip_len = 0; - ip->ip_sum = 0; - - th->th_sum = in_pseudo(ip->ip_src.s_addr, - ip->ip_dst.s_addr, - htons(IPPROTO_TCP)); - } + if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { + struct ip *ip = + (struct ip *)(m_head->m_data + ether_len); + unsigned long iph_len = ip->ip_hl << 2; + struct tcphdr *th = + (struct tcphdr *)((caddr_t)ip + iph_len); + + tso_info->lso_v2_xmit.ip_version = + RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV4; + ip->ip_len = 0; + ip->ip_sum = 0; + + th->th_sum = in_pseudo(ip->ip_src.s_addr, + ip->ip_dst.s_addr, htons(IPPROTO_TCP)); + } #endif #if defined(INET6) && defined(INET) - else + else #endif #ifdef INET6 - { - struct ip6_hdr *ip6 = - (struct ip6_hdr *)(m_head->m_data + ether_len); - struct tcphdr *th = (struct tcphdr *)(ip6 + 1); - - tso_info->lso_v2_xmit.ip_version = - RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV6; - ip6->ip6_plen = 0; - th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); - } + { + struct ip6_hdr *ip6 = (struct ip6_hdr *) + (m_head->m_data + ether_len); + struct tcphdr *th = (struct tcphdr *)(ip6 + 1); + + tso_info->lso_v2_xmit.ip_version = + RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV6; + ip6->ip6_plen = 0; + th->th_sum = + in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); + } #endif - tso_info->lso_v2_xmit.tcp_header_offset = 0; - tso_info->lso_v2_xmit.mss = m_head->m_pkthdr.tso_segsz; + tso_info->lso_v2_xmit.tcp_header_offset = 0; + tso_info->lso_v2_xmit.mss = m_head->m_pkthdr.tso_segsz; + } else if (m_head->m_pkthdr.csum_flags & sc->hn_csum_assist) { + rndis_msg_size += RNDIS_CSUM_PPI_SIZE; + rppi = hv_set_rppi_data(rndis_mesg, RNDIS_CSUM_PPI_SIZE, + tcpip_chksum_info); + csum_info = (rndis_tcp_ip_csum_info *)((char*)rppi + + rppi->per_packet_info_offset); + + csum_info->xmit.is_ipv4 = 1; + if (m_head->m_pkthdr.csum_flags & CSUM_IP) + csum_info->xmit.ip_header_csum = 1; + + if (m_head->m_pkthdr.csum_flags & CSUM_TCP) { + csum_info->xmit.tcp_csum = 1; + csum_info->xmit.tcp_header_offset = 0; + } else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) { + csum_info->xmit.udp_csum = 1; + } + } -pre_send: rndis_mesg->msg_len = packet->tot_data_buf_len + rndis_msg_size; packet->tot_data_buf_len = rndis_mesg->msg_len; @@ -1191,7 +1142,7 @@ netvsc_recv(struct hv_device *device_ctx struct mbuf *m_new; struct ifnet *ifp; device_t dev = device_ctx->device; - int size, do_lro = 0; + int size, do_lro = 0, do_csum = 1; if (sc == NULL) { return (0); /* TODO: KYS how can this be! */ @@ -1241,21 +1192,28 @@ netvsc_recv(struct hv_device *device_ctx } m_new->m_pkthdr.rcvif = ifp; + if (__predict_false((ifp->if_capenable & IFCAP_RXCSUM) == 0)) + do_csum = 0; + /* receive side checksum offload */ - if (NULL != csum_info) { + if (csum_info != NULL) { /* IP csum offload */ - if (csum_info->receive.ip_csum_succeeded) { + if (csum_info->receive.ip_csum_succeeded && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); sc->hn_csum_ip++; } - /* TCP csum offload */ - if (csum_info->receive.tcp_csum_succeeded) { + /* TCP/UDP csum offload */ + if ((csum_info->receive.tcp_csum_succeeded || + csum_info->receive.udp_csum_succeeded) && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; - sc->hn_csum_tcp++; + if (csum_info->receive.tcp_csum_succeeded) + sc->hn_csum_tcp++; + else + sc->hn_csum_udp++; } if (csum_info->receive.ip_csum_succeeded && @@ -1286,7 +1244,8 @@ netvsc_recv(struct hv_device *device_ctx pr = hn_check_iplen(m_new, hoff); if (pr == IPPROTO_TCP) { - if (sc->hn_trust_hosttcp) { + if (do_csum && + (sc->hn_trust_hcsum & HN_TRUST_HCSUM_TCP)) { sc->hn_csum_trusted++; m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID | @@ -1295,6 +1254,20 @@ netvsc_recv(struct hv_device *device_ctx } /* Rely on SW csum verification though... */ do_lro = 1; + } else if (pr == IPPROTO_UDP) { + if (do_csum && + (sc->hn_trust_hcsum & HN_TRUST_HCSUM_UDP)) { + sc->hn_csum_trusted++; + m_new->m_pkthdr.csum_flags |= + (CSUM_IP_CHECKED | CSUM_IP_VALID | + CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + m_new->m_pkthdr.csum_data = 0xffff; + } + } else if (pr != IPPROTO_DONE && do_csum && + (sc->hn_trust_hcsum & HN_TRUST_HCSUM_IP)) { + sc->hn_csum_trusted++; + m_new->m_pkthdr.csum_flags |= + (CSUM_IP_CHECKED | CSUM_IP_VALID); } } } @@ -1508,47 +1481,40 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, error = 0; break; case SIOCSIFCAP: + NV_LOCK(sc); + mask = ifr->ifr_reqcap ^ ifp->if_capenable; if (mask & IFCAP_TXCSUM) { - if (IFCAP_TXCSUM & ifp->if_capenable) { - ifp->if_capenable &= ~IFCAP_TXCSUM; - ifp->if_hwassist &= ~(CSUM_TCP | CSUM_UDP); - } else { - ifp->if_capenable |= IFCAP_TXCSUM; - /* - * Only enable UDP checksum offloading on - * Windows Server 2012R2 or later releases. - */ - if (hv_vmbus_protocal_version >= - HV_VMBUS_VERSION_WIN8_1) { - ifp->if_hwassist |= - (CSUM_TCP | CSUM_UDP); - } else { - ifp->if_hwassist |= CSUM_TCP; - } - } + ifp->if_capenable ^= IFCAP_TXCSUM; + if (ifp->if_capenable & IFCAP_TXCSUM) + ifp->if_hwassist |= sc->hn_csum_assist; + else + ifp->if_hwassist &= ~sc->hn_csum_assist; } - if (mask & IFCAP_RXCSUM) { - if (IFCAP_RXCSUM & ifp->if_capenable) { - ifp->if_capenable &= ~IFCAP_RXCSUM; - } else { - ifp->if_capenable |= IFCAP_RXCSUM; - } - } + if (mask & IFCAP_RXCSUM) + ifp->if_capenable ^= IFCAP_RXCSUM; + if (mask & IFCAP_LRO) ifp->if_capenable ^= IFCAP_LRO; if (mask & IFCAP_TSO4) { ifp->if_capenable ^= IFCAP_TSO4; - ifp->if_hwassist ^= CSUM_IP_TSO; + if (ifp->if_capenable & IFCAP_TSO4) + ifp->if_hwassist |= CSUM_IP_TSO; + else + ifp->if_hwassist &= ~CSUM_IP_TSO; } if (mask & IFCAP_TSO6) { ifp->if_capenable ^= IFCAP_TSO6; - ifp->if_hwassist ^= CSUM_IP6_TSO; + if (ifp->if_capenable & IFCAP_TSO6) + ifp->if_hwassist |= CSUM_IP6_TSO; + else + ifp->if_hwassist &= ~CSUM_IP6_TSO; } + NV_UNLOCK(sc); error = 0; break; case SIOCADDMULTI: @@ -1737,6 +1703,30 @@ hn_lro_hiwat_sysctl(SYSCTL_HANDLER_ARGS) #endif /* HN_LRO_HIWAT */ static int +hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int hcsum = arg2; + int on, error; + + on = 0; + if (sc->hn_trust_hcsum & hcsum) + on = 1; + + error = sysctl_handle_int(oidp, &on, 0, req); + if (error || req->newptr == NULL) + return error; + + NV_LOCK(sc); + if (on) + sc->hn_trust_hcsum |= hcsum; + else + sc->hn_trust_hcsum &= ~hcsum; + NV_UNLOCK(sc); + return 0; +} + +static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; From owner-svn-src-stable-10@freebsd.org Mon Jun 13 06:09:03 2016 Return-Path: Delivered-To: svn-src-stable-10@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 D28FAAF0A76; Mon, 13 Jun 2016 06:09:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 94BD321E7; Mon, 13 Jun 2016 06:09:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D6926b054582; Mon, 13 Jun 2016 06:09:02 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D692hC054580; Mon, 13 Jun 2016 06:09:02 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130609.u5D692hC054580@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 06:09:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301857 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 06:09:03 -0000 Author: sephe Date: Mon Jun 13 06:09:02 2016 New Revision: 301857 URL: https://svnweb.freebsd.org/changeset/base/301857 Log: MFC 295302,295303 295302 hyperv/hn: Factor out hn_encap() from hn_start_locked() It will be shared w/ upcoming ifnet.if_transmit implementaion. No functional changes. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5158 295303 hyperv/hn: Recover half of the chimney sending space We lost half of the chimney sending space, because we mis-used ffs() on a 64 bits mask, where ffsl() should be used. While I'm here: - Use system atomic operation instead. - Stringent chimney sending index assertion. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5159 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Jun 13 05:43:42 2016 (r301856) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Jun 13 06:09:02 2016 (r301857) @@ -135,15 +135,15 @@ hv_nv_get_next_send_section(netvsc_dev * int i; for (i = 0; i < bitsmap_words; i++) { - idx = ffs(~bitsmap[i]); + idx = ffsl(~bitsmap[i]); if (0 == idx) continue; idx--; - if (i * BITS_PER_LONG + idx >= net_dev->send_section_count) - return (ret); + KASSERT(i * BITS_PER_LONG + idx < net_dev->send_section_count, + ("invalid i %d and idx %lu", i, idx)); - if (synch_test_and_set_bit(idx, &bitsmap[i])) + if (atomic_testandset_long(&bitsmap[i], idx)) continue; ret = i * BITS_PER_LONG + idx; @@ -788,8 +788,27 @@ hv_nv_on_send_completion(netvsc_dev *net if (NULL != net_vsc_pkt) { if (net_vsc_pkt->send_buf_section_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { - synch_change_bit(net_vsc_pkt->send_buf_section_idx, - net_dev->send_section_bitsmap); + u_long mask; + int idx; + + idx = net_vsc_pkt->send_buf_section_idx / + BITS_PER_LONG; + KASSERT(idx < net_dev->bitsmap_words, + ("invalid section index %u", + net_vsc_pkt->send_buf_section_idx)); + mask = 1UL << + (net_vsc_pkt->send_buf_section_idx % + BITS_PER_LONG); + + KASSERT(net_dev->send_section_bitsmap[idx] & + mask, + ("index bitmap 0x%lx, section index %u, " + "bitmap idx %d, bitmask 0x%lx", + net_dev->send_section_bitsmap[idx], + net_vsc_pkt->send_buf_section_idx, + idx, mask)); + atomic_clear_long( + &net_dev->send_section_bitsmap[idx], mask); } /* Notify the layer above us */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 05:43:42 2016 (r301856) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 06:09:02 2016 (r301857) @@ -254,6 +254,7 @@ static int hn_create_tx_ring(struct hn_s static void hn_destroy_tx_ring(struct hn_softc *sc); static void hn_start_taskfunc(void *xsc, int pending); static void hn_txeof_taskfunc(void *xsc, int pending); +static int hn_encap(struct hn_softc *, struct hn_txdesc *, struct mbuf **); static __inline void hn_set_lro_hiwat(struct hn_softc *sc, int hiwat) @@ -744,31 +745,235 @@ netvsc_channel_rollup(struct hv_device * } /* - * Start a transmit of one or more packets + * NOTE: + * This this function fails, then both txd and m_head0 will be freed */ static int -hn_start_locked(struct ifnet *ifp, int len) +hn_encap(struct hn_softc *sc, struct hn_txdesc *txd, struct mbuf **m_head0) { - hn_softc_t *sc = ifp->if_softc; - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); - netvsc_dev *net_dev = sc->net_dev; + bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; + int error, nsegs, i; + struct mbuf *m_head = *m_head0; + netvsc_packet *packet; rndis_msg *rndis_mesg; rndis_packet *rndis_pkt; rndis_per_packet_info *rppi; - ndis_8021q_info *rppi_vlan_info; - rndis_tcp_ip_csum_info *csum_info; - rndis_tcp_tso_info *tso_info; - uint32_t rndis_msg_size = 0; + uint32_t rndis_msg_size; + + packet = &txd->netvsc_pkt; + packet->is_data_pkt = TRUE; + packet->tot_data_buf_len = m_head->m_pkthdr.len; + + /* + * extension points to the area reserved for the + * rndis_filter_packet, which is placed just after + * the netvsc_packet (and rppi struct, if present; + * length is updated later). + */ + rndis_mesg = txd->rndis_msg; + /* XXX not necessary */ + memset(rndis_mesg, 0, HN_RNDIS_MSG_LEN); + rndis_mesg->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; + + rndis_pkt = &rndis_mesg->msg.packet; + rndis_pkt->data_offset = sizeof(rndis_packet); + rndis_pkt->data_length = packet->tot_data_buf_len; + rndis_pkt->per_pkt_info_offset = sizeof(rndis_packet); + + rndis_msg_size = RNDIS_MESSAGE_SIZE(rndis_packet); + + if (m_head->m_flags & M_VLANTAG) { + ndis_8021q_info *rppi_vlan_info; + + rndis_msg_size += RNDIS_VLAN_PPI_SIZE; + rppi = hv_set_rppi_data(rndis_mesg, RNDIS_VLAN_PPI_SIZE, + ieee_8021q_info); + + rppi_vlan_info = (ndis_8021q_info *)((uint8_t *)rppi + + rppi->per_packet_info_offset); + rppi_vlan_info->u1.s1.vlan_id = + m_head->m_pkthdr.ether_vtag & 0xfff; + } + + if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { + rndis_tcp_tso_info *tso_info; + struct ether_vlan_header *eh; + int ether_len; + + /* + * XXX need m_pullup and use mtodo + */ + eh = mtod(m_head, struct ether_vlan_header*); + if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) + ether_len = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; + else + ether_len = ETHER_HDR_LEN; + + rndis_msg_size += RNDIS_TSO_PPI_SIZE; + rppi = hv_set_rppi_data(rndis_mesg, RNDIS_TSO_PPI_SIZE, + tcp_large_send_info); + + tso_info = (rndis_tcp_tso_info *)((uint8_t *)rppi + + rppi->per_packet_info_offset); + tso_info->lso_v2_xmit.type = + RNDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE; + +#ifdef INET + if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { + struct ip *ip = + (struct ip *)(m_head->m_data + ether_len); + unsigned long iph_len = ip->ip_hl << 2; + struct tcphdr *th = + (struct tcphdr *)((caddr_t)ip + iph_len); + + tso_info->lso_v2_xmit.ip_version = + RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV4; + ip->ip_len = 0; + ip->ip_sum = 0; + + th->th_sum = in_pseudo(ip->ip_src.s_addr, + ip->ip_dst.s_addr, htons(IPPROTO_TCP)); + } +#endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET6 + { + struct ip6_hdr *ip6 = (struct ip6_hdr *) + (m_head->m_data + ether_len); + struct tcphdr *th = (struct tcphdr *)(ip6 + 1); + + tso_info->lso_v2_xmit.ip_version = + RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV6; + ip6->ip6_plen = 0; + th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); + } +#endif + tso_info->lso_v2_xmit.tcp_header_offset = 0; + tso_info->lso_v2_xmit.mss = m_head->m_pkthdr.tso_segsz; + } else if (m_head->m_pkthdr.csum_flags & sc->hn_csum_assist) { + rndis_tcp_ip_csum_info *csum_info; + + rndis_msg_size += RNDIS_CSUM_PPI_SIZE; + rppi = hv_set_rppi_data(rndis_mesg, RNDIS_CSUM_PPI_SIZE, + tcpip_chksum_info); + csum_info = (rndis_tcp_ip_csum_info *)((uint8_t *)rppi + + rppi->per_packet_info_offset); + + csum_info->xmit.is_ipv4 = 1; + if (m_head->m_pkthdr.csum_flags & CSUM_IP) + csum_info->xmit.ip_header_csum = 1; + + if (m_head->m_pkthdr.csum_flags & CSUM_TCP) { + csum_info->xmit.tcp_csum = 1; + csum_info->xmit.tcp_header_offset = 0; + } else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) { + csum_info->xmit.udp_csum = 1; + } + } + + rndis_mesg->msg_len = packet->tot_data_buf_len + rndis_msg_size; + packet->tot_data_buf_len = rndis_mesg->msg_len; + + /* + * Chimney send, if the packet could fit into one chimney buffer. + */ + if (packet->tot_data_buf_len < sc->hn_tx_chimney_size) { + netvsc_dev *net_dev = sc->net_dev; + uint32_t send_buf_section_idx; + + send_buf_section_idx = + hv_nv_get_next_send_section(net_dev); + if (send_buf_section_idx != + NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { + uint8_t *dest = ((uint8_t *)net_dev->send_buf + + (send_buf_section_idx * + net_dev->send_section_size)); + + memcpy(dest, rndis_mesg, rndis_msg_size); + dest += rndis_msg_size; + m_copydata(m_head, 0, m_head->m_pkthdr.len, dest); + + packet->send_buf_section_idx = send_buf_section_idx; + packet->send_buf_section_size = + packet->tot_data_buf_len; + packet->page_buf_count = 0; + sc->hn_tx_chimney++; + goto done; + } + } + + error = hn_txdesc_dmamap_load(sc, txd, &m_head, segs, &nsegs); + if (error) { + int freed; + + /* + * This mbuf is not linked w/ the txd yet, so free it now. + */ + m_freem(m_head); + *m_head0 = NULL; + + freed = hn_txdesc_put(sc, txd); + KASSERT(freed != 0, + ("fail to free txd upon txdma error")); + + sc->hn_txdma_failed++; + if_inc_counter(sc->hn_ifp, IFCOUNTER_OERRORS, 1); + return error; + } + *m_head0 = m_head; + + packet->page_buf_count = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; + + /* send packet with page buffer */ + packet->page_buffers[0].pfn = atop(txd->rndis_msg_paddr); + packet->page_buffers[0].offset = txd->rndis_msg_paddr & PAGE_MASK; + packet->page_buffers[0].length = rndis_msg_size; + + /* + * Fill the page buffers with mbuf info starting at index + * HV_RF_NUM_TX_RESERVED_PAGE_BUFS. + */ + for (i = 0; i < nsegs; ++i) { + hv_vmbus_page_buffer *pb = &packet->page_buffers[ + i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS]; + + pb->pfn = atop(segs[i].ds_addr); + pb->offset = segs[i].ds_addr & PAGE_MASK; + pb->length = segs[i].ds_len; + } + + packet->send_buf_section_idx = + NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; + packet->send_buf_section_size = 0; +done: + txd->m = m_head; + + /* Set the completion routine */ + packet->compl.send.on_send_completion = netvsc_xmit_completion; + packet->compl.send.send_completion_context = packet; + packet->compl.send.send_completion_tid = (uint64_t)(uintptr_t)txd; + + return 0; +} + +/* + * Start a transmit of one or more packets + */ +static int +hn_start_locked(struct ifnet *ifp, int len) +{ + struct hn_softc *sc = ifp->if_softc; + struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return 0; while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { - bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; - int error, nsegs, i, send_failed = 0; + int error, send_failed = 0; struct hn_txdesc *txd; - netvsc_packet *packet; struct mbuf *m_head; IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); @@ -793,216 +998,17 @@ hn_start_locked(struct ifnet *ifp, int l break; } - packet = &txd->netvsc_pkt; - packet->is_data_pkt = TRUE; - /* Initialize it from the mbuf */ - packet->tot_data_buf_len = m_head->m_pkthdr.len; - - /* - * extension points to the area reserved for the - * rndis_filter_packet, which is placed just after - * the netvsc_packet (and rppi struct, if present; - * length is updated later). - */ - rndis_mesg = txd->rndis_msg; - /* XXX not necessary */ - memset(rndis_mesg, 0, HN_RNDIS_MSG_LEN); - rndis_mesg->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; - - rndis_pkt = &rndis_mesg->msg.packet; - rndis_pkt->data_offset = sizeof(rndis_packet); - rndis_pkt->data_length = packet->tot_data_buf_len; - rndis_pkt->per_pkt_info_offset = sizeof(rndis_packet); - - rndis_msg_size = RNDIS_MESSAGE_SIZE(rndis_packet); - - /* - * If the Hyper-V infrastructure needs to embed a VLAN tag, - * initialize netvsc_packet and rppi struct values as needed. - */ - if (m_head->m_flags & M_VLANTAG) { - /* - * set up some additional fields so the Hyper-V infrastructure will stuff the VLAN tag - * into the frame. - */ - rndis_msg_size += RNDIS_VLAN_PPI_SIZE; - - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_VLAN_PPI_SIZE, - ieee_8021q_info); - - /* VLAN info immediately follows rppi struct */ - rppi_vlan_info = (ndis_8021q_info *)((char*)rppi + - rppi->per_packet_info_offset); - /* FreeBSD does not support CFI or priority */ - rppi_vlan_info->u1.s1.vlan_id = - m_head->m_pkthdr.ether_vtag & 0xfff; - } - - if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { - struct ether_vlan_header *eh; - int ether_len; - - eh = mtod(m_head, struct ether_vlan_header*); - if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) { - ether_len = ETHER_HDR_LEN + - ETHER_VLAN_ENCAP_LEN; - } else { - ether_len = ETHER_HDR_LEN; - } - - rndis_msg_size += RNDIS_TSO_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_TSO_PPI_SIZE, - tcp_large_send_info); - - tso_info = (rndis_tcp_tso_info *)((char *)rppi + - rppi->per_packet_info_offset); - tso_info->lso_v2_xmit.type = - RNDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE; - -#ifdef INET - if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { - struct ip *ip = - (struct ip *)(m_head->m_data + ether_len); - unsigned long iph_len = ip->ip_hl << 2; - struct tcphdr *th = - (struct tcphdr *)((caddr_t)ip + iph_len); - - tso_info->lso_v2_xmit.ip_version = - RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV4; - ip->ip_len = 0; - ip->ip_sum = 0; - - th->th_sum = in_pseudo(ip->ip_src.s_addr, - ip->ip_dst.s_addr, htons(IPPROTO_TCP)); - } -#endif -#if defined(INET6) && defined(INET) - else -#endif -#ifdef INET6 - { - struct ip6_hdr *ip6 = (struct ip6_hdr *) - (m_head->m_data + ether_len); - struct tcphdr *th = (struct tcphdr *)(ip6 + 1); - - tso_info->lso_v2_xmit.ip_version = - RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV6; - ip6->ip6_plen = 0; - th->th_sum = - in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); - } -#endif - tso_info->lso_v2_xmit.tcp_header_offset = 0; - tso_info->lso_v2_xmit.mss = m_head->m_pkthdr.tso_segsz; - } else if (m_head->m_pkthdr.csum_flags & sc->hn_csum_assist) { - rndis_msg_size += RNDIS_CSUM_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_CSUM_PPI_SIZE, - tcpip_chksum_info); - csum_info = (rndis_tcp_ip_csum_info *)((char*)rppi + - rppi->per_packet_info_offset); - - csum_info->xmit.is_ipv4 = 1; - if (m_head->m_pkthdr.csum_flags & CSUM_IP) - csum_info->xmit.ip_header_csum = 1; - - if (m_head->m_pkthdr.csum_flags & CSUM_TCP) { - csum_info->xmit.tcp_csum = 1; - csum_info->xmit.tcp_header_offset = 0; - } else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) { - csum_info->xmit.udp_csum = 1; - } - } - - rndis_mesg->msg_len = packet->tot_data_buf_len + rndis_msg_size; - packet->tot_data_buf_len = rndis_mesg->msg_len; - - /* send packet with send buffer */ - if (packet->tot_data_buf_len < sc->hn_tx_chimney_size) { - uint32_t send_buf_section_idx; - - send_buf_section_idx = - hv_nv_get_next_send_section(net_dev); - if (send_buf_section_idx != - NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { - uint8_t *dest = ((uint8_t *)net_dev->send_buf + - (send_buf_section_idx * - net_dev->send_section_size)); - - memcpy(dest, rndis_mesg, rndis_msg_size); - dest += rndis_msg_size; - - m_copydata(m_head, 0, m_head->m_pkthdr.len, - dest); - - packet->send_buf_section_idx = - send_buf_section_idx; - packet->send_buf_section_size = - packet->tot_data_buf_len; - packet->page_buf_count = 0; - sc->hn_tx_chimney++; - goto do_send; - } - } - - error = hn_txdesc_dmamap_load(sc, txd, &m_head, segs, &nsegs); + error = hn_encap(sc, txd, &m_head); if (error) { - int freed; - - /* - * This mbuf is not linked w/ the txd yet, so free - * it now. - */ - m_freem(m_head); - freed = hn_txdesc_put(sc, txd); - KASSERT(freed != 0, - ("fail to free txd upon txdma error")); - - sc->hn_txdma_failed++; - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + /* Both txd and m_head are freed */ continue; } - - packet->page_buf_count = nsegs + - HV_RF_NUM_TX_RESERVED_PAGE_BUFS; - - /* send packet with page buffer */ - packet->page_buffers[0].pfn = atop(txd->rndis_msg_paddr); - packet->page_buffers[0].offset = - txd->rndis_msg_paddr & PAGE_MASK; - packet->page_buffers[0].length = rndis_msg_size; - - /* - * Fill the page buffers with mbuf info starting at index - * HV_RF_NUM_TX_RESERVED_PAGE_BUFS. - */ - for (i = 0; i < nsegs; ++i) { - hv_vmbus_page_buffer *pb = &packet->page_buffers[ - i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS]; - - pb->pfn = atop(segs[i].ds_addr); - pb->offset = segs[i].ds_addr & PAGE_MASK; - pb->length = segs[i].ds_len; - } - - packet->send_buf_section_idx = - NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; - packet->send_buf_section_size = 0; - -do_send: - txd->m = m_head; - - /* Set the completion routine */ - packet->compl.send.on_send_completion = netvsc_xmit_completion; - packet->compl.send.send_completion_context = packet; - packet->compl.send.send_completion_tid = - (uint64_t)(uintptr_t)txd; - again: /* * Make sure that txd is not freed before ETHER_BPF_MTAP. */ hn_txdesc_hold(txd); - error = hv_nv_on_send(device_ctx, packet); + error = hv_nv_on_send(device_ctx, &txd->netvsc_pkt); if (!error) { ETHER_BPF_MTAP(ifp, m_head); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); From owner-svn-src-stable-10@freebsd.org Mon Jun 13 06:24:42 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E9B4FAF0E85; Mon, 13 Jun 2016 06:24:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C11F42ADF; Mon, 13 Jun 2016 06:24:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D6OfwG062067; Mon, 13 Jun 2016 06:24:41 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D6Ofcw062065; Mon, 13 Jun 2016 06:24:41 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130624.u5D6Ofcw062065@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 06:24:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301858 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 06:24:43 -0000 Author: sephe Date: Mon Jun 13 06:24:41 2016 New Revision: 301858 URL: https://svnweb.freebsd.org/changeset/base/301858 Log: MFC 295304,295305,295306 295304 hyperv/hn: Increase LRO entry count to 128 by default hn(4) only has one RX ring currently, so default 8 LRO entries are too small. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5166 295305 hyperv/hn: Move LRO flush to the channel processing rollup This significantly increases LRO aggregation ratio when there are large amount of connections (improves reception performance a lot). Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5167 295306 hyperv/hn: Add an option to always do transmission scheduling It is off by default. This eases more experiment on hn(4). Reviewed by: adrian, Hongjiang Zhang Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5175 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 06:09:02 2016 (r301857) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 06:24:41 2016 (r301858) @@ -1024,6 +1024,7 @@ typedef struct hn_softc { int hn_txdesc_avail; int hn_txeof; + int hn_sched_tx; int hn_direct_tx_size; struct taskqueue *hn_tx_taskq; struct task hn_start_task; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 06:09:02 2016 (r301857) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 06:24:41 2016 (r301858) @@ -132,6 +132,8 @@ __FBSDID("$FreeBSD$"); /* YYY should get it from the underlying channel */ #define HN_TX_DESC_CNT 512 +#define HN_LROENT_CNT_DEF 128 + #define HN_RNDIS_MSG_LEN \ (sizeof(rndis_msg) + \ RNDIS_VLAN_PPI_SIZE + \ @@ -232,6 +234,13 @@ TUNABLE_INT("dev.hn.tx_chimney_size", &h static int hn_direct_tx_size = HN_DIRECT_TX_SIZE_DEF; TUNABLE_INT("dev.hn.direct_tx_size", &hn_direct_tx_size); +#if defined(INET) || defined(INET6) +#if __FreeBSD_version >= 1100095 +static int hn_lro_entry_count = HN_LROENT_CNT_DEF; +TUNABLE_INT("dev.hn.lro_entry_count", &hn_lro_entry_count); +#endif +#endif + /* * Forward declarations */ @@ -335,6 +344,11 @@ netvsc_attach(device_t dev) #if __FreeBSD_version >= 1100045 int tso_maxlen; #endif +#if defined(INET) || defined(INET6) +#if __FreeBSD_version >= 1100095 + int lroent_cnt; +#endif +#endif sc = device_get_softc(dev); if (sc == NULL) { @@ -417,9 +431,17 @@ netvsc_attach(device_t dev) } #if defined(INET) || defined(INET6) +#if __FreeBSD_version >= 1100095 + lroent_cnt = hn_lro_entry_count; + if (lroent_cnt < TCP_LRO_ENTRIES) + lroent_cnt = TCP_LRO_ENTRIES; + tcp_lro_init_args(&sc->hn_lro, ifp, lroent_cnt, 0); + device_printf(dev, "LRO: entry count %d\n", lroent_cnt); +#else tcp_lro_init(&sc->hn_lro); /* Driver private LRO settings */ sc->hn_lro.ifp = ifp; +#endif #ifdef HN_LRO_HIWAT sc->hn_lro.lro_hiwat = sc->hn_lro_hiwat; #endif @@ -512,6 +534,10 @@ netvsc_attach(device_t dev) SYSCTL_ADD_INT(ctx, child, OID_AUTO, "direct_tx_size", CTLFLAG_RW, &sc->hn_direct_tx_size, 0, "Size of the packet for direct transmission"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sched_tx", + CTLFLAG_RW, &sc->hn_sched_tx, 0, + "Always schedule transmission " + "instead of doing direct transmission"); if (unit == 0) { struct sysctl_ctx_list *dc_ctx; @@ -547,6 +573,12 @@ netvsc_attach(device_t dev) SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "direct_tx_size", CTLFLAG_RD, &hn_direct_tx_size, 0, "Size of the packet for direct transmission"); +#if defined(INET) || defined(INET6) +#if __FreeBSD_version >= 1100095 + SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "lro_entry_count", + CTLFLAG_RD, &hn_lro_entry_count, 0, "LRO entry count"); +#endif +#endif } return (0); @@ -736,6 +768,15 @@ void netvsc_channel_rollup(struct hv_device *device_ctx) { struct hn_softc *sc = device_get_softc(device_ctx->device); +#if defined(INET) || defined(INET6) + struct lro_ctrl *lro = &sc->hn_lro; + struct lro_entry *queued; + + while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { + SLIST_REMOVE_HEAD(&lro->lro_active, next); + tcp_lro_flush(lro, queued); + } +#endif if (!sc->hn_txeof) return; @@ -1312,18 +1353,8 @@ skip: } void -netvsc_recv_rollup(struct hv_device *device_ctx) +netvsc_recv_rollup(struct hv_device *device_ctx __unused) { -#if defined(INET) || defined(INET6) - hn_softc_t *sc = device_get_softc(device_ctx->device); - struct lro_ctrl *lro = &sc->hn_lro; - struct lro_entry *queued; - - while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } -#endif } /* @@ -1577,9 +1608,11 @@ hn_stop(hn_softc_t *sc) static void hn_start(struct ifnet *ifp) { - hn_softc_t *sc; + struct hn_softc *sc = ifp->if_softc; + + if (sc->hn_sched_tx) + goto do_sched; - sc = ifp->if_softc; if (NV_TRYLOCK(sc)) { int sched; @@ -1588,15 +1621,18 @@ hn_start(struct ifnet *ifp) if (!sched) return; } +do_sched: taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_start_task); } static void hn_start_txeof(struct ifnet *ifp) { - hn_softc_t *sc; + struct hn_softc *sc = ifp->if_softc; + + if (sc->hn_sched_tx) + goto do_sched; - sc = ifp->if_softc; if (NV_TRYLOCK(sc)) { int sched; @@ -1608,6 +1644,7 @@ hn_start_txeof(struct ifnet *ifp) &sc->hn_start_task); } } else { +do_sched: /* * Release the OACTIVE earlier, with the hope, that * others could catch up. The task will clear the From owner-svn-src-stable-10@freebsd.org Mon Jun 13 06:38:49 2016 Return-Path: Delivered-To: svn-src-stable-10@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 5BB85AF11E8; Mon, 13 Jun 2016 06:38:49 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 ECB812233; Mon, 13 Jun 2016 06:38:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D6cmmu066216; Mon, 13 Jun 2016 06:38:48 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D6clMh066204; Mon, 13 Jun 2016 06:38:47 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130638.u5D6clMh066204@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 06:38:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301859 - in stable/10/sys/dev/hyperv: include netvsc utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 06:38:49 -0000 Author: sephe Date: Mon Jun 13 06:38:46 2016 New Revision: 301859 URL: https://svnweb.freebsd.org/changeset/base/301859 Log: MFC 295307,295308,295309,295606 295307 hyperv: Use standard taskqueue instead of hv_work_queue HyperV code was ported from Linux. There is an implementation of work queue called hv_work_queue. In FreeBSD, taskqueue could be used for the same purpose. Convert all the consumer of hv_work_queue to use taskqueue, and remove work queue implementation. Submitted by: Jun Su Reviewed by: adrian, Hongjiang Zhang Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D4963 295308 hyperv: Use WAITOK in the places where we can wait And convert rndis non-hot path spinlock to mutex. Submitted by: Jun Su Reviewed by: adrian, sephe Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5081 295309 hyperv: Use malloc for page allocation. We will eventually convert them to use busdma. Submitted by: Jun Su Reviewed by: adrian, sephe, Dexuan Cui Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5087 295606 hyperv/hn: Fix typo in comment Noticed by: avos Reviewed by: adrian, avos, Hongjiang Zhang Approved by: adrian MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5199 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_connection.c stable/10/sys/dev/hyperv/vmbus/hv_hv.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/include/hyperv.h Mon Jun 13 06:38:46 2016 (r301859) @@ -908,30 +908,6 @@ int hv_vmbus_channel_teardown_gpdal( struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary); -/* - * Work abstraction defines - */ -typedef struct hv_work_queue { - struct taskqueue* queue; - struct proc* proc; - struct sema* work_sema; -} hv_work_queue; - -typedef struct hv_work_item { - struct task work; - void (*callback)(void *); - void* context; - hv_work_queue* wq; -} hv_work_item; - -struct hv_work_queue* hv_work_queue_create(char* name); - -void hv_work_queue_close(struct hv_work_queue* wq); - -int hv_queue_work_item( - hv_work_queue* wq, - void (*callback)(void *), - void* context); /** * @brief Get physical address from virtual */ @@ -952,8 +928,8 @@ typedef struct hv_vmbus_service { hv_guid guid; /* Hyper-V GUID */ char *name; /* name of service */ boolean_t enabled; /* service enabled */ - hv_work_queue *work_queue; /* background work queue */ - + void* context; + struct task task; /* * function to initialize service */ @@ -963,6 +939,11 @@ typedef struct hv_vmbus_service { * function to process Hyper-V messages */ void (*callback)(void *); + + /* + * function to uninitilize service + */ + int (*uninit)(struct hv_vmbus_service *); } hv_vmbus_service; extern uint8_t* receive_buffer[]; Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Jun 13 06:38:46 2016 (r301859) @@ -73,10 +73,7 @@ hv_nv_alloc_net_device(struct hv_device netvsc_dev *net_dev; hn_softc_t *sc = device_get_softc(device->device); - net_dev = malloc(sizeof(netvsc_dev), M_NETVSC, M_NOWAIT | M_ZERO); - if (net_dev == NULL) { - return (NULL); - } + net_dev = malloc(sizeof(netvsc_dev), M_NETVSC, M_WAITOK | M_ZERO); net_dev->dev = device; net_dev->destroy = FALSE; @@ -223,11 +220,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.num_sections; net_dev->rx_sections = malloc(net_dev->rx_section_count * - sizeof(nvsp_1_rx_buf_section), M_NETVSC, M_NOWAIT); - if (net_dev->rx_sections == NULL) { - ret = EINVAL; - goto cleanup; - } + sizeof(nvsp_1_rx_buf_section), M_NETVSC, M_WAITOK); memcpy(net_dev->rx_sections, init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.sections, net_dev->rx_section_count * sizeof(nvsp_1_rx_buf_section)); @@ -325,11 +318,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru BITS_PER_LONG); net_dev->send_section_bitsmap = malloc(net_dev->bitsmap_words * sizeof(long), M_NETVSC, - M_NOWAIT | M_ZERO); - if (NULL == net_dev->send_section_bitsmap) { - ret = ENOMEM; - goto cleanup; - } + M_WAITOK | M_ZERO); goto exit; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 06:38:46 2016 (r301859) @@ -787,7 +787,7 @@ netvsc_channel_rollup(struct hv_device * /* * NOTE: - * This this function fails, then both txd and m_head0 will be freed + * If this function fails, then both txd and m_head0 will be freed. */ static int hn_encap(struct hn_softc *sc, struct hn_txdesc *txd, struct mbuf **m_head0) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Jun 13 06:38:46 2016 (r301859) @@ -136,12 +136,9 @@ hv_get_rndis_device(void) { rndis_device *device; - device = malloc(sizeof(rndis_device), M_NETVSC, M_NOWAIT | M_ZERO); - if (device == NULL) { - return (NULL); - } + device = malloc(sizeof(rndis_device), M_NETVSC, M_WAITOK | M_ZERO); - mtx_init(&device->req_lock, "HV-FRL", NULL, MTX_SPIN | MTX_RECURSE); + mtx_init(&device->req_lock, "HV-FRL", NULL, MTX_DEF); /* Same effect as STAILQ_HEAD_INITIALIZER() static initializer */ STAILQ_INIT(&device->myrequest_list); @@ -172,10 +169,7 @@ hv_rndis_request(rndis_device *device, u rndis_msg *rndis_mesg; rndis_set_request *set; - request = malloc(sizeof(rndis_request), M_NETVSC, M_NOWAIT | M_ZERO); - if (request == NULL) { - return (NULL); - } + request = malloc(sizeof(rndis_request), M_NETVSC, M_WAITOK | M_ZERO); sema_init(&request->wait_sema, 0, "rndis sema"); @@ -194,9 +188,9 @@ hv_rndis_request(rndis_device *device, u set->request_id += 1; /* Add to the request list */ - mtx_lock_spin(&device->req_lock); + mtx_lock(&device->req_lock); STAILQ_INSERT_TAIL(&device->myrequest_list, request, mylist_entry); - mtx_unlock_spin(&device->req_lock); + mtx_unlock(&device->req_lock); return (request); } @@ -207,14 +201,14 @@ hv_rndis_request(rndis_device *device, u static inline void hv_put_rndis_request(rndis_device *device, rndis_request *request) { - mtx_lock_spin(&device->req_lock); + mtx_lock(&device->req_lock); /* Fixme: Has O(n) performance */ /* * XXXKYS: Use Doubly linked lists. */ STAILQ_REMOVE(&device->myrequest_list, request, rndis_request_, mylist_entry); - mtx_unlock_spin(&device->req_lock); + mtx_unlock(&device->req_lock); sema_destroy(&request->wait_sema); free(request, M_NETVSC); @@ -271,7 +265,7 @@ hv_rf_receive_response(rndis_device *dev rndis_request *next_request; boolean_t found = FALSE; - mtx_lock_spin(&device->req_lock); + mtx_lock(&device->req_lock); request = STAILQ_FIRST(&device->myrequest_list); while (request != NULL) { /* @@ -286,7 +280,7 @@ hv_rf_receive_response(rndis_device *dev next_request = STAILQ_NEXT(request, mylist_entry); request = next_request; } - mtx_unlock_spin(&device->req_lock); + mtx_unlock(&device->req_lock); if (found) { if (response->msg_len <= sizeof(rndis_msg)) { Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Mon Jun 13 06:38:46 2016 (r301859) @@ -98,7 +98,7 @@ static d_poll_t hv_kvp_dev_daemon_poll; static int hv_kvp_req_in_progress(void); static void hv_kvp_transaction_init(uint32_t, hv_vmbus_channel *, uint64_t, uint8_t *); static void hv_kvp_send_msg_to_daemon(void); -static void hv_kvp_process_request(void *context); +static void hv_kvp_process_request(void *context, int pending); /* hv_kvp character device structure */ static struct cdevsw hv_kvp_cdevsw = @@ -123,9 +123,6 @@ static struct selinfo hv_kvp_selinfo; */ static struct { - /* Pre-allocated work item for queue */ - hv_work_item work_item; - /* Unless specified the pending mutex should be * used to alter the values of the following paramters: * 1. req_in_progress @@ -642,7 +639,7 @@ hv_kvp_send_msg_to_daemon(void) * and interact with daemon */ static void -hv_kvp_process_request(void *context) +hv_kvp_process_request(void *context, int pending) { uint8_t *kvp_buf; hv_vmbus_channel *channel = context; @@ -756,23 +753,18 @@ hv_kvp_callback(void *context) uint64_t pending_cnt = 0; if (kvp_globals.register_done == false) { - kvp_globals.channelp = context; + TASK_INIT(&service_table[HV_KVP].task, 0, hv_kvp_process_request, context); } else { - mtx_lock(&kvp_globals.pending_mutex); kvp_globals.pending_reqs = kvp_globals.pending_reqs + 1; pending_cnt = kvp_globals.pending_reqs; mtx_unlock(&kvp_globals.pending_mutex); if (pending_cnt == 1) { hv_kvp_log_info("%s: Queuing work item\n", __func__); - hv_queue_work_item( - service_table[HV_KVP].work_queue, - hv_kvp_process_request, - context - ); + taskqueue_enqueue(taskqueue_thread, &service_table[HV_KVP].task); } - } + } } @@ -977,26 +969,13 @@ int hv_kvp_init(hv_vmbus_service *srv) { int error = 0; - hv_work_queue *work_queue = NULL; - - memset(&kvp_globals, 0, sizeof(kvp_globals)); - work_queue = hv_work_queue_create("KVP Service"); - if (work_queue == NULL) { - hv_kvp_log_info("%s: Work queue alloc failed\n", __func__); - error = ENOMEM; - hv_kvp_log_error("%s: ENOMEM\n", __func__); - goto Finish; - } - srv->work_queue = work_queue; + memset(&kvp_globals, 0, sizeof(kvp_globals)); error = hv_kvp_dev_init(); mtx_init(&kvp_globals.pending_mutex, "hv-kvp pending mutex", - NULL, MTX_DEF); - kvp_globals.pending_reqs = 0; - + NULL, MTX_DEF); -Finish: return (error); } Modified: stable/10/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/utilities/hv_util.c Mon Jun 13 06:38:46 2016 (r301859) @@ -52,6 +52,8 @@ static void hv_heartbeat_cb(void *contex static void hv_timesync_cb(void *context); static int hv_timesync_init(hv_vmbus_service *serv); +static int hv_timesync_uninit(hv_vmbus_service *serv); +static void hv_set_host_time(void *context, int pending); /* * Note: GUID codes below are predefined by the host hypervisor @@ -73,6 +75,7 @@ hv_vmbus_service service_table[] = { .enabled = TRUE, .init = hv_timesync_init, .callback = hv_timesync_cb, + .uninit = hv_timesync_uninit, }, /* Heartbeat Service */ @@ -111,10 +114,16 @@ struct hv_ictimesync_data { static int hv_timesync_init(hv_vmbus_service *serv) { + void *time_msg = malloc(sizeof(time_sync_data), M_DEVBUF, M_WAITOK); + TASK_INIT(&serv->task, 1, hv_set_host_time, time_msg); + return (0); +} - serv->work_queue = hv_work_queue_create("Time Sync"); - if (serv->work_queue == NULL) - return (ENOMEM); +static int +hv_timesync_uninit(hv_vmbus_service *serv) +{ + taskqueue_drain(taskqueue_thread, &serv->task); + free(serv->task.ta_context, M_DEVBUF); return (0); } @@ -152,9 +161,9 @@ hv_negotiate_version( * Set host time based on time sync message from host */ static void -hv_set_host_time(void *context) +hv_set_host_time(void *context, int pending) { - time_sync_data* time_msg = (time_sync_data*) context; + time_sync_data* time_msg = (time_sync_data*) context; uint64_t hosttime = time_msg->data; struct timespec guest_ts, host_ts; uint64_t host_tns; @@ -166,7 +175,7 @@ hv_set_host_time(void *context) host_ts.tv_nsec = (long)(host_tns%HV_NANO_SEC_PER_SEC); nanotime(&guest_ts); - + diff = (int64_t)host_ts.tv_sec - (int64_t)guest_ts.tv_sec; /* @@ -175,12 +184,7 @@ hv_set_host_time(void *context) if (diff > 5 || diff < -5) { error = kern_clock_settime(curthread, CLOCK_REALTIME, &host_ts); - } - - /* - * Free the hosttime that was allocated in hv_adj_guesttime() - */ - free(time_msg, M_DEVBUF); + } } /** @@ -197,23 +201,13 @@ hv_set_host_time(void *context) static inline void hv_adj_guesttime(uint64_t hosttime, uint8_t flags) { - time_sync_data* time_msg; - - time_msg = malloc(sizeof(time_sync_data), M_DEVBUF, M_NOWAIT); + time_sync_data* time_msg = service_table[HV_TIME_SYNCH].task.ta_context; - if (time_msg == NULL) - return; - time_msg->data = hosttime; - if ((flags & HV_ICTIMESYNCFLAG_SYNC) != 0) { - hv_queue_work_item(service_table[HV_TIME_SYNCH].work_queue, - hv_set_host_time, time_msg); - } else if ((flags & HV_ICTIMESYNCFLAG_SAMPLE) != 0) { - hv_queue_work_item(service_table[HV_TIME_SYNCH].work_queue, - hv_set_host_time, time_msg); - } else { - free(time_msg, M_DEVBUF); + if (((flags & HV_ICTIMESYNCFLAG_SYNC) != 0) || + ((flags & HV_ICTIMESYNCFLAG_SAMPLE) != 0)) { + taskqueue_enqueue(taskqueue_thread, &service_table[HV_TIME_SYNCH].task); } } @@ -452,19 +446,14 @@ hv_util_detach(device_t dev) service = device_get_softc(dev); receive_buffer_offset = service - &service_table[0]; - if (service->work_queue != NULL) - hv_work_queue_close(service->work_queue); + if (service->uninit != NULL) + service->uninit(service); free(receive_buffer[receive_buffer_offset], M_DEVBUF); receive_buffer[receive_buffer_offset] = NULL; return (0); } -static void -hv_util_init(void) -{ -} - static int hv_util_modevent(module_t mod, int event, void *arg) { @@ -495,6 +484,3 @@ static devclass_t util_devclass; DRIVER_MODULE(hv_utils, vmbus, util_driver, util_devclass, hv_util_modevent, 0); MODULE_VERSION(hv_utils, 1); MODULE_DEPEND(hv_utils, vmbus, 1, 1, 1); - -SYSINIT(hv_util_initx, SI_SUB_KTHREAD_IDLE, SI_ORDER_MIDDLE + 1, - hv_util_init, NULL); Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Mon Jun 13 06:38:46 2016 (r301859) @@ -69,9 +69,7 @@ vmbus_channel_set_event(hv_vmbus_channel + ((channel->offer_msg.child_rel_id >> 5)))); monitor_page = (hv_vmbus_monitor_page *) - hv_vmbus_g_connection.monitor_pages; - - monitor_page++; /* Get the child to parent monitor page */ + hv_vmbus_g_connection.monitor_page_2; synch_set_bit(channel->monitor_bit, (uint32_t *)&monitor_page-> Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Mon Jun 13 06:38:46 2016 (r301859) @@ -39,8 +39,10 @@ __FBSDID("$FreeBSD$"); */ static void vmbus_channel_on_offer(hv_vmbus_channel_msg_header* hdr); +static void vmbus_channel_on_offer_internal(void* context); static void vmbus_channel_on_open_result(hv_vmbus_channel_msg_header* hdr); static void vmbus_channel_on_offer_rescind(hv_vmbus_channel_msg_header* hdr); +static void vmbus_channel_on_offer_rescind_internal(void* context); static void vmbus_channel_on_gpadl_created(hv_vmbus_channel_msg_header* hdr); static void vmbus_channel_on_gpadl_torndown(hv_vmbus_channel_msg_header* hdr); static void vmbus_channel_on_offers_delivered(hv_vmbus_channel_msg_header* hdr); @@ -52,41 +54,46 @@ static void vmbus_channel_on_version_res hv_vmbus_channel_msg_table_entry g_channel_message_table[HV_CHANNEL_MESSAGE_COUNT] = { { HV_CHANNEL_MESSAGE_INVALID, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGE_OFFER_CHANNEL, - 0, vmbus_channel_on_offer }, + vmbus_channel_on_offer }, { HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER, - 0, vmbus_channel_on_offer_rescind }, + vmbus_channel_on_offer_rescind }, { HV_CHANNEL_MESSAGE_REQUEST_OFFERS, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED, - 1, vmbus_channel_on_offers_delivered }, + vmbus_channel_on_offers_delivered }, { HV_CHANNEL_MESSAGE_OPEN_CHANNEL, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT, - 1, vmbus_channel_on_open_result }, + vmbus_channel_on_open_result }, { HV_CHANNEL_MESSAGE_CLOSE_CHANNEL, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGEL_GPADL_HEADER, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGE_GPADL_BODY, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGE_GPADL_CREATED, - 1, vmbus_channel_on_gpadl_created }, + vmbus_channel_on_gpadl_created }, { HV_CHANNEL_MESSAGE_GPADL_TEARDOWN, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGE_GPADL_TORNDOWN, - 1, vmbus_channel_on_gpadl_torndown }, + vmbus_channel_on_gpadl_torndown }, { HV_CHANNEL_MESSAGE_REL_ID_RELEASED, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGE_INITIATED_CONTACT, - 0, NULL }, + NULL }, { HV_CHANNEL_MESSAGE_VERSION_RESPONSE, - 1, vmbus_channel_on_version_response }, + vmbus_channel_on_version_response }, { HV_CHANNEL_MESSAGE_UNLOAD, - 0, NULL } + NULL } }; +typedef struct hv_work_item { + struct task work; + void (*callback)(void *); + void* context; +} hv_work_item; /** * Implementation of the work abstraction. @@ -96,120 +103,30 @@ work_item_callback(void *work, int pendi { struct hv_work_item *w = (struct hv_work_item *)work; - /* - * Serialize work execution. - */ - if (w->wq->work_sema != NULL) { - sema_wait(w->wq->work_sema); - } - w->callback(w->context); - if (w->wq->work_sema != NULL) { - sema_post(w->wq->work_sema); - } - free(w, M_DEVBUF); } -struct hv_work_queue* -hv_work_queue_create(char* name) -{ - static unsigned int qid = 0; - char qname[64]; - int pri; - struct hv_work_queue* wq; - - wq = malloc(sizeof(struct hv_work_queue), M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT(wq != NULL, ("Error VMBUS: Failed to allocate work_queue\n")); - if (wq == NULL) - return (NULL); - - /* - * We use work abstraction to handle messages - * coming from the host and these are typically offers. - * Some FreeBsd drivers appear to have a concurrency issue - * where probe/attach needs to be serialized. We ensure that - * by having only one thread process work elements in a - * specific queue by serializing work execution. - * - */ - if (strcmp(name, "vmbusQ") == 0) { - pri = PI_DISK; - } else { /* control */ - pri = PI_NET; - /* - * Initialize semaphore for this queue by pointing - * to the globale semaphore used for synchronizing all - * control messages. - */ - wq->work_sema = &hv_vmbus_g_connection.control_sema; - } - - sprintf(qname, "hv_%s_%u", name, qid); - - /* - * Fixme: FreeBSD 8.2 has a different prototype for - * taskqueue_create(), and for certain other taskqueue functions. - * We need to research the implications of these changes. - * Fixme: Not sure when the changes were introduced. - */ - wq->queue = taskqueue_create(qname, M_NOWAIT, taskqueue_thread_enqueue, - &wq->queue - #if __FreeBSD_version < 800000 - , &wq->proc - #endif - ); - - if (wq->queue == NULL) { - free(wq, M_DEVBUF); - return (NULL); - } - - if (taskqueue_start_threads(&wq->queue, 1, pri, "%s taskq", qname)) { - taskqueue_free(wq->queue); - free(wq, M_DEVBUF); - return (NULL); - } - - qid++; - - return (wq); -} - -void -hv_work_queue_close(struct hv_work_queue *wq) -{ - /* - * KYS: Need to drain the taskqueue - * before we close the hv_work_queue. - */ - /*KYS: taskqueue_drain(wq->tq, ); */ - taskqueue_free(wq->queue); - free(wq, M_DEVBUF); -} - /** * @brief Create work item */ -int +static int hv_queue_work_item( - struct hv_work_queue *wq, void (*callback)(void *), void *context) { struct hv_work_item *w = malloc(sizeof(struct hv_work_item), - M_DEVBUF, M_NOWAIT | M_ZERO); + M_DEVBUF, M_NOWAIT); KASSERT(w != NULL, ("Error VMBUS: Failed to allocate WorkItem\n")); if (w == NULL) return (ENOMEM); w->callback = callback; w->context = context; - w->wq = wq; TASK_INIT(&w->work, 0, work_item_callback, w); - return (taskqueue_enqueue(wq->queue, &w->work)); + return (taskqueue_enqueue(taskqueue_thread, &w->work)); } @@ -224,10 +141,7 @@ hv_vmbus_allocate_channel(void) channel = (hv_vmbus_channel*) malloc( sizeof(hv_vmbus_channel), M_DEVBUF, - M_NOWAIT | M_ZERO); - KASSERT(channel != NULL, ("Error VMBUS: Failed to allocate channel!")); - if (channel == NULL) - return (NULL); + M_WAITOK | M_ZERO); mtx_init(&channel->inbound_lock, "channel inbound", NULL, MTX_DEF); mtx_init(&channel->sc_lock, "vmbus multi channel", NULL, MTX_DEF); @@ -238,16 +152,6 @@ hv_vmbus_allocate_channel(void) } /** - * @brief Release the vmbus channel object itself - */ -static inline void -ReleaseVmbusChannel(void *context) -{ - hv_vmbus_channel* channel = (hv_vmbus_channel*) context; - free(channel, M_DEVBUF); -} - -/** * @brief Release the resources used by the vmbus channel object */ void @@ -255,13 +159,8 @@ hv_vmbus_free_vmbus_channel(hv_vmbus_cha { mtx_destroy(&channel->sc_lock); mtx_destroy(&channel->inbound_lock); - /* - * We have to release the channel's workqueue/thread in - * the vmbus's workqueue/thread context - * ie we can't destroy ourselves - */ - hv_queue_work_item(hv_vmbus_g_connection.work_queue, - ReleaseVmbusChannel, (void *) channel); + + free(channel, M_DEVBUF); } /** @@ -459,7 +358,7 @@ static void vmbus_channel_on_offer(hv_vmbus_channel_msg_header* hdr) { hv_vmbus_channel_offer_channel* offer; - hv_vmbus_channel* new_channel; + hv_vmbus_channel_offer_channel* copied; offer = (hv_vmbus_channel_offer_channel*) hdr; @@ -469,10 +368,25 @@ vmbus_channel_on_offer(hv_vmbus_channel_ guidType = &offer->offer.interface_type; guidInstance = &offer->offer.interface_instance; + // copy offer data + copied = malloc(sizeof(*copied), M_DEVBUF, M_NOWAIT); + if (copied == NULL) { + printf("fail to allocate memory\n"); + return; + } + + memcpy(copied, hdr, sizeof(*copied)); + hv_queue_work_item(vmbus_channel_on_offer_internal, copied); +} + +static void +vmbus_channel_on_offer_internal(void* context) +{ + hv_vmbus_channel* new_channel; + + hv_vmbus_channel_offer_channel* offer = (hv_vmbus_channel_offer_channel*)context; /* Allocate the channel object and save this offer */ new_channel = hv_vmbus_allocate_channel(); - if (new_channel == NULL) - return; /* * By default we setup state to enable batched @@ -512,6 +426,8 @@ vmbus_channel_on_offer(hv_vmbus_channel_ new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32; vmbus_channel_process_offer(new_channel); + + free(offer, M_DEVBUF); } /** @@ -529,13 +445,20 @@ vmbus_channel_on_offer_rescind(hv_vmbus_ rescind = (hv_vmbus_channel_rescind_offer*) hdr; channel = hv_vmbus_g_connection.channels[rescind->child_rel_id]; - if (channel == NULL) + if (channel == NULL) return; - hv_vmbus_child_device_unregister(channel->device); - mtx_lock(&hv_vmbus_g_connection.channel_lock); + hv_queue_work_item(vmbus_channel_on_offer_rescind_internal, channel); hv_vmbus_g_connection.channels[rescind->child_rel_id] = NULL; - mtx_unlock(&hv_vmbus_g_connection.channel_lock); +} + +static void +vmbus_channel_on_offer_rescind_internal(void *context) +{ + hv_vmbus_channel* channel; + + channel = (hv_vmbus_channel*)context; + hv_vmbus_child_device_unregister(channel->device); } /** @@ -712,35 +635,6 @@ vmbus_channel_on_version_response(hv_vmb } /** - * @brief Handler for channel protocol messages. - * - * This is invoked in the vmbus worker thread context. - */ -void -hv_vmbus_on_channel_message(void *context) -{ - hv_vmbus_message* msg; - hv_vmbus_channel_msg_header* hdr; - int size; - - msg = (hv_vmbus_message*) context; - hdr = (hv_vmbus_channel_msg_header*) msg->u.payload; - size = msg->header.payload_size; - - if (hdr->message_type >= HV_CHANNEL_MESSAGE_COUNT) { - free(msg, M_DEVBUF); - return; - } - - if (g_channel_message_table[hdr->message_type].messageHandler) { - g_channel_message_table[hdr->message_type].messageHandler(hdr); - } - - /* Free the msg that was allocated in VmbusOnMsgDPC() */ - free(msg, M_DEVBUF); -} - -/** * @brief Send a request to get all our pending offers. */ int @@ -765,8 +659,7 @@ hv_vmbus_request_channel_offers(void) ret = hv_vmbus_post_message(msg, sizeof(hv_vmbus_channel_msg_header)); - if (msg_info) - free(msg_info, M_DEVBUF); + free(msg_info, M_DEVBUF); return (ret); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_connection.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c Mon Jun 13 06:38:46 2016 (r301859) @@ -90,12 +90,10 @@ hv_vmbus_negotiate_version(hv_vmbus_chan hv_vmbus_g_connection.interrupt_page); msg->monitor_page_1 = hv_get_phys_addr( - hv_vmbus_g_connection.monitor_pages); + hv_vmbus_g_connection.monitor_page_1); - msg->monitor_page_2 = - hv_get_phys_addr( - ((uint8_t *) hv_vmbus_g_connection.monitor_pages - + PAGE_SIZE)); + msg->monitor_page_2 = hv_get_phys_addr( + hv_vmbus_g_connection.monitor_page_2); /** * Add to list before we send the request since we may receive the @@ -168,8 +166,6 @@ hv_vmbus_connect(void) { * Initialize the vmbus connection */ hv_vmbus_g_connection.connect_state = HV_CONNECTING; - hv_vmbus_g_connection.work_queue = hv_work_queue_create("vmbusQ"); - sema_init(&hv_vmbus_g_connection.control_sema, 1, "control_sema"); TAILQ_INIT(&hv_vmbus_g_connection.channel_msg_anchor); mtx_init(&hv_vmbus_g_connection.channel_msg_lock, "vmbus channel msg", @@ -183,18 +179,9 @@ hv_vmbus_connect(void) { * Setup the vmbus event connection for channel interrupt abstraction * stuff */ - hv_vmbus_g_connection.interrupt_page = contigmalloc( + hv_vmbus_g_connection.interrupt_page = malloc( PAGE_SIZE, M_DEVBUF, - M_NOWAIT | M_ZERO, 0UL, - BUS_SPACE_MAXADDR, - PAGE_SIZE, 0); - KASSERT(hv_vmbus_g_connection.interrupt_page != NULL, - ("Error VMBUS: malloc failed to allocate Channel" - " Request Event message!")); - if (hv_vmbus_g_connection.interrupt_page == NULL) { - ret = ENOMEM; - goto cleanup; - } + M_WAITOK | M_ZERO); hv_vmbus_g_connection.recv_interrupt_page = hv_vmbus_g_connection.interrupt_page; @@ -207,31 +194,19 @@ hv_vmbus_connect(void) { * Set up the monitor notification facility. The 1st page for * parent->child and the 2nd page for child->parent */ - hv_vmbus_g_connection.monitor_pages = contigmalloc( - 2 * PAGE_SIZE, + hv_vmbus_g_connection.monitor_page_1 = malloc( + PAGE_SIZE, M_DEVBUF, - M_NOWAIT | M_ZERO, - 0UL, - BUS_SPACE_MAXADDR, + M_WAITOK | M_ZERO); + hv_vmbus_g_connection.monitor_page_2 = malloc( PAGE_SIZE, - 0); - KASSERT(hv_vmbus_g_connection.monitor_pages != NULL, - ("Error VMBUS: malloc failed to allocate Monitor Pages!")); - if (hv_vmbus_g_connection.monitor_pages == NULL) { - ret = ENOMEM; - goto cleanup; - } + M_DEVBUF, + M_WAITOK | M_ZERO); msg_info = (hv_vmbus_channel_msg_info*) malloc(sizeof(hv_vmbus_channel_msg_info) + sizeof(hv_vmbus_channel_initiate_contact), - M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT(msg_info != NULL, - ("Error VMBUS: malloc failed for Initiate Contact message!")); - if (msg_info == NULL) { - ret = ENOMEM; - goto cleanup; - } + M_DEVBUF, M_WAITOK | M_ZERO); hv_vmbus_g_connection.channels = malloc(sizeof(hv_vmbus_channel*) * HV_CHANNEL_MAX_COUNT, @@ -273,8 +248,6 @@ hv_vmbus_connect(void) { hv_vmbus_g_connection.connect_state = HV_DISCONNECTED; - hv_work_queue_close(hv_vmbus_g_connection.work_queue); - sema_destroy(&hv_vmbus_g_connection.control_sema); mtx_destroy(&hv_vmbus_g_connection.channel_lock); mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock); @@ -286,13 +259,8 @@ hv_vmbus_connect(void) { hv_vmbus_g_connection.interrupt_page = NULL; } - if (hv_vmbus_g_connection.monitor_pages != NULL) { - contigfree( - hv_vmbus_g_connection.monitor_pages, - 2 * PAGE_SIZE, - M_DEVBUF); - hv_vmbus_g_connection.monitor_pages = NULL; - } + free(hv_vmbus_g_connection.monitor_page_1, M_DEVBUF); + free(hv_vmbus_g_connection.monitor_page_2, M_DEVBUF); if (msg_info) { sema_destroy(&msg_info->wait_sema); @@ -309,32 +277,19 @@ hv_vmbus_connect(void) { int hv_vmbus_disconnect(void) { int ret = 0; - hv_vmbus_channel_unload* msg; - - msg = malloc(sizeof(hv_vmbus_channel_unload), - M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT(msg != NULL, - ("Error VMBUS: malloc failed to allocate Channel Unload Msg!")); - if (msg == NULL) - return (ENOMEM); + hv_vmbus_channel_unload msg; - msg->message_type = HV_CHANNEL_MESSAGE_UNLOAD; - - ret = hv_vmbus_post_message(msg, sizeof(hv_vmbus_channel_unload)); + msg.message_type = HV_CHANNEL_MESSAGE_UNLOAD; + ret = hv_vmbus_post_message(&msg, sizeof(hv_vmbus_channel_unload)); contigfree(hv_vmbus_g_connection.interrupt_page, PAGE_SIZE, M_DEVBUF); mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock); - hv_work_queue_close(hv_vmbus_g_connection.work_queue); - sema_destroy(&hv_vmbus_g_connection.control_sema); - free(hv_vmbus_g_connection.channels, M_DEVBUF); hv_vmbus_g_connection.connect_state = HV_DISCONNECTED; - free(msg, M_DEVBUF); - return (ret); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_hv.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c Mon Jun 13 06:38:46 2016 (r301859) @@ -189,11 +189,7 @@ hv_vmbus_init(void) * See if the hypercall page is already set */ hypercall_msr.as_uint64_t = rdmsr(HV_X64_MSR_HYPERCALL); - virt_addr = malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT(virt_addr != NULL, - ("Error VMBUS: malloc failed to allocate page during init!")); - if (virt_addr == NULL) - goto cleanup; + virt_addr = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO); hypercall_msr.u.enable = 1; hypercall_msr.u.guest_physical_address = Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Mon Jun 13 06:24:41 2016 (r301858) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Mon Jun 13 06:38:46 2016 (r301859) @@ -83,8 +83,6 @@ vmbus_msg_swintr(void *arg) hv_vmbus_channel_msg_table_entry *entry; hv_vmbus_channel_msg_type msg_type; hv_vmbus_message* msg; - hv_vmbus_message* copied; - static bool warned = false; cpu = (int)(long)arg; KASSERT(cpu <= mp_maxid, ("VMBUS: vmbus_msg_swintr: " @@ -100,31 +98,15 @@ vmbus_msg_swintr(void *arg) hdr = (hv_vmbus_channel_msg_header *)msg->u.payload; msg_type = hdr->message_type; - if (msg_type >= HV_CHANNEL_MESSAGE_COUNT && !warned) { - warned = true; + if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { printf("VMBUS: unknown message type = %d\n", msg_type); goto handled; } entry = &g_channel_message_table[msg_type]; - if (entry->handler_no_sleep) + if (entry->messageHandler) entry->messageHandler(hdr); - else { - - copied = malloc(sizeof(hv_vmbus_message), - M_DEVBUF, M_NOWAIT); - KASSERT(copied != NULL, - ("Error VMBUS: malloc failed to allocate" - " hv_vmbus_message!")); - if (copied == NULL) - continue; - - memcpy(copied, msg, sizeof(hv_vmbus_message)); - hv_queue_work_item(hv_vmbus_g_connection.work_queue, - hv_vmbus_on_channel_message, - copied); - } handled: msg->header.message_type = HV_MESSAGE_TYPE_NONE; @@ -309,12 +291,7 @@ hv_vmbus_child_device_create( * Allocate the new child device */ child_dev = malloc(sizeof(hv_device), M_DEVBUF, - M_NOWAIT | M_ZERO); - KASSERT(child_dev != NULL, - ("Error VMBUS: malloc failed to allocate hv_device!")); - - if (child_dev == NULL) - return (NULL); + M_WAITOK | M_ZERO); child_dev->channel = channel; memcpy(&child_dev->class_id, &type, sizeof(hv_guid)); @@ -585,12 +562,7 @@ vmbus_bus_init(void) */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Mon Jun 13 07:03:01 2016 Return-Path: Delivered-To: svn-src-stable-10@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 8FC9EAF165A; Mon, 13 Jun 2016 07:03:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 51F342CA3; Mon, 13 Jun 2016 07:03:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D730Sq076877; Mon, 13 Jun 2016 07:03:00 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D730pi076875; Mon, 13 Jun 2016 07:03:00 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130703.u5D730pi076875@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 07:03:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301860 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 07:03:01 -0000 Author: sephe Date: Mon Jun 13 07:03:00 2016 New Revision: 301860 URL: https://svnweb.freebsd.org/changeset/base/301860 Log: MFC 295740,295741,295742 295740 hyperv/hn: Set the TCP ACK/data segment aggregation limit Set TCP ACK append limit to 1, i.e. aggregate 2 ACKs at most. Aggregating anything more than 2 hurts TCP sending performance in hyperv. This significantly improves the TCP sending performance when the number of concurrent connetion is low (2~8). And it greatly stabilizes the TCP sending performance in other cases. Set TCP data segments aggregation length limit to 37500. Without this limitation, hn(4) could aggregate ~45 TCP data segments for each connection (even at 64 or more connections) before dispatching them to socket code; large aggregation slows down ACK sending and eventually hurts/destabilizes TCP reception performance. This setting stabilizes and improves TCP reception performance for >4 concurrent connections significantly. Make them sysctls so they could be adjusted. Reviewed by: adrian, gallatin (previous version), hselasky (previous version) Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5185 295741 hyperv/hn: Add option to allow sharing TX taskq between hn instances It is off by default. This eases further experimenting on this driver. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5272 295742 hyperv/hn: Always do transmission scheduling. This one gives the best performance so far. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5273 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 06:38:46 2016 (r301859) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 07:03:00 2016 (r301860) @@ -1031,7 +1031,6 @@ typedef struct hn_softc { struct task hn_txeof_task; struct lro_ctrl hn_lro; - int hn_lro_hiwat; /* Trust csum verification on host side */ int hn_trust_hcsum; /* HN_TRUST_HCSUM_ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 06:38:46 2016 (r301859) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 07:03:00 2016 (r301860) @@ -176,14 +176,11 @@ struct hn_txdesc { #define HN_CSUM_ASSIST_WIN8 (CSUM_TCP) #define HN_CSUM_ASSIST (CSUM_IP | CSUM_UDP | CSUM_TCP) -/* XXX move to netinet/tcp_lro.h */ -#define HN_LRO_HIWAT_MAX 65535 -#define HN_LRO_HIWAT_DEF HN_LRO_HIWAT_MAX +#define HN_LRO_LENLIM_DEF (25 * ETHERMTU) /* YYY 2*MTU is a bit rough, but should be good enough. */ -#define HN_LRO_HIWAT_MTULIM(ifp) (2 * (ifp)->if_mtu) -#define HN_LRO_HIWAT_ISVALID(sc, hiwat) \ - ((hiwat) >= HN_LRO_HIWAT_MTULIM((sc)->hn_ifp) || \ - (hiwat) <= HN_LRO_HIWAT_MAX) +#define HN_LRO_LENLIM_MIN(ifp) (2 * (ifp)->if_mtu) + +#define HN_LRO_ACKCNT_DEF 1 /* * Be aware that this sleepable mutex will exhibit WITNESS errors when @@ -241,6 +238,11 @@ TUNABLE_INT("dev.hn.lro_entry_count", &h #endif #endif +static int hn_share_tx_taskq = 0; +TUNABLE_INT("hw.hn.share_tx_taskq", &hn_share_tx_taskq); + +static struct taskqueue *hn_tx_taskq; + /* * Forward declarations */ @@ -253,8 +255,9 @@ static void hn_start(struct ifnet *ifp); static void hn_start_txeof(struct ifnet *ifp); static int hn_ifmedia_upd(struct ifnet *ifp); static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); -#ifdef HN_LRO_HIWAT -static int hn_lro_hiwat_sysctl(SYSCTL_HANDLER_ARGS); +#if __FreeBSD_version >= 1100099 +static int hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS); #endif static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS); @@ -265,15 +268,6 @@ static void hn_start_taskfunc(void *xsc, static void hn_txeof_taskfunc(void *xsc, int pending); static int hn_encap(struct hn_softc *, struct hn_txdesc *, struct mbuf **); -static __inline void -hn_set_lro_hiwat(struct hn_softc *sc, int hiwat) -{ - sc->hn_lro_hiwat = hiwat; -#ifdef HN_LRO_HIWAT - sc->hn_lro.lro_hiwat = sc->hn_lro_hiwat; -#endif -} - static int hn_ifmedia_upd(struct ifnet *ifp __unused) { @@ -358,7 +352,6 @@ netvsc_attach(device_t dev) bzero(sc, sizeof(hn_softc_t)); sc->hn_unit = unit; sc->hn_dev = dev; - sc->hn_lro_hiwat = HN_LRO_HIWAT_DEF; sc->hn_direct_tx_size = hn_direct_tx_size; if (hn_trust_hosttcp) sc->hn_trust_hcsum |= HN_TRUST_HCSUM_TCP; @@ -367,10 +360,14 @@ netvsc_attach(device_t dev) if (hn_trust_hostip) sc->hn_trust_hcsum |= HN_TRUST_HCSUM_IP; - sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK, - taskqueue_thread_enqueue, &sc->hn_tx_taskq); - taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx", - device_get_nameunit(dev)); + if (hn_tx_taskq == NULL) { + sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_tx_taskq); + taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx", + device_get_nameunit(dev)); + } else { + sc->hn_tx_taskq = hn_tx_taskq; + } TASK_INIT(&sc->hn_start_task, 0, hn_start_taskfunc, sc); TASK_INIT(&sc->hn_txeof_task, 0, hn_txeof_taskfunc, sc); @@ -442,8 +439,9 @@ netvsc_attach(device_t dev) /* Driver private LRO settings */ sc->hn_lro.ifp = ifp; #endif -#ifdef HN_LRO_HIWAT - sc->hn_lro.lro_hiwat = sc->hn_lro_hiwat; +#if __FreeBSD_version >= 1100099 + sc->hn_lro.lro_length_lim = HN_LRO_LENLIM_DEF; + sc->hn_lro.lro_ackcnt_lim = HN_LRO_ACKCNT_DEF; #endif #endif /* INET || INET6 */ @@ -471,6 +469,13 @@ netvsc_attach(device_t dev) hn_tx_chimney_size < sc->hn_tx_chimney_max) sc->hn_tx_chimney_size = hn_tx_chimney_size; + /* + * Always schedule transmission instead of trying + * to do direct transmission. This one gives the + * best performance so far. + */ + sc->hn_sched_tx = 1; + ctx = device_get_sysctl_ctx(dev); child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); @@ -480,10 +485,13 @@ netvsc_attach(device_t dev) CTLFLAG_RW, &sc->hn_lro.lro_flushed, 0, "LRO flushed"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "lro_tried", CTLFLAG_RW, &sc->hn_lro_tried, "# of LRO tries"); -#ifdef HN_LRO_HIWAT - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_hiwat", - CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_lro_hiwat_sysctl, - "I", "LRO high watermark"); +#if __FreeBSD_version >= 1100099 + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_length_lim", + CTLTYPE_UINT | CTLFLAG_RW, sc, 0, hn_lro_lenlim_sysctl, "IU", + "Max # of data bytes to be aggregated by LRO"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_ackcnt_lim", + CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_lro_ackcnt_sysctl, "I", + "Max # of ACKs to be aggregated by LRO"); #endif SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hosttcp", CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_TCP, @@ -616,7 +624,8 @@ netvsc_detach(device_t dev) taskqueue_drain(sc->hn_tx_taskq, &sc->hn_start_task); taskqueue_drain(sc->hn_tx_taskq, &sc->hn_txeof_task); - taskqueue_free(sc->hn_tx_taskq); + if (sc->hn_tx_taskq != hn_tx_taskq) + taskqueue_free(sc->hn_tx_taskq); ifmedia_removeall(&sc->hn_media); #if defined(INET) || defined(INET6) @@ -1412,12 +1421,15 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, /* Obtain and record requested MTU */ ifp->if_mtu = ifr->ifr_mtu; + +#if __FreeBSD_version >= 1100099 /* - * Make sure that LRO high watermark is still valid, - * after MTU change (the 2*MTU limit). + * Make sure that LRO aggregation length limit is still + * valid, after the MTU change. */ - if (!HN_LRO_HIWAT_ISVALID(sc, sc->hn_lro_hiwat)) - hn_set_lro_hiwat(sc, HN_LRO_HIWAT_MTULIM(ifp)); + if (sc->hn_lro.lro_length_lim < HN_LRO_LENLIM_MIN(ifp)) + sc->hn_lro.lro_length_lim = HN_LRO_LENLIM_MIN(ifp); +#endif do { NV_LOCK(sc); @@ -1724,26 +1736,55 @@ hn_watchdog(struct ifnet *ifp) } #endif -#ifdef HN_LRO_HIWAT +#if __FreeBSD_version >= 1100099 + static int -hn_lro_hiwat_sysctl(SYSCTL_HANDLER_ARGS) +hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; - int hiwat, error; + unsigned int lenlim; + int error; - hiwat = sc->hn_lro_hiwat; - error = sysctl_handle_int(oidp, &hiwat, 0, req); + lenlim = sc->hn_lro.lro_length_lim; + error = sysctl_handle_int(oidp, &lenlim, 0, req); if (error || req->newptr == NULL) return error; - if (!HN_LRO_HIWAT_ISVALID(sc, hiwat)) + if (lenlim < HN_LRO_LENLIM_MIN(sc->hn_ifp) || + lenlim > TCP_LRO_LENGTH_MAX) return EINVAL; - if (sc->hn_lro_hiwat != hiwat) - hn_set_lro_hiwat(sc, hiwat); + sc->hn_lro.lro_length_lim = lenlim; return 0; } -#endif /* HN_LRO_HIWAT */ + +static int +hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int ackcnt, error; + + /* + * lro_ackcnt_lim is append count limit, + * +1 to turn it into aggregation limit. + */ + ackcnt = sc->hn_lro.lro_ackcnt_lim + 1; + error = sysctl_handle_int(oidp, &ackcnt, 0, req); + if (error || req->newptr == NULL) + return error; + + if (ackcnt < 2 || ackcnt > (TCP_LRO_ACKCNT_MAX + 1)) + return EINVAL; + + /* + * Convert aggregation limit back to append + * count limit. + */ + sc->hn_lro.lro_ackcnt_lim = ackcnt - 1; + return 0; +} + +#endif static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS) @@ -2029,6 +2070,28 @@ hn_txeof_taskfunc(void *xsc, int pending NV_UNLOCK(sc); } +static void +hn_tx_taskq_create(void *arg __unused) +{ + if (!hn_share_tx_taskq) + return; + + hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK, + taskqueue_thread_enqueue, &hn_tx_taskq); + taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx"); +} +SYSINIT(hn_txtq_create, SI_SUB_DRIVERS, SI_ORDER_FIRST, + hn_tx_taskq_create, NULL); + +static void +hn_tx_taskq_destroy(void *arg __unused) +{ + if (hn_tx_taskq != NULL) + taskqueue_free(hn_tx_taskq); +} +SYSUNINIT(hn_txtq_destroy, SI_SUB_DRIVERS, SI_ORDER_FIRST, + hn_tx_taskq_destroy, NULL); + static device_method_t netvsc_methods[] = { /* Device interface */ DEVMETHOD(device_probe, netvsc_probe), From owner-svn-src-stable-10@freebsd.org Mon Jun 13 07:30:56 2016 Return-Path: Delivered-To: svn-src-stable-10@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 34679AF1B71; Mon, 13 Jun 2016 07:30:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F066F27A5; Mon, 13 Jun 2016 07:30:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D7Ut4w086562; Mon, 13 Jun 2016 07:30:55 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D7Utc6086560; Mon, 13 Jun 2016 07:30:55 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130730.u5D7Utc6086560@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 07:30:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301861 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 07:30:56 -0000 Author: sephe Date: Mon Jun 13 07:30:54 2016 New Revision: 301861 URL: https://svnweb.freebsd.org/changeset/base/301861 Log: MFC 295743,295744,295745,295746,295747 295743 hyperv/hn: Change global tunable prefix to hw.hn And use SYSCTL+CTLFLAG_RDTUN for them. Suggested by: adrian Reviewed by: adrian, Hongjiang Zhang Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5274 295744 hyperv/hn: Split RX ring data structure out of softc This paves the way for upcoming vRSS stuffs and eases more code cleanup. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5275 295745 hyperv/hn: Use taskqueue_enqueue() This also eases experiment on the non-fast taskqueue. Reviewed by: adrian, Jun Su Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5276 295746 hyperv/hn: Use non-fast taskqueue for transmission Performance stays same; so no need to use fast taskqueue here. 295747 hyperv/hn: Split TX ring data structure out of softc This paves the way for upcoming vRSS stuffs and eases more code cleanup. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5283 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 07:03:00 2016 (r301860) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 07:30:54 2016 (r301861) @@ -993,31 +993,25 @@ typedef struct { struct hn_txdesc; SLIST_HEAD(hn_txdesc_list, hn_txdesc); -/* - * Device-specific softc structure - */ -typedef struct hn_softc { - struct ifnet *hn_ifp; - struct arpcom arpcom; - struct ifmedia hn_media; - device_t hn_dev; - uint8_t hn_unit; - int hn_carrier; - int hn_if_flags; - struct mtx hn_lock; - int hn_initdone; - /* See hv_netvsc_drv_freebsd.c for rules on how to use */ - int temp_unusable; - struct hv_device *hn_dev_obj; - netvsc_dev *net_dev; +struct hn_rx_ring { + struct lro_ctrl hn_lro; - struct hn_txdesc *hn_txdesc; - bus_dma_tag_t hn_tx_data_dtag; - bus_dma_tag_t hn_tx_rndis_dtag; - int hn_tx_chimney_size; - int hn_tx_chimney_max; - uint64_t hn_csum_assist; + /* Trust csum verification on host side */ + int hn_trust_hcsum; /* HN_TRUST_HCSUM_ */ + + u_long hn_csum_ip; + u_long hn_csum_tcp; + u_long hn_csum_udp; + u_long hn_csum_trusted; + u_long hn_lro_tried; + u_long hn_small_pkts; +} __aligned(CACHE_LINE_SIZE); + +#define HN_TRUST_HCSUM_IP 0x0001 +#define HN_TRUST_HCSUM_TCP 0x0002 +#define HN_TRUST_HCSUM_UDP 0x0004 +struct hn_tx_ring { struct mtx hn_txlist_spin; struct hn_txdesc_list hn_txlist; int hn_txdesc_cnt; @@ -1025,32 +1019,57 @@ typedef struct hn_softc { int hn_txeof; int hn_sched_tx; - int hn_direct_tx_size; struct taskqueue *hn_tx_taskq; struct task hn_start_task; struct task hn_txeof_task; - struct lro_ctrl hn_lro; + struct mtx hn_tx_lock; + struct hn_softc *hn_sc; - /* Trust csum verification on host side */ - int hn_trust_hcsum; /* HN_TRUST_HCSUM_ */ + int hn_direct_tx_size; + int hn_tx_chimney_size; + bus_dma_tag_t hn_tx_data_dtag; + uint64_t hn_csum_assist; - u_long hn_csum_ip; - u_long hn_csum_tcp; - u_long hn_csum_udp; - u_long hn_csum_trusted; - u_long hn_lro_tried; - u_long hn_small_pkts; u_long hn_no_txdescs; u_long hn_send_failed; u_long hn_txdma_failed; u_long hn_tx_collapsed; u_long hn_tx_chimney; -} hn_softc_t; -#define HN_TRUST_HCSUM_IP 0x0001 -#define HN_TRUST_HCSUM_TCP 0x0002 -#define HN_TRUST_HCSUM_UDP 0x0004 + /* Rarely used stuffs */ + struct hn_txdesc *hn_txdesc; + bus_dma_tag_t hn_tx_rndis_dtag; + struct sysctl_oid *hn_tx_sysctl_tree; +} __aligned(CACHE_LINE_SIZE); + +/* + * Device-specific softc structure + */ +typedef struct hn_softc { + struct ifnet *hn_ifp; + struct arpcom arpcom; + struct ifmedia hn_media; + device_t hn_dev; + uint8_t hn_unit; + int hn_carrier; + int hn_if_flags; + struct mtx hn_lock; + int hn_initdone; + /* See hv_netvsc_drv_freebsd.c for rules on how to use */ + int temp_unusable; + struct hv_device *hn_dev_obj; + netvsc_dev *net_dev; + + int hn_rx_ring_cnt; + struct hn_rx_ring *hn_rx_ring; + + int hn_tx_ring_cnt; + struct hn_tx_ring *hn_tx_ring; + int hn_tx_chimney_max; + struct taskqueue *hn_tx_taskq; + struct sysctl_oid *hn_tx_sysctl_tree; +} hn_softc_t; /* * Externs Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 07:03:00 2016 (r301860) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 07:30:54 2016 (r301861) @@ -153,7 +153,7 @@ __FBSDID("$FreeBSD$"); struct hn_txdesc { SLIST_ENTRY(hn_txdesc) link; struct mbuf *m; - struct hn_softc *sc; + struct hn_tx_ring *txr; int refs; uint32_t flags; /* HN_TXD_FLAG_ */ netvsc_packet netvsc_pkt; /* XXX to be removed */ @@ -193,7 +193,6 @@ struct hn_txdesc { #define NV_LOCK_INIT(_sc, _name) \ mtx_init(&(_sc)->hn_lock, _name, MTX_NETWORK_LOCK, MTX_DEF) #define NV_LOCK(_sc) mtx_lock(&(_sc)->hn_lock) -#define NV_TRYLOCK(_sc) mtx_trylock(&(_sc)->hn_lock) #define NV_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->hn_lock, MA_OWNED) #define NV_UNLOCK(_sc) mtx_unlock(&(_sc)->hn_lock) #define NV_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->hn_lock) @@ -205,41 +204,57 @@ struct hn_txdesc { int hv_promisc_mode = 0; /* normal mode by default */ +SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD, NULL, "Hyper-V network interface"); + /* Trust tcp segements verification on host side. */ static int hn_trust_hosttcp = 1; -TUNABLE_INT("dev.hn.trust_hosttcp", &hn_trust_hosttcp); +SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosttcp, CTLFLAG_RDTUN, + &hn_trust_hosttcp, 0, + "Trust tcp segement verification on host side, " + "when csum info is missing (global setting)"); /* Trust udp datagrams verification on host side. */ static int hn_trust_hostudp = 1; -TUNABLE_INT("dev.hn.trust_hostudp", &hn_trust_hostudp); +SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostudp, CTLFLAG_RDTUN, + &hn_trust_hostudp, 0, + "Trust udp datagram verification on host side, " + "when csum info is missing (global setting)"); /* Trust ip packets verification on host side. */ static int hn_trust_hostip = 1; -TUNABLE_INT("dev.hn.trust_hostip", &hn_trust_hostip); +SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostip, CTLFLAG_RDTUN, + &hn_trust_hostip, 0, + "Trust ip packet verification on host side, " + "when csum info is missing (global setting)"); #if __FreeBSD_version >= 1100045 /* Limit TSO burst size */ static int hn_tso_maxlen = 0; -TUNABLE_INT("dev.hn.tso_maxlen", &hn_tso_maxlen); +SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, + &hn_tso_maxlen, 0, "TSO burst limit"); #endif /* Limit chimney send size */ static int hn_tx_chimney_size = 0; -TUNABLE_INT("dev.hn.tx_chimney_size", &hn_tx_chimney_size); +SYSCTL_INT(_hw_hn, OID_AUTO, tx_chimney_size, CTLFLAG_RDTUN, + &hn_tx_chimney_size, 0, "Chimney send packet size limit"); /* Limit the size of packet for direct transmission */ static int hn_direct_tx_size = HN_DIRECT_TX_SIZE_DEF; -TUNABLE_INT("dev.hn.direct_tx_size", &hn_direct_tx_size); +SYSCTL_INT(_hw_hn, OID_AUTO, direct_tx_size, CTLFLAG_RDTUN, + &hn_direct_tx_size, 0, "Size of the packet for direct transmission"); #if defined(INET) || defined(INET6) #if __FreeBSD_version >= 1100095 static int hn_lro_entry_count = HN_LROENT_CNT_DEF; -TUNABLE_INT("dev.hn.lro_entry_count", &hn_lro_entry_count); +SYSCTL_INT(_hw_hn, OID_AUTO, lro_entry_count, CTLFLAG_RDTUN, + &hn_lro_entry_count, 0, "LRO entry count"); #endif #endif static int hn_share_tx_taskq = 0; -TUNABLE_INT("hw.hn.share_tx_taskq", &hn_share_tx_taskq); +SYSCTL_INT(_hw_hn, OID_AUTO, share_tx_taskq, CTLFLAG_RDTUN, + &hn_share_tx_taskq, 0, "Enable shared TX taskqueue"); static struct taskqueue *hn_tx_taskq; @@ -250,9 +265,9 @@ static void hn_stop(hn_softc_t *sc); static void hn_ifinit_locked(hn_softc_t *sc); static void hn_ifinit(void *xsc); static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); -static int hn_start_locked(struct ifnet *ifp, int len); +static int hn_start_locked(struct hn_tx_ring *txr, int len); static void hn_start(struct ifnet *ifp); -static void hn_start_txeof(struct ifnet *ifp); +static void hn_start_txeof(struct hn_tx_ring *); static int hn_ifmedia_upd(struct ifnet *ifp); static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); #if __FreeBSD_version >= 1100099 @@ -261,12 +276,22 @@ static int hn_lro_ackcnt_sysctl(SYSCTL_H #endif static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); -static int hn_create_tx_ring(struct hn_softc *sc); -static void hn_destroy_tx_ring(struct hn_softc *sc); +static int hn_create_tx_ring(struct hn_softc *, int); +static void hn_destroy_tx_ring(struct hn_tx_ring *); +static int hn_create_tx_data(struct hn_softc *); +static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *xsc, int pending); static void hn_txeof_taskfunc(void *xsc, int pending); -static int hn_encap(struct hn_softc *, struct hn_txdesc *, struct mbuf **); +static void hn_stop_tx_tasks(struct hn_softc *); +static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); +static void hn_create_rx_data(struct hn_softc *sc); +static void hn_destroy_rx_data(struct hn_softc *sc); +static void hn_set_tx_chimney_size(struct hn_softc *, int); static int hn_ifmedia_upd(struct ifnet *ifp __unused) @@ -332,17 +357,10 @@ netvsc_attach(device_t dev) hn_softc_t *sc; int unit = device_get_unit(dev); struct ifnet *ifp = NULL; - struct sysctl_oid_list *child; - struct sysctl_ctx_list *ctx; int error; #if __FreeBSD_version >= 1100045 int tso_maxlen; #endif -#if defined(INET) || defined(INET6) -#if __FreeBSD_version >= 1100095 - int lroent_cnt; -#endif -#endif sc = device_get_softc(dev); if (sc == NULL) { @@ -352,29 +370,15 @@ netvsc_attach(device_t dev) bzero(sc, sizeof(hn_softc_t)); sc->hn_unit = unit; sc->hn_dev = dev; - sc->hn_direct_tx_size = hn_direct_tx_size; - if (hn_trust_hosttcp) - sc->hn_trust_hcsum |= HN_TRUST_HCSUM_TCP; - if (hn_trust_hostudp) - sc->hn_trust_hcsum |= HN_TRUST_HCSUM_UDP; - if (hn_trust_hostip) - sc->hn_trust_hcsum |= HN_TRUST_HCSUM_IP; if (hn_tx_taskq == NULL) { - sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK, + sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, taskqueue_thread_enqueue, &sc->hn_tx_taskq); taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx", device_get_nameunit(dev)); } else { sc->hn_tx_taskq = hn_tx_taskq; } - TASK_INIT(&sc->hn_start_task, 0, hn_start_taskfunc, sc); - TASK_INIT(&sc->hn_txeof_task, 0, hn_txeof_taskfunc, sc); - - error = hn_create_tx_ring(sc); - if (error) - goto failed; - NV_LOCK_INIT(sc, "NetVSCLock"); sc->hn_dev_obj = device_ctx; @@ -382,6 +386,12 @@ netvsc_attach(device_t dev) ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; + error = hn_create_tx_data(sc); + if (error) + goto failed; + + hn_create_rx_data(sc); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_dunit = unit; ifp->if_dname = NETVSC_DEVNAME; @@ -412,12 +422,7 @@ netvsc_attach(device_t dev) ifp->if_capenable |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO; - - if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1) - sc->hn_csum_assist = HN_CSUM_ASSIST; - else - sc->hn_csum_assist = HN_CSUM_ASSIST_WIN8; - ifp->if_hwassist = sc->hn_csum_assist | CSUM_TSO; + ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; error = hv_rf_on_device_add(device_ctx, &device_info); if (error) @@ -427,24 +432,6 @@ netvsc_attach(device_t dev) sc->hn_carrier = 1; } -#if defined(INET) || defined(INET6) -#if __FreeBSD_version >= 1100095 - lroent_cnt = hn_lro_entry_count; - if (lroent_cnt < TCP_LRO_ENTRIES) - lroent_cnt = TCP_LRO_ENTRIES; - tcp_lro_init_args(&sc->hn_lro, ifp, lroent_cnt, 0); - device_printf(dev, "LRO: entry count %d\n", lroent_cnt); -#else - tcp_lro_init(&sc->hn_lro); - /* Driver private LRO settings */ - sc->hn_lro.ifp = ifp; -#endif -#if __FreeBSD_version >= 1100099 - sc->hn_lro.lro_length_lim = HN_LRO_LENLIM_DEF; - sc->hn_lro.lro_ackcnt_lim = HN_LRO_ACKCNT_DEF; -#endif -#endif /* INET || INET6 */ - #if __FreeBSD_version >= 1100045 tso_maxlen = hn_tso_maxlen; if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) @@ -464,134 +451,14 @@ netvsc_attach(device_t dev) #endif sc->hn_tx_chimney_max = sc->net_dev->send_section_size; - sc->hn_tx_chimney_size = sc->hn_tx_chimney_max; + hn_set_tx_chimney_size(sc, sc->hn_tx_chimney_max); if (hn_tx_chimney_size > 0 && hn_tx_chimney_size < sc->hn_tx_chimney_max) - sc->hn_tx_chimney_size = hn_tx_chimney_size; - - /* - * Always schedule transmission instead of trying - * to do direct transmission. This one gives the - * best performance so far. - */ - sc->hn_sched_tx = 1; - - ctx = device_get_sysctl_ctx(dev); - child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); - - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "lro_queued", - CTLFLAG_RW, &sc->hn_lro.lro_queued, 0, "LRO queued"); - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "lro_flushed", - CTLFLAG_RW, &sc->hn_lro.lro_flushed, 0, "LRO flushed"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "lro_tried", - CTLFLAG_RW, &sc->hn_lro_tried, "# of LRO tries"); -#if __FreeBSD_version >= 1100099 - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_length_lim", - CTLTYPE_UINT | CTLFLAG_RW, sc, 0, hn_lro_lenlim_sysctl, "IU", - "Max # of data bytes to be aggregated by LRO"); - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_ackcnt_lim", - CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_lro_ackcnt_sysctl, "I", - "Max # of ACKs to be aggregated by LRO"); -#endif - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hosttcp", - CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_TCP, - hn_trust_hcsum_sysctl, "I", - "Trust tcp segement verification on host side, " - "when csum info is missing"); - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hostudp", - CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_UDP, - hn_trust_hcsum_sysctl, "I", - "Trust udp datagram verification on host side, " - "when csum info is missing"); - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hostip", - CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_IP, - hn_trust_hcsum_sysctl, "I", - "Trust ip packet verification on host side, " - "when csum info is missing"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_ip", - CTLFLAG_RW, &sc->hn_csum_ip, "RXCSUM IP"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_tcp", - CTLFLAG_RW, &sc->hn_csum_tcp, "RXCSUM TCP"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_udp", - CTLFLAG_RW, &sc->hn_csum_udp, "RXCSUM UDP"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_trusted", - CTLFLAG_RW, &sc->hn_csum_trusted, - "# of packets that we trust host's csum verification"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "small_pkts", - CTLFLAG_RW, &sc->hn_small_pkts, "# of small packets received"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "no_txdescs", - CTLFLAG_RW, &sc->hn_no_txdescs, "# of times short of TX descs"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "send_failed", - CTLFLAG_RW, &sc->hn_send_failed, "# of hyper-v sending failure"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "txdma_failed", - CTLFLAG_RW, &sc->hn_txdma_failed, "# of TX DMA failure"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "tx_collapsed", - CTLFLAG_RW, &sc->hn_tx_collapsed, "# of TX mbuf collapsed"); - SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "tx_chimney", - CTLFLAG_RW, &sc->hn_tx_chimney, "# of chimney send"); - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "txdesc_cnt", - CTLFLAG_RD, &sc->hn_txdesc_cnt, 0, "# of total TX descs"); - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "txdesc_avail", - CTLFLAG_RD, &sc->hn_txdesc_avail, 0, "# of available TX descs"); - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "tx_chimney_max", - CTLFLAG_RD, &sc->hn_tx_chimney_max, 0, - "Chimney send packet size upper boundary"); - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "tx_chimney_size", - CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_tx_chimney_size_sysctl, - "I", "Chimney send packet size limit"); - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "direct_tx_size", - CTLFLAG_RW, &sc->hn_direct_tx_size, 0, - "Size of the packet for direct transmission"); - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sched_tx", - CTLFLAG_RW, &sc->hn_sched_tx, 0, - "Always schedule transmission " - "instead of doing direct transmission"); - - if (unit == 0) { - struct sysctl_ctx_list *dc_ctx; - struct sysctl_oid_list *dc_child; - devclass_t dc; - - /* - * Add sysctl nodes for devclass - */ - dc = device_get_devclass(dev); - dc_ctx = devclass_get_sysctl_ctx(dc); - dc_child = SYSCTL_CHILDREN(devclass_get_sysctl_tree(dc)); - - SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hosttcp", - CTLFLAG_RD, &hn_trust_hosttcp, 0, - "Trust tcp segement verification on host side, " - "when csum info is missing (global setting)"); - SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hostudp", - CTLFLAG_RD, &hn_trust_hostudp, 0, - "Trust udp datagram verification on host side, " - "when csum info is missing (global setting)"); - SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hostip", - CTLFLAG_RD, &hn_trust_hostip, 0, - "Trust ip packet verification on host side, " - "when csum info is missing (global setting)"); - SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "tx_chimney_size", - CTLFLAG_RD, &hn_tx_chimney_size, 0, - "Chimney send packet size limit"); -#if __FreeBSD_version >= 1100045 - SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "tso_maxlen", - CTLFLAG_RD, &hn_tso_maxlen, 0, "TSO burst limit"); -#endif - SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "direct_tx_size", - CTLFLAG_RD, &hn_direct_tx_size, 0, - "Size of the packet for direct transmission"); -#if defined(INET) || defined(INET6) -#if __FreeBSD_version >= 1100095 - SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "lro_entry_count", - CTLFLAG_RD, &hn_lro_entry_count, 0, "LRO entry count"); -#endif -#endif - } + hn_set_tx_chimney_size(sc, hn_tx_chimney_size); return (0); failed: - hn_destroy_tx_ring(sc); + hn_destroy_tx_data(sc); if (ifp != NULL) if_free(ifp); return (error); @@ -622,16 +489,14 @@ netvsc_detach(device_t dev) hv_rf_on_device_remove(hv_device, HV_RF_NV_DESTROY_CHANNEL); - taskqueue_drain(sc->hn_tx_taskq, &sc->hn_start_task); - taskqueue_drain(sc->hn_tx_taskq, &sc->hn_txeof_task); - if (sc->hn_tx_taskq != hn_tx_taskq) - taskqueue_free(sc->hn_tx_taskq); + hn_stop_tx_tasks(sc); ifmedia_removeall(&sc->hn_media); -#if defined(INET) || defined(INET6) - tcp_lro_free(&sc->hn_lro); -#endif - hn_destroy_tx_ring(sc); + hn_destroy_rx_data(sc); + hn_destroy_tx_data(sc); + + if (sc->hn_tx_taskq != hn_tx_taskq) + taskqueue_free(sc->hn_tx_taskq); return (0); } @@ -646,13 +511,13 @@ netvsc_shutdown(device_t dev) } static __inline int -hn_txdesc_dmamap_load(struct hn_softc *sc, struct hn_txdesc *txd, +hn_txdesc_dmamap_load(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head, bus_dma_segment_t *segs, int *nsegs) { struct mbuf *m = *m_head; int error; - error = bus_dmamap_load_mbuf_sg(sc->hn_tx_data_dtag, txd->data_dmap, + error = bus_dmamap_load_mbuf_sg(txr->hn_tx_data_dtag, txd->data_dmap, m, segs, nsegs, BUS_DMA_NOWAIT); if (error == EFBIG) { struct mbuf *m_new; @@ -662,13 +527,13 @@ hn_txdesc_dmamap_load(struct hn_softc *s return ENOBUFS; else *m_head = m = m_new; - sc->hn_tx_collapsed++; + txr->hn_tx_collapsed++; - error = bus_dmamap_load_mbuf_sg(sc->hn_tx_data_dtag, + error = bus_dmamap_load_mbuf_sg(txr->hn_tx_data_dtag, txd->data_dmap, m, segs, nsegs, BUS_DMA_NOWAIT); } if (!error) { - bus_dmamap_sync(sc->hn_tx_data_dtag, txd->data_dmap, + bus_dmamap_sync(txr->hn_tx_data_dtag, txd->data_dmap, BUS_DMASYNC_PREWRITE); txd->flags |= HN_TXD_FLAG_DMAMAP; } @@ -676,20 +541,20 @@ hn_txdesc_dmamap_load(struct hn_softc *s } static __inline void -hn_txdesc_dmamap_unload(struct hn_softc *sc, struct hn_txdesc *txd) +hn_txdesc_dmamap_unload(struct hn_tx_ring *txr, struct hn_txdesc *txd) { if (txd->flags & HN_TXD_FLAG_DMAMAP) { - bus_dmamap_sync(sc->hn_tx_data_dtag, + bus_dmamap_sync(txr->hn_tx_data_dtag, txd->data_dmap, BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(sc->hn_tx_data_dtag, + bus_dmamap_unload(txr->hn_tx_data_dtag, txd->data_dmap); txd->flags &= ~HN_TXD_FLAG_DMAMAP; } } static __inline int -hn_txdesc_put(struct hn_softc *sc, struct hn_txdesc *txd) +hn_txdesc_put(struct hn_tx_ring *txr, struct hn_txdesc *txd) { KASSERT((txd->flags & HN_TXD_FLAG_ONLIST) == 0, @@ -699,7 +564,7 @@ hn_txdesc_put(struct hn_softc *sc, struc if (atomic_fetchadd_int(&txd->refs, -1) != 1) return 0; - hn_txdesc_dmamap_unload(sc, txd); + hn_txdesc_dmamap_unload(txr, txd); if (txd->m != NULL) { m_freem(txd->m); txd->m = NULL; @@ -707,31 +572,31 @@ hn_txdesc_put(struct hn_softc *sc, struc txd->flags |= HN_TXD_FLAG_ONLIST; - mtx_lock_spin(&sc->hn_txlist_spin); - KASSERT(sc->hn_txdesc_avail >= 0 && - sc->hn_txdesc_avail < sc->hn_txdesc_cnt, - ("txdesc_put: invalid txd avail %d", sc->hn_txdesc_avail)); - sc->hn_txdesc_avail++; - SLIST_INSERT_HEAD(&sc->hn_txlist, txd, link); - mtx_unlock_spin(&sc->hn_txlist_spin); + mtx_lock_spin(&txr->hn_txlist_spin); + KASSERT(txr->hn_txdesc_avail >= 0 && + txr->hn_txdesc_avail < txr->hn_txdesc_cnt, + ("txdesc_put: invalid txd avail %d", txr->hn_txdesc_avail)); + txr->hn_txdesc_avail++; + SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link); + mtx_unlock_spin(&txr->hn_txlist_spin); return 1; } static __inline struct hn_txdesc * -hn_txdesc_get(struct hn_softc *sc) +hn_txdesc_get(struct hn_tx_ring *txr) { struct hn_txdesc *txd; - mtx_lock_spin(&sc->hn_txlist_spin); - txd = SLIST_FIRST(&sc->hn_txlist); + mtx_lock_spin(&txr->hn_txlist_spin); + txd = SLIST_FIRST(&txr->hn_txlist); if (txd != NULL) { - KASSERT(sc->hn_txdesc_avail > 0, - ("txdesc_get: invalid txd avail %d", sc->hn_txdesc_avail)); - sc->hn_txdesc_avail--; - SLIST_REMOVE_HEAD(&sc->hn_txlist, link); + KASSERT(txr->hn_txdesc_avail > 0, + ("txdesc_get: invalid txd avail %d", txr->hn_txdesc_avail)); + txr->hn_txdesc_avail--; + SLIST_REMOVE_HEAD(&txr->hn_txlist, link); } - mtx_unlock_spin(&sc->hn_txlist_spin); + mtx_unlock_spin(&txr->hn_txlist_spin); if (txd != NULL) { KASSERT(txd->m == NULL && txd->refs == 0 && @@ -763,22 +628,24 @@ netvsc_xmit_completion(void *context) { netvsc_packet *packet = context; struct hn_txdesc *txd; - struct hn_softc *sc; + struct hn_tx_ring *txr; txd = (struct hn_txdesc *)(uintptr_t) packet->compl.send.send_completion_tid; - sc = txd->sc; - sc->hn_txeof = 1; - hn_txdesc_put(sc, txd); + txr = txd->txr; + txr->hn_txeof = 1; + hn_txdesc_put(txr, txd); } void netvsc_channel_rollup(struct hv_device *device_ctx) { struct hn_softc *sc = device_get_softc(device_ctx->device); + struct hn_tx_ring *txr = &sc->hn_tx_ring[0]; /* TODO: vRSS */ #if defined(INET) || defined(INET6) - struct lro_ctrl *lro = &sc->hn_lro; + struct hn_rx_ring *rxr = &sc->hn_rx_ring[0]; /* TODO: vRSS */ + struct lro_ctrl *lro = &rxr->hn_lro; struct lro_entry *queued; while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { @@ -787,11 +654,11 @@ netvsc_channel_rollup(struct hv_device * } #endif - if (!sc->hn_txeof) + if (!txr->hn_txeof) return; - sc->hn_txeof = 0; - hn_start_txeof(sc->hn_ifp); + txr->hn_txeof = 0; + hn_start_txeof(txr); } /* @@ -799,7 +666,7 @@ netvsc_channel_rollup(struct hv_device * * If this function fails, then both txd and m_head0 will be freed. */ static int -hn_encap(struct hn_softc *sc, struct hn_txdesc *txd, struct mbuf **m_head0) +hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0) { bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; int error, nsegs, i; @@ -902,7 +769,7 @@ hn_encap(struct hn_softc *sc, struct hn_ #endif tso_info->lso_v2_xmit.tcp_header_offset = 0; tso_info->lso_v2_xmit.mss = m_head->m_pkthdr.tso_segsz; - } else if (m_head->m_pkthdr.csum_flags & sc->hn_csum_assist) { + } else if (m_head->m_pkthdr.csum_flags & txr->hn_csum_assist) { rndis_tcp_ip_csum_info *csum_info; rndis_msg_size += RNDIS_CSUM_PPI_SIZE; @@ -929,8 +796,8 @@ hn_encap(struct hn_softc *sc, struct hn_ /* * Chimney send, if the packet could fit into one chimney buffer. */ - if (packet->tot_data_buf_len < sc->hn_tx_chimney_size) { - netvsc_dev *net_dev = sc->net_dev; + if (packet->tot_data_buf_len < txr->hn_tx_chimney_size) { + netvsc_dev *net_dev = txr->hn_sc->net_dev; uint32_t send_buf_section_idx; send_buf_section_idx = @@ -949,12 +816,12 @@ hn_encap(struct hn_softc *sc, struct hn_ packet->send_buf_section_size = packet->tot_data_buf_len; packet->page_buf_count = 0; - sc->hn_tx_chimney++; + txr->hn_tx_chimney++; goto done; } } - error = hn_txdesc_dmamap_load(sc, txd, &m_head, segs, &nsegs); + error = hn_txdesc_dmamap_load(txr, txd, &m_head, segs, &nsegs); if (error) { int freed; @@ -964,12 +831,12 @@ hn_encap(struct hn_softc *sc, struct hn_ m_freem(m_head); *m_head0 = NULL; - freed = hn_txdesc_put(sc, txd); + freed = hn_txdesc_put(txr, txd); KASSERT(freed != 0, ("fail to free txd upon txdma error")); - sc->hn_txdma_failed++; - if_inc_counter(sc->hn_ifp, IFCOUNTER_OERRORS, 1); + txr->hn_txdma_failed++; + if_inc_counter(txr->hn_sc->hn_ifp, IFCOUNTER_OERRORS, 1); return error; } *m_head0 = m_head; @@ -1012,11 +879,15 @@ done: * Start a transmit of one or more packets */ static int -hn_start_locked(struct ifnet *ifp, int len) +hn_start_locked(struct hn_tx_ring *txr, int len) { - struct hn_softc *sc = ifp->if_softc; + struct hn_softc *sc = txr->hn_sc; + struct ifnet *ifp = sc->hn_ifp; struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); + KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); + mtx_assert(&txr->hn_tx_lock, MA_OWNED); + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return 0; @@ -1040,15 +911,15 @@ hn_start_locked(struct ifnet *ifp, int l return 1; } - txd = hn_txdesc_get(sc); + txd = hn_txdesc_get(txr); if (txd == NULL) { - sc->hn_no_txdescs++; + txr->hn_no_txdescs++; IF_PREPEND(&ifp->if_snd, m_head); atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); break; } - error = hn_encap(sc, txd, &m_head); + error = hn_encap(txr, txd, &m_head); if (error) { /* Both txd and m_head are freed */ continue; @@ -1063,7 +934,7 @@ again: ETHER_BPF_MTAP(ifp, m_head); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } - hn_txdesc_put(sc, txd); + hn_txdesc_put(txr, txd); if (__predict_false(error)) { int freed; @@ -1075,9 +946,9 @@ again: * commands to run? Ask netvsc_channel_rollup() * to kick start later. */ - sc->hn_txeof = 1; + txr->hn_txeof = 1; if (!send_failed) { - sc->hn_send_failed++; + txr->hn_send_failed++; send_failed = 1; /* * Try sending again after set hn_txeof; @@ -1094,11 +965,11 @@ again: * DMA map in hn_txdesc_put(), if it was loaded. */ txd->m = NULL; - freed = hn_txdesc_put(sc, txd); + freed = hn_txdesc_put(txr, txd); KASSERT(freed != 0, ("fail to free txd upon send error")); - sc->hn_send_failed++; + txr->hn_send_failed++; IF_PREPEND(&ifp->if_snd, m_head); atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); break; @@ -1194,10 +1065,10 @@ int netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet, rndis_tcp_ip_csum_info *csum_info) { - hn_softc_t *sc = (hn_softc_t *)device_get_softc(device_ctx->device); + struct hn_softc *sc = device_get_softc(device_ctx->device); + struct hn_rx_ring *rxr = &sc->hn_rx_ring[0]; /* TODO: vRSS */ struct mbuf *m_new; struct ifnet *ifp; - device_t dev = device_ctx->device; int size, do_lro = 0, do_csum = 1; if (sc == NULL) { @@ -1224,7 +1095,7 @@ netvsc_recv(struct hv_device *device_ctx memcpy(mtod(m_new, void *), packet->data, packet->tot_data_buf_len); m_new->m_pkthdr.len = m_new->m_len = packet->tot_data_buf_len; - sc->hn_small_pkts++; + rxr->hn_small_pkts++; } else { /* * Get an mbuf with a cluster. For packets 2K or less, @@ -1240,7 +1111,7 @@ netvsc_recv(struct hv_device *device_ctx m_new = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, size); if (m_new == NULL) { - device_printf(dev, "alloc mbuf failed.\n"); + if_printf(ifp, "alloc mbuf failed.\n"); return (0); } @@ -1257,7 +1128,7 @@ netvsc_recv(struct hv_device *device_ctx if (csum_info->receive.ip_csum_succeeded && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); - sc->hn_csum_ip++; + rxr->hn_csum_ip++; } /* TCP/UDP csum offload */ @@ -1267,9 +1138,9 @@ netvsc_recv(struct hv_device *device_ctx (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; if (csum_info->receive.tcp_csum_succeeded) - sc->hn_csum_tcp++; + rxr->hn_csum_tcp++; else - sc->hn_csum_udp++; + rxr->hn_csum_udp++; } if (csum_info->receive.ip_csum_succeeded && @@ -1301,8 +1172,9 @@ netvsc_recv(struct hv_device *device_ctx pr = hn_check_iplen(m_new, hoff); if (pr == IPPROTO_TCP) { if (do_csum && - (sc->hn_trust_hcsum & HN_TRUST_HCSUM_TCP)) { - sc->hn_csum_trusted++; + (rxr->hn_trust_hcsum & + HN_TRUST_HCSUM_TCP)) { + rxr->hn_csum_trusted++; m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR); @@ -1312,16 +1184,17 @@ netvsc_recv(struct hv_device *device_ctx do_lro = 1; } else if (pr == IPPROTO_UDP) { if (do_csum && - (sc->hn_trust_hcsum & HN_TRUST_HCSUM_UDP)) { - sc->hn_csum_trusted++; + (rxr->hn_trust_hcsum & + HN_TRUST_HCSUM_UDP)) { + rxr->hn_csum_trusted++; m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; } } else if (pr != IPPROTO_DONE && do_csum && - (sc->hn_trust_hcsum & HN_TRUST_HCSUM_IP)) { - sc->hn_csum_trusted++; + (rxr->hn_trust_hcsum & HN_TRUST_HCSUM_IP)) { + rxr->hn_csum_trusted++; m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); } @@ -1343,10 +1216,10 @@ skip: if ((ifp->if_capenable & IFCAP_LRO) && do_lro) { #if defined(INET) || defined(INET6) - struct lro_ctrl *lro = &sc->hn_lro; + struct lro_ctrl *lro = &rxr->hn_lro; if (lro->lro_cnt) { - sc->hn_lro_tried++; + rxr->hn_lro_tried++; if (tcp_lro_rx(lro, m_new, 0) == 0) { /* DONE! */ return 0; @@ -1427,8 +1300,16 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, * Make sure that LRO aggregation length limit is still * valid, after the MTU change. */ - if (sc->hn_lro.lro_length_lim < HN_LRO_LENLIM_MIN(ifp)) - sc->hn_lro.lro_length_lim = HN_LRO_LENLIM_MIN(ifp); + NV_LOCK(sc); + if (sc->hn_rx_ring[0].hn_lro.lro_length_lim < + HN_LRO_LENLIM_MIN(ifp)) { + int i; + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + sc->hn_rx_ring[i].hn_lro.lro_length_lim = + HN_LRO_LENLIM_MIN(ifp); + } + } + NV_UNLOCK(sc); #endif do { @@ -1469,8 +1350,10 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, } sc->hn_tx_chimney_max = sc->net_dev->send_section_size; - if (sc->hn_tx_chimney_size > sc->hn_tx_chimney_max) - sc->hn_tx_chimney_size = sc->hn_tx_chimney_max; + if (sc->hn_tx_ring[0].hn_tx_chimney_size > + sc->hn_tx_chimney_max) + hn_set_tx_chimney_size(sc, sc->hn_tx_chimney_max); + hn_ifinit_locked(sc); NV_LOCK(sc); @@ -1535,10 +1418,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, mask = ifr->ifr_reqcap ^ ifp->if_capenable; if (mask & IFCAP_TXCSUM) { ifp->if_capenable ^= IFCAP_TXCSUM; - if (ifp->if_capenable & IFCAP_TXCSUM) - ifp->if_hwassist |= sc->hn_csum_assist; - else - ifp->if_hwassist &= ~sc->hn_csum_assist; + if (ifp->if_capenable & IFCAP_TXCSUM) { + ifp->if_hwassist |= + sc->hn_tx_ring[0].hn_csum_assist; + } else { + ifp->if_hwassist &= + ~sc->hn_tx_ring[0].hn_csum_assist; + } } if (mask & IFCAP_RXCSUM) @@ -1621,50 +1507,54 @@ static void hn_start(struct ifnet *ifp) { struct hn_softc *sc = ifp->if_softc; + struct hn_tx_ring *txr = &sc->hn_tx_ring[0]; - if (sc->hn_sched_tx) + if (txr->hn_sched_tx) goto do_sched; - if (NV_TRYLOCK(sc)) { + if (mtx_trylock(&txr->hn_tx_lock)) { int sched; - sched = hn_start_locked(ifp, sc->hn_direct_tx_size); - NV_UNLOCK(sc); + sched = hn_start_locked(txr, txr->hn_direct_tx_size); + mtx_unlock(&txr->hn_tx_lock); if (!sched) return; } do_sched: - taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_start_task); + taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_start_task); } static void -hn_start_txeof(struct ifnet *ifp) +hn_start_txeof(struct hn_tx_ring *txr) { - struct hn_softc *sc = ifp->if_softc; + struct hn_softc *sc = txr->hn_sc; + struct ifnet *ifp = sc->hn_ifp; - if (sc->hn_sched_tx) + KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); + + if (txr->hn_sched_tx) goto do_sched; - if (NV_TRYLOCK(sc)) { + if (mtx_trylock(&txr->hn_tx_lock)) { int sched; atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); - sched = hn_start_locked(ifp, sc->hn_direct_tx_size); - NV_UNLOCK(sc); + sched = hn_start_locked(txr, txr->hn_direct_tx_size); + mtx_unlock(&txr->hn_tx_lock); if (sched) { - taskqueue_enqueue_fast(sc->hn_tx_taskq, - &sc->hn_start_task); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Mon Jun 13 08:03:54 2016 Return-Path: Delivered-To: svn-src-stable-10@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 D4031AF153B; Mon, 13 Jun 2016 08:03:54 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 96CA62804; Mon, 13 Jun 2016 08:03:54 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D83rCA099038; Mon, 13 Jun 2016 08:03:53 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D83rBm099036; Mon, 13 Jun 2016 08:03:53 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130803.u5D83rBm099036@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 08:03:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301862 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 08:03:54 -0000 Author: sephe Date: Mon Jun 13 08:03:53 2016 New Revision: 301862 URL: https://svnweb.freebsd.org/changeset/base/301862 Log: MFC 295748,295792,295793,295794 295748 hyperv/hn: Use buf_ring for txdesc list So one spinlock is avoided, which would be potentially dangerous for virtual machine, if the spinlock holder was scheduled out by the host, as noted by royger. Old spinlock based txdesc list is still kept around, so we could have a safe fallback. No performance regression nor improvement is observed. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5290 295792 hyperv/hn: Add option to bind TX taskqueues to the specified CPU It will be used to help tracking host side transmission ring selection issue; and it will be turned on by default, once we have concrete result. Reviewed by: adrian, Jun Su Approved by: adrian (mento) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5316 295793 hyperv/hn: Enable IP header checksum offloading for WIN8 (WinServ2012) Tested on Windows Server 2012. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5317 295794 hyperv/hn: Free the txdesc buf_ring when the TX ring is destroyed Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5318 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 07:30:54 2016 (r301861) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 08:03:53 2016 (r301862) @@ -58,6 +58,8 @@ #include +#define HN_USE_TXDESC_BUFRING + MALLOC_DECLARE(M_NETVSC); #define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF) @@ -990,8 +992,12 @@ typedef struct { hv_bool_uint8_t link_state; } netvsc_device_info; +#ifndef HN_USE_TXDESC_BUFRING struct hn_txdesc; SLIST_HEAD(hn_txdesc_list, hn_txdesc); +#else +struct buf_ring; +#endif struct hn_rx_ring { struct lro_ctrl hn_lro; @@ -1012,8 +1018,12 @@ struct hn_rx_ring { #define HN_TRUST_HCSUM_UDP 0x0004 struct hn_tx_ring { +#ifndef HN_USE_TXDESC_BUFRING struct mtx hn_txlist_spin; struct hn_txdesc_list hn_txlist; +#else + struct buf_ring *hn_txdesc_br; +#endif int hn_txdesc_cnt; int hn_txdesc_avail; int hn_txeof; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 07:30:54 2016 (r301861) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 08:03:53 2016 (r301862) @@ -66,10 +66,12 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +#include #include #include @@ -151,7 +153,9 @@ __FBSDID("$FreeBSD$"); #define HN_DIRECT_TX_SIZE_DEF 128 struct hn_txdesc { +#ifndef HN_USE_TXDESC_BUFRING SLIST_ENTRY(hn_txdesc) link; +#endif struct mbuf *m; struct hn_tx_ring *txr; int refs; @@ -173,7 +177,7 @@ struct hn_txdesc { * later. UDP checksum offloading doesn't work on earlier * Windows releases. */ -#define HN_CSUM_ASSIST_WIN8 (CSUM_TCP) +#define HN_CSUM_ASSIST_WIN8 (CSUM_IP | CSUM_TCP) #define HN_CSUM_ASSIST (CSUM_IP | CSUM_UDP | CSUM_TCP) #define HN_LRO_LENLIM_DEF (25 * ETHERMTU) @@ -258,6 +262,18 @@ SYSCTL_INT(_hw_hn, OID_AUTO, share_tx_ta static struct taskqueue *hn_tx_taskq; +#ifndef HN_USE_TXDESC_BUFRING +static int hn_use_txdesc_bufring = 0; +#else +static int hn_use_txdesc_bufring = 1; +#endif +SYSCTL_INT(_hw_hn, OID_AUTO, use_txdesc_bufring, CTLFLAG_RD, + &hn_use_txdesc_bufring, 0, "Use buf_ring for TX descriptors"); + +static int hn_bind_tx_taskq = -1; +SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN, + &hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu"); + /* * Forward declarations */ @@ -343,6 +359,19 @@ netvsc_probe(device_t dev) return (ENXIO); } +static void +hn_cpuset_setthread_task(void *xmask, int pending __unused) +{ + cpuset_t *mask = xmask; + int error; + + error = cpuset_setthread(curthread->td_tid, mask); + if (error) { + panic("curthread=%ju: can't pin; error=%d", + (uintmax_t)curthread->td_tid, error); + } +} + /* * Standard attach entry point. * @@ -376,6 +405,19 @@ netvsc_attach(device_t dev) taskqueue_thread_enqueue, &sc->hn_tx_taskq); taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx", device_get_nameunit(dev)); + if (hn_bind_tx_taskq >= 0) { + int cpu = hn_bind_tx_taskq; + struct task cpuset_task; + cpuset_t cpu_set; + + if (cpu > mp_ncpus - 1) + cpu = mp_ncpus - 1; + CPU_SETOF(cpu, &cpu_set); + TASK_INIT(&cpuset_task, 0, hn_cpuset_setthread_task, + &cpu_set); + taskqueue_enqueue(sc->hn_tx_taskq, &cpuset_task); + taskqueue_drain(sc->hn_tx_taskq, &cpuset_task); + } } else { sc->hn_tx_taskq = hn_tx_taskq; } @@ -572,6 +614,7 @@ hn_txdesc_put(struct hn_tx_ring *txr, st txd->flags |= HN_TXD_FLAG_ONLIST; +#ifndef HN_USE_TXDESC_BUFRING mtx_lock_spin(&txr->hn_txlist_spin); KASSERT(txr->hn_txdesc_avail >= 0 && txr->hn_txdesc_avail < txr->hn_txdesc_cnt, @@ -579,6 +622,10 @@ hn_txdesc_put(struct hn_tx_ring *txr, st txr->hn_txdesc_avail++; SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link); mtx_unlock_spin(&txr->hn_txlist_spin); +#else + atomic_add_int(&txr->hn_txdesc_avail, 1); + buf_ring_enqueue(txr->hn_txdesc_br, txd); +#endif return 1; } @@ -588,6 +635,7 @@ hn_txdesc_get(struct hn_tx_ring *txr) { struct hn_txdesc *txd; +#ifndef HN_USE_TXDESC_BUFRING mtx_lock_spin(&txr->hn_txlist_spin); txd = SLIST_FIRST(&txr->hn_txlist); if (txd != NULL) { @@ -597,8 +645,14 @@ hn_txdesc_get(struct hn_tx_ring *txr) SLIST_REMOVE_HEAD(&txr->hn_txlist, link); } mtx_unlock_spin(&txr->hn_txlist_spin); +#else + txd = buf_ring_dequeue_sc(txr->hn_txdesc_br); +#endif if (txd != NULL) { +#ifdef HN_USE_TXDESC_BUFRING + atomic_subtract_int(&txr->hn_txdesc_avail, 1); +#endif KASSERT(txd->m == NULL && txd->refs == 0 && (txd->flags & HN_TXD_FLAG_ONLIST), ("invalid txd")); txd->flags &= ~HN_TXD_FLAG_ONLIST; @@ -2061,13 +2115,20 @@ hn_create_tx_ring(struct hn_softc *sc, i txr->hn_sc = sc; +#ifndef HN_USE_TXDESC_BUFRING mtx_init(&txr->hn_txlist_spin, "hn txlist", NULL, MTX_SPIN); +#endif mtx_init(&txr->hn_tx_lock, "hn tx", NULL, MTX_DEF); txr->hn_txdesc_cnt = HN_TX_DESC_CNT; txr->hn_txdesc = malloc(sizeof(struct hn_txdesc) * txr->hn_txdesc_cnt, M_NETVSC, M_WAITOK | M_ZERO); +#ifndef HN_USE_TXDESC_BUFRING SLIST_INIT(&txr->hn_txlist); +#else + txr->hn_txdesc_br = buf_ring_alloc(txr->hn_txdesc_cnt, M_NETVSC, + M_WAITOK, &txr->hn_tx_lock); +#endif txr->hn_tx_taskq = sc->hn_tx_taskq; TASK_INIT(&txr->hn_start_task, 0, hn_start_taskfunc, txr); @@ -2171,7 +2232,11 @@ hn_create_tx_ring(struct hn_softc *sc, i /* All set, put it to list */ txd->flags |= HN_TXD_FLAG_ONLIST; +#ifndef HN_USE_TXDESC_BUFRING SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link); +#else + buf_ring_enqueue(txr->hn_txdesc_br, txd); +#endif } txr->hn_txdesc_avail = txr->hn_txdesc_cnt; @@ -2204,6 +2269,20 @@ hn_create_tx_ring(struct hn_softc *sc, i } static void +hn_txdesc_dmamap_destroy(struct hn_txdesc *txd) +{ + struct hn_tx_ring *txr = txd->txr; + + KASSERT(txd->m == NULL, ("still has mbuf installed")); + KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("still dma mapped")); + + bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_msg_dmap); + bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_msg, + txd->rndis_msg_dmap); + bus_dmamap_destroy(txr->hn_tx_data_dtag, txd->data_dmap); +} + +static void hn_destroy_tx_ring(struct hn_tx_ring *txr) { struct hn_txdesc *txd; @@ -2211,28 +2290,31 @@ hn_destroy_tx_ring(struct hn_tx_ring *tx if (txr->hn_txdesc == NULL) return; +#ifndef HN_USE_TXDESC_BUFRING while ((txd = SLIST_FIRST(&txr->hn_txlist)) != NULL) { - KASSERT(txd->m == NULL, ("still has mbuf installed")); - KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, - ("still dma mapped")); SLIST_REMOVE_HEAD(&txr->hn_txlist, link); - - bus_dmamap_unload(txr->hn_tx_rndis_dtag, - txd->rndis_msg_dmap); - bus_dmamem_free(txr->hn_tx_rndis_dtag, - txd->rndis_msg, txd->rndis_msg_dmap); - - bus_dmamap_destroy(txr->hn_tx_data_dtag, txd->data_dmap); + hn_txdesc_dmamap_destroy(txd); } +#else + while ((txd = buf_ring_dequeue_sc(txr->hn_txdesc_br)) != NULL) + hn_txdesc_dmamap_destroy(txd); +#endif if (txr->hn_tx_data_dtag != NULL) bus_dma_tag_destroy(txr->hn_tx_data_dtag); if (txr->hn_tx_rndis_dtag != NULL) bus_dma_tag_destroy(txr->hn_tx_rndis_dtag); + +#ifdef HN_USE_TXDESC_BUFRING + buf_ring_free(txr->hn_txdesc_br, M_NETVSC); +#endif + free(txr->hn_txdesc, M_NETVSC); txr->hn_txdesc = NULL; +#ifndef HN_USE_TXDESC_BUFRING mtx_destroy(&txr->hn_txlist_spin); +#endif mtx_destroy(&txr->hn_tx_lock); } @@ -2377,6 +2459,18 @@ hn_tx_taskq_create(void *arg __unused) hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, taskqueue_thread_enqueue, &hn_tx_taskq); taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx"); + if (hn_bind_tx_taskq >= 0) { + int cpu = hn_bind_tx_taskq; + struct task cpuset_task; + cpuset_t cpu_set; + + if (cpu > mp_ncpus - 1) + cpu = mp_ncpus - 1; + CPU_SETOF(cpu, &cpu_set); + TASK_INIT(&cpuset_task, 0, hn_cpuset_setthread_task, &cpu_set); + taskqueue_enqueue(hn_tx_taskq, &cpuset_task); + taskqueue_drain(hn_tx_taskq, &cpuset_task); + } } SYSINIT(hn_txtq_create, SI_SUB_DRIVERS, SI_ORDER_FIRST, hn_tx_taskq_create, NULL); From owner-svn-src-stable-10@freebsd.org Mon Jun 13 08:18:46 2016 Return-Path: Delivered-To: svn-src-stable-10@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 88219AF1866; Mon, 13 Jun 2016 08:18:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 3ECDD2D10; Mon, 13 Jun 2016 08:18:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D8IjPm002877; Mon, 13 Jun 2016 08:18:45 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D8IjwX002876; Mon, 13 Jun 2016 08:18:45 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130818.u5D8IjwX002876@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 08:18:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301863 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 08:18:46 -0000 Author: sephe Date: Mon Jun 13 08:18:45 2016 New Revision: 301863 URL: https://svnweb.freebsd.org/changeset/base/301863 Log: hyperv/hn: Fix mis-merge introduced by r301861. Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 08:03:53 2016 (r301862) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 08:18:45 2016 (r301863) @@ -292,6 +292,9 @@ static int hn_lro_ackcnt_sysctl(SYSCTL_H #endif static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS); +#if __FreeBSD_version < 1100095 +static int hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS); +#endif static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); @@ -1783,6 +1786,34 @@ hn_tx_chimney_size_sysctl(SYSCTL_HANDLER return 0; } +#if __FreeBSD_version < 1100095 +static int +hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int ofs = arg2, i, error; + struct hn_rx_ring *rxr; + uint64_t stat; + + stat = 0; + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + rxr = &sc->hn_rx_ring[i]; + stat += *((int *)((uint8_t *)rxr + ofs)); + } + + error = sysctl_handle_64(oidp, &stat, 0, req); + if (error || req->newptr == NULL) + return error; + + /* Zero out this stat. */ + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + rxr = &sc->hn_rx_ring[i]; + *((int *)((uint8_t *)rxr + ofs)) = 0; + } + return 0; +} +#endif + static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) { @@ -2031,11 +2062,21 @@ hn_create_rx_data(struct hn_softc *sc) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_queued", CTLTYPE_U64 | CTLFLAG_RW, sc, __offsetof(struct hn_rx_ring, hn_lro.lro_queued), - hn_rx_stat_u64_sysctl, "LU", "LRO queued"); +#if __FreeBSD_version < 1100095 + hn_rx_stat_int_sysctl, +#else + hn_rx_stat_u64_sysctl, +#endif + "LU", "LRO queued"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_flushed", CTLTYPE_U64 | CTLFLAG_RW, sc, __offsetof(struct hn_rx_ring, hn_lro.lro_flushed), - hn_rx_stat_u64_sysctl, "LU", "LRO flushed"); +#if __FreeBSD_version < 1100095 + hn_rx_stat_int_sysctl, +#else + hn_rx_stat_u64_sysctl, +#endif + "LU", "LRO flushed"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_tried", CTLTYPE_ULONG | CTLFLAG_RW, sc, __offsetof(struct hn_rx_ring, hn_lro_tried), From owner-svn-src-stable-10@freebsd.org Mon Jun 13 08:38:05 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E74FBAF1E3D; Mon, 13 Jun 2016 08:38:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9BE712580; Mon, 13 Jun 2016 08:38:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D8c43m009994; Mon, 13 Jun 2016 08:38:04 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D8c4t7009992; Mon, 13 Jun 2016 08:38:04 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130838.u5D8c4t7009992@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 08:38:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301864 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 08:38:06 -0000 Author: sephe Date: Mon Jun 13 08:38:04 2016 New Revision: 301864 URL: https://svnweb.freebsd.org/changeset/base/301864 Log: MFC 295875,295876,295877,295916,295918 295875 hyperv/hn: Rename TX related function and struct fields a bit Preamble to implement the ifnet.if_transmit method. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5344 295876 hyperv/hn: Staticize and rename packet TX done function It is only used in hv_netvsc_drv_freebsd.c; and rename it to hn_tx_done() mainly to reserve "xmit" for ifnet.if_transmit implement. While I'm here, remove unapplied comment. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5345 295877 hyperv/hn: Add TX method for txeof processing. Preamble to implement ifnet.if_transmit method. Reviewed by: adrian Approved by: adrian (mentor) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5346 295916 hyperv/hn: Factor out hn_send_pkt() from hn_start_locked() It will be shared w/ the upcoming ifnet.if_transmit method implementation. No functional change. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5385 295918 hyperv/hn: Use IFQ_DRV_PREPEND instead of IF_PREPEND IF_PREPEND promises out-of-order packet sending when the TX desc list is depleted. It was overlooked and copied blindly when the transmission path was partially rewritten. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5386 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 08:18:45 2016 (r301863) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Jun 13 08:38:04 2016 (r301864) @@ -1026,11 +1026,12 @@ struct hn_tx_ring { #endif int hn_txdesc_cnt; int hn_txdesc_avail; - int hn_txeof; + int hn_has_txeof; int hn_sched_tx; + void (*hn_txeof)(struct hn_tx_ring *); struct taskqueue *hn_tx_taskq; - struct task hn_start_task; + struct task hn_tx_task; struct task hn_txeof_task; struct mtx hn_tx_lock; @@ -1087,7 +1088,6 @@ typedef struct hn_softc { extern int hv_promisc_mode; void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status); -void netvsc_xmit_completion(void *context); void hv_nv_on_receive_completion(struct hv_device *device, uint64_t tid, uint32_t status); netvsc_dev *hv_nv_on_device_add(struct hv_device *device, Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 08:18:45 2016 (r301863) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 08:38:04 2016 (r301864) @@ -304,8 +304,8 @@ static int hn_create_tx_ring(struct hn_s static void hn_destroy_tx_ring(struct hn_tx_ring *); static int hn_create_tx_data(struct hn_softc *); static void hn_destroy_tx_data(struct hn_softc *); -static void hn_start_taskfunc(void *xsc, int pending); -static void hn_txeof_taskfunc(void *xsc, int pending); +static void hn_start_taskfunc(void *, int); +static void hn_start_txeof_taskfunc(void *, int); static void hn_stop_tx_tasks(struct hn_softc *); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static void hn_create_rx_data(struct hn_softc *sc); @@ -673,17 +673,10 @@ hn_txdesc_hold(struct hn_txdesc *txd) atomic_add_int(&txd->refs, 1); } -/* - * Send completion processing - * - * Note: It looks like offset 0 of buf is reserved to hold the softc - * pointer. The sc pointer is not currently needed in this function, and - * it is not presently populated by the TX function. - */ -void -netvsc_xmit_completion(void *context) +static void +hn_tx_done(void *xpkt) { - netvsc_packet *packet = context; + netvsc_packet *packet = xpkt; struct hn_txdesc *txd; struct hn_tx_ring *txr; @@ -691,7 +684,7 @@ netvsc_xmit_completion(void *context) packet->compl.send.send_completion_tid; txr = txd->txr; - txr->hn_txeof = 1; + txr->hn_has_txeof = 1; hn_txdesc_put(txr, txd); } @@ -711,11 +704,11 @@ netvsc_channel_rollup(struct hv_device * } #endif - if (!txr->hn_txeof) + if (!txr->hn_has_txeof) return; - txr->hn_txeof = 0; - hn_start_txeof(txr); + txr->hn_has_txeof = 0; + txr->hn_txeof(txr); } /* @@ -925,7 +918,7 @@ done: txd->m = m_head; /* Set the completion routine */ - packet->compl.send.on_send_completion = netvsc_xmit_completion; + packet->compl.send.on_send_completion = hn_tx_done; packet->compl.send.send_completion_context = packet; packet->compl.send.send_completion_tid = (uint64_t)(uintptr_t)txd; @@ -933,6 +926,68 @@ done: } /* + * NOTE: + * If this function fails, then txd will be freed, but the mbuf + * associated w/ the txd will _not_ be freed. + */ +static int +hn_send_pkt(struct ifnet *ifp, struct hv_device *device_ctx, + struct hn_tx_ring *txr, struct hn_txdesc *txd) +{ + int error, send_failed = 0; + +again: + /* + * Make sure that txd is not freed before ETHER_BPF_MTAP. + */ + hn_txdesc_hold(txd); + error = hv_nv_on_send(device_ctx, &txd->netvsc_pkt); + if (!error) { + ETHER_BPF_MTAP(ifp, txd->m); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + } + hn_txdesc_put(txr, txd); + + if (__predict_false(error)) { + int freed; + + /* + * This should "really rarely" happen. + * + * XXX Too many RX to be acked or too many sideband + * commands to run? Ask netvsc_channel_rollup() + * to kick start later. + */ + txr->hn_has_txeof = 1; + if (!send_failed) { + txr->hn_send_failed++; + send_failed = 1; + /* + * Try sending again after set hn_has_txeof; + * in case that we missed the last + * netvsc_channel_rollup(). + */ + goto again; + } + if_printf(ifp, "send failed\n"); + + /* + * Caller will perform further processing on the + * associated mbuf, so don't free it in hn_txdesc_put(); + * only unload it from the DMA map in hn_txdesc_put(), + * if it was loaded. + */ + txd->m = NULL; + freed = hn_txdesc_put(txr, txd); + KASSERT(freed != 0, + ("fail to free txd upon send error")); + + txr->hn_send_failed++; + } + return error; +} + +/* * Start a transmit of one or more packets */ static int @@ -950,9 +1005,9 @@ hn_start_locked(struct hn_tx_ring *txr, return 0; while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { - int error, send_failed = 0; struct hn_txdesc *txd; struct mbuf *m_head; + int error; IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) @@ -964,14 +1019,14 @@ hn_start_locked(struct hn_tx_ring *txr, * dispatch this packet sending (and sending of any * following up packets) to tx taskqueue. */ - IF_PREPEND(&ifp->if_snd, m_head); + IFQ_DRV_PREPEND(&ifp->if_snd, m_head); return 1; } txd = hn_txdesc_get(txr); if (txd == NULL) { txr->hn_no_txdescs++; - IF_PREPEND(&ifp->if_snd, m_head); + IFQ_DRV_PREPEND(&ifp->if_snd, m_head); atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); break; } @@ -981,53 +1036,11 @@ hn_start_locked(struct hn_tx_ring *txr, /* Both txd and m_head are freed */ continue; } -again: - /* - * Make sure that txd is not freed before ETHER_BPF_MTAP. - */ - hn_txdesc_hold(txd); - error = hv_nv_on_send(device_ctx, &txd->netvsc_pkt); - if (!error) { - ETHER_BPF_MTAP(ifp, m_head); - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - } - hn_txdesc_put(txr, txd); + error = hn_send_pkt(ifp, device_ctx, txr, txd); if (__predict_false(error)) { - int freed; - - /* - * This should "really rarely" happen. - * - * XXX Too many RX to be acked or too many sideband - * commands to run? Ask netvsc_channel_rollup() - * to kick start later. - */ - txr->hn_txeof = 1; - if (!send_failed) { - txr->hn_send_failed++; - send_failed = 1; - /* - * Try sending again after set hn_txeof; - * in case that we missed the last - * netvsc_channel_rollup(). - */ - goto again; - } - if_printf(ifp, "send failed\n"); - - /* - * This mbuf will be prepended, don't free it - * in hn_txdesc_put(); only unload it from the - * DMA map in hn_txdesc_put(), if it was loaded. - */ - txd->m = NULL; - freed = hn_txdesc_put(txr, txd); - KASSERT(freed != 0, - ("fail to free txd upon send error")); - - txr->hn_send_failed++; - IF_PREPEND(&ifp->if_snd, m_head); + /* txd is freed, but m_head is not */ + IFQ_DRV_PREPEND(&ifp->if_snd, m_head); atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); break; } @@ -1578,7 +1591,7 @@ hn_start(struct ifnet *ifp) return; } do_sched: - taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_start_task); + taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_tx_task); } static void @@ -1600,7 +1613,7 @@ hn_start_txeof(struct hn_tx_ring *txr) mtx_unlock(&txr->hn_tx_lock); if (sched) { taskqueue_enqueue(txr->hn_tx_taskq, - &txr->hn_start_task); + &txr->hn_tx_task); } } else { do_sched: @@ -2172,8 +2185,8 @@ hn_create_tx_ring(struct hn_softc *sc, i #endif txr->hn_tx_taskq = sc->hn_tx_taskq; - TASK_INIT(&txr->hn_start_task, 0, hn_start_taskfunc, txr); - TASK_INIT(&txr->hn_txeof_task, 0, hn_txeof_taskfunc, txr); + TASK_INIT(&txr->hn_tx_task, 0, hn_start_taskfunc, txr); + TASK_INIT(&txr->hn_txeof_task, 0, hn_start_txeof_taskfunc, txr); txr->hn_direct_tx_size = hn_direct_tx_size; if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1) @@ -2187,6 +2200,8 @@ hn_create_tx_ring(struct hn_softc *sc, i */ txr->hn_sched_tx = 1; + txr->hn_txeof = hn_start_txeof; /* TODO: if_transmit */ + parent_dtag = bus_get_dma_tag(sc->hn_dev); /* DMA tag for RNDIS messages. */ @@ -2468,7 +2483,7 @@ hn_start_taskfunc(void *xtxr, int pendin } static void -hn_txeof_taskfunc(void *xtxr, int pending __unused) +hn_start_txeof_taskfunc(void *xtxr, int pending __unused) { struct hn_tx_ring *txr = xtxr; @@ -2486,7 +2501,7 @@ hn_stop_tx_tasks(struct hn_softc *sc) for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; - taskqueue_drain(txr->hn_tx_taskq, &txr->hn_start_task); + taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task); taskqueue_drain(txr->hn_tx_taskq, &txr->hn_txeof_task); } } From owner-svn-src-stable-10@freebsd.org Mon Jun 13 08:44:30 2016 Return-Path: Delivered-To: svn-src-stable-10@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 A629FAF1FE6; Mon, 13 Jun 2016 08:44:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 63ECF2962; Mon, 13 Jun 2016 08:44:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D8iTxs013459; Mon, 13 Jun 2016 08:44:29 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D8iTXx013458; Mon, 13 Jun 2016 08:44:29 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130844.u5D8iTXx013458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 08:44:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301865 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 08:44:30 -0000 Author: sephe Date: Mon Jun 13 08:44:29 2016 New Revision: 301865 URL: https://svnweb.freebsd.org/changeset/base/301865 Log: hyperv/hn: Hide unused function Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 08:38:04 2016 (r301864) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Jun 13 08:44:29 2016 (r301865) @@ -294,9 +294,10 @@ static int hn_trust_hcsum_sysctl(SYSCTL_ static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS); #if __FreeBSD_version < 1100095 static int hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS); +#else +static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); #endif static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); @@ -1825,56 +1826,57 @@ hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARG } return 0; } -#endif - +#else static int -hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) +hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; int ofs = arg2, i, error; struct hn_rx_ring *rxr; - u_long stat; + uint64_t stat; stat = 0; for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; - stat += *((u_long *)((uint8_t *)rxr + ofs)); + stat += *((uint64_t *)((uint8_t *)rxr + ofs)); } - error = sysctl_handle_long(oidp, &stat, 0, req); + error = sysctl_handle_64(oidp, &stat, 0, req); if (error || req->newptr == NULL) return error; /* Zero out this stat. */ for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; - *((u_long *)((uint8_t *)rxr + ofs)) = 0; + *((uint64_t *)((uint8_t *)rxr + ofs)) = 0; } return 0; } +#endif + static int -hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS) +hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; int ofs = arg2, i, error; struct hn_rx_ring *rxr; - uint64_t stat; + u_long stat; stat = 0; for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; - stat += *((uint64_t *)((uint8_t *)rxr + ofs)); + stat += *((u_long *)((uint8_t *)rxr + ofs)); } - error = sysctl_handle_64(oidp, &stat, 0, req); + error = sysctl_handle_long(oidp, &stat, 0, req); if (error || req->newptr == NULL) return error; /* Zero out this stat. */ for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { rxr = &sc->hn_rx_ring[i]; - *((uint64_t *)((uint8_t *)rxr + ofs)) = 0; + *((u_long *)((uint8_t *)rxr + ofs)) = 0; } return 0; } From owner-svn-src-stable-10@freebsd.org Mon Jun 13 09:02:09 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E2C2EAF0638; Mon, 13 Jun 2016 09:02:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A701420AE; Mon, 13 Jun 2016 09:02:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5D928mR020525; Mon, 13 Jun 2016 09:02:08 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5D928h6020518; Mon, 13 Jun 2016 09:02:08 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606130902.u5D928h6020518@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 13 Jun 2016 09:02:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301866 - in stable/10/sys: conf dev/hyperv/include dev/hyperv/storvsc dev/hyperv/utilities dev/hyperv/vmbus modules/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 09:02:10 -0000 Author: sephe Date: Mon Jun 13 09:02:08 2016 New Revision: 301866 URL: https://svnweb.freebsd.org/changeset/base/301866 Log: MFC 295919,295958,295964 295919 hyperv/stor: Fix print format Detected by: PVS Static Analysis MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5388 295958 hyperv/utils: Code rearrange and cleanup Split heartbeat, shutdown and timesync out of utils code and name them properly. Submitted by: Jun Su Reviewed by: adrian, sephe, Hongjiang Zhang MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5216 295964 hyperv/vmbus: Use free(9) for interrupt page; it is allocated by malloc(9) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5417 Added: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c - copied unchanged from r295958, head/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c - copied unchanged from r295958, head/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c - copied unchanged from r295958, head/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/hv_util.h - copied unchanged from r295958, head/sys/dev/hyperv/utilities/hv_util.h Modified: stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_kvp.h stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/vmbus/hv_connection.c stable/10/sys/modules/hyperv/utilities/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Mon Jun 13 08:44:29 2016 (r301865) +++ stable/10/sys/conf/files.amd64 Mon Jun 13 09:02:08 2016 (r301866) @@ -266,7 +266,10 @@ dev/hyperv/netvsc/hv_netvsc_drv_freebsd. dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv dev/hyperv/stordisengage/hv_ata_pci_disengage.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv +dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv +dev/hyperv/utilities/hv_shutdown.c optional hyperv +dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Mon Jun 13 08:44:29 2016 (r301865) +++ stable/10/sys/conf/files.i386 Mon Jun 13 09:02:08 2016 (r301866) @@ -242,7 +242,10 @@ dev/hyperv/netvsc/hv_netvsc_drv_freebsd. dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv dev/hyperv/stordisengage/hv_ata_pci_disengage.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv +dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv +dev/hyperv/utilities/hv_shutdown.c optional hyperv +dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Mon Jun 13 08:44:29 2016 (r301865) +++ stable/10/sys/dev/hyperv/include/hyperv.h Mon Jun 13 09:02:08 2016 (r301866) @@ -919,40 +919,5 @@ hv_get_phys_addr(void *virt) return (ret); } - -/** - * KVP related structures - * - */ -typedef struct hv_vmbus_service { - hv_guid guid; /* Hyper-V GUID */ - char *name; /* name of service */ - boolean_t enabled; /* service enabled */ - void* context; - struct task task; - /* - * function to initialize service - */ - int (*init)(struct hv_vmbus_service *); - - /* - * function to process Hyper-V messages - */ - void (*callback)(void *); - - /* - * function to uninitilize service - */ - int (*uninit)(struct hv_vmbus_service *); -} hv_vmbus_service; - -extern uint8_t* receive_buffer[]; -extern hv_vmbus_service service_table[]; extern uint32_t hv_vmbus_protocal_version; - -void hv_kvp_callback(void *context); -int hv_kvp_init(hv_vmbus_service *serv); -void hv_kvp_deinit(void); - #endif /* __HYPERV_H__ */ - Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Jun 13 08:44:29 2016 (r301865) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Jun 13 09:02:08 2016 (r301866) @@ -856,8 +856,8 @@ hv_storvsc_rescan_target(struct storvsc_ if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid, targetid, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { - printf("unable to create path for rescan, pathid: %d," - "targetid: %d\n", pathid, targetid); + printf("unable to create path for rescan, pathid: %u," + "targetid: %u\n", pathid, targetid); xpt_free_ccb(ccb); return; } Copied: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c (from r295958, head/sys/dev/hyperv/utilities/hv_heartbeat.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Mon Jun 13 09:02:08 2016 (r301866, copy of r295958, head/sys/dev/hyperv/utilities/hv_heartbeat.c) @@ -0,0 +1,129 @@ +/*- + * Copyright (c) 2014 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include "hv_util.h" + +/* Heartbeat Service */ +static hv_guid service_guid = { .data = + {0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, + 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }; + +/** + * Process heartbeat message + */ +static void +hv_heartbeat_cb(void *context) +{ + uint8_t* buf; + hv_vmbus_channel* channel; + uint32_t recvlen; + uint64_t requestid; + int ret; + + struct hv_vmbus_heartbeat_msg_data* heartbeat_msg; + struct hv_vmbus_icmsg_hdr* icmsghdrp; + hv_util_sc *softc; + + softc = (hv_util_sc*)context; + buf = softc->receive_buffer;; + channel = softc->hv_dev->channel; + + ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE, &recvlen, + &requestid); + + if ((ret == 0) && recvlen > 0) { + + icmsghdrp = (struct hv_vmbus_icmsg_hdr *) + &buf[sizeof(struct hv_vmbus_pipe_hdr)]; + + if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { + hv_negotiate_version(icmsghdrp, NULL, buf); + + } else { + heartbeat_msg = + (struct hv_vmbus_heartbeat_msg_data *) + &buf[sizeof(struct hv_vmbus_pipe_hdr) + + sizeof(struct hv_vmbus_icmsg_hdr)]; + + heartbeat_msg->seq_num += 1; + } + + icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | + HV_ICMSGHDRFLAG_RESPONSE; + + hv_vmbus_channel_send_packet(channel, buf, recvlen, requestid, + HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + } +} + +static int +hv_heartbeat_probe(device_t dev) +{ + const char *p = vmbus_get_type(dev); + if (!memcmp(p, &service_guid, sizeof(hv_guid))) { + device_set_desc(dev, "Hyper-V Heartbeat Service"); + return BUS_PROBE_DEFAULT; + } + + return ENXIO; +} + +static int +hv_heartbeat_attach(device_t dev) +{ + hv_util_sc *softc = (hv_util_sc*)device_get_softc(dev); + + softc->callback = hv_heartbeat_cb; + + return hv_util_attach(dev); +} + +static device_method_t heartbeat_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, hv_heartbeat_probe), + DEVMETHOD(device_attach, hv_heartbeat_attach), + DEVMETHOD(device_detach, hv_util_detach), + { 0, 0 } +}; + +static driver_t heartbeat_driver = { "hvheartbeat", heartbeat_methods, sizeof(hv_util_sc)}; + +static devclass_t heartbeat_devclass; + +DRIVER_MODULE(hv_heartbeat, vmbus, heartbeat_driver, heartbeat_devclass, NULL, NULL); +MODULE_VERSION(hv_heartbeat, 1); +MODULE_DEPEND(hv_heartbeat, vmbus, 1, 1, 1); Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Mon Jun 13 08:44:29 2016 (r301865) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Mon Jun 13 09:02:08 2016 (r301866) @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include "hv_util.h" #include "unicode.h" #include "hv_kvp.h" @@ -74,8 +75,6 @@ __FBSDID("$FreeBSD$"); /* hv_kvp debug control */ static int hv_kvp_log = 0; -SYSCTL_INT(_dev, OID_AUTO, hv_kvp_log, CTLFLAG_RW, &hv_kvp_log, 0, - "hv_kvp log"); #define hv_kvp_log_error(...) do { \ if (hv_kvp_log > 0) \ @@ -87,6 +86,10 @@ SYSCTL_INT(_dev, OID_AUTO, hv_kvp_log, C log(LOG_INFO, "hv_kvp: " __VA_ARGS__); \ } while (0) +static hv_guid service_guid = { .data = + {0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, + 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6} }; + /* character device prototypes */ static d_open_t hv_kvp_dev_open; static d_close_t hv_kvp_dev_close; @@ -94,12 +97,6 @@ static d_read_t hv_kvp_dev_daemon_read; static d_write_t hv_kvp_dev_daemon_write; static d_poll_t hv_kvp_dev_daemon_poll; -/* hv_kvp prototypes */ -static int hv_kvp_req_in_progress(void); -static void hv_kvp_transaction_init(uint32_t, hv_vmbus_channel *, uint64_t, uint8_t *); -static void hv_kvp_send_msg_to_daemon(void); -static void hv_kvp_process_request(void *context, int pending); - /* hv_kvp character device structure */ static struct cdevsw hv_kvp_cdevsw = { @@ -111,67 +108,67 @@ static struct cdevsw hv_kvp_cdevsw = .d_poll = hv_kvp_dev_daemon_poll, .d_name = "hv_kvp_dev", }; -static struct cdev *hv_kvp_dev; -static struct hv_kvp_msg *hv_kvp_dev_buf; -struct proc *daemon_task; -static struct selinfo hv_kvp_selinfo; /* * Global state to track and synchronize multiple * KVP transaction requests from the host. */ -static struct { +typedef struct hv_kvp_sc { + struct hv_util_sc util_sc; - /* Unless specified the pending mutex should be + /* Unless specified the pending mutex should be * used to alter the values of the following paramters: * 1. req_in_progress * 2. req_timed_out - * 3. pending_reqs. */ - struct mtx pending_mutex; - + struct mtx pending_mutex; + + struct task task; + /* To track if transaction is active or not */ - boolean_t req_in_progress; + boolean_t req_in_progress; /* Tracks if daemon did not reply back in time */ - boolean_t req_timed_out; + boolean_t req_timed_out; /* Tracks if daemon is serving a request currently */ boolean_t daemon_busy; - /* Count of KVP requests from Hyper-V. */ - uint64_t pending_reqs; - - - /* Length of host message */ - uint32_t host_msg_len; - /* Pointer to channel */ - hv_vmbus_channel *channelp; + /* Length of host message */ + uint32_t host_msg_len; /* Host message id */ - uint64_t host_msg_id; - + uint64_t host_msg_id; + /* Current kvp message from the host */ - struct hv_kvp_msg *host_kvp_msg; - + struct hv_kvp_msg *host_kvp_msg; + /* Current kvp message for daemon */ - struct hv_kvp_msg daemon_kvp_msg; - + struct hv_kvp_msg daemon_kvp_msg; + /* Rcv buffer for communicating with the host*/ - uint8_t *rcv_buf; - + uint8_t *rcv_buf; + /* Device semaphore to control communication */ - struct sema dev_sema; - + struct sema dev_sema; + /* Indicates if daemon registered with driver */ - boolean_t register_done; - + boolean_t register_done; + /* Character device status */ - boolean_t dev_accessed; -} kvp_globals; + boolean_t dev_accessed; + + struct cdev *hv_kvp_dev; -/* global vars */ -MALLOC_DECLARE(M_HV_KVP_DEV_BUF); -MALLOC_DEFINE(M_HV_KVP_DEV_BUF, "hv_kvp_dev buffer", "buffer for hv_kvp_dev module"); + struct proc *daemon_task; + + struct selinfo hv_kvp_selinfo; +} hv_kvp_sc; + +/* hv_kvp prototypes */ +static int hv_kvp_req_in_progress(hv_kvp_sc *sc); +static void hv_kvp_transaction_init(hv_kvp_sc *sc, uint32_t, uint64_t, uint8_t *); +static void hv_kvp_send_msg_to_daemon(hv_kvp_sc *sc); +static void hv_kvp_process_request(void *context, int pending); /* * hv_kvp low level functions @@ -181,10 +178,10 @@ MALLOC_DEFINE(M_HV_KVP_DEV_BUF, "hv_kvp_ * Check if kvp transaction is in progres */ static int -hv_kvp_req_in_progress(void) +hv_kvp_req_in_progress(hv_kvp_sc *sc) { - return (kvp_globals.req_in_progress); + return (sc->req_in_progress); } @@ -192,18 +189,17 @@ hv_kvp_req_in_progress(void) * This routine is called whenever a message is received from the host */ static void -hv_kvp_transaction_init(uint32_t rcv_len, hv_vmbus_channel *rcv_channel, +hv_kvp_transaction_init(hv_kvp_sc *sc, uint32_t rcv_len, uint64_t request_id, uint8_t *rcv_buf) { - + /* Store all the relevant message details in the global structure */ /* Do not need to use mutex for req_in_progress here */ - kvp_globals.req_in_progress = true; - kvp_globals.host_msg_len = rcv_len; - kvp_globals.channelp = rcv_channel; - kvp_globals.host_msg_id = request_id; - kvp_globals.rcv_buf = rcv_buf; - kvp_globals.host_kvp_msg = (struct hv_kvp_msg *)&rcv_buf[ + sc->req_in_progress = true; + sc->host_msg_len = rcv_len; + sc->host_msg_id = request_id; + sc->rcv_buf = rcv_buf; + sc->host_kvp_msg = (struct hv_kvp_msg *)&rcv_buf[ sizeof(struct hv_vmbus_pipe_hdr) + sizeof(struct hv_vmbus_icmsg_hdr)]; } @@ -255,12 +251,12 @@ hv_kvp_negotiate_version(struct hv_vmbus * Convert ip related info in umsg from utf8 to utf16 and store in hmsg */ static int -hv_kvp_convert_utf8_ipinfo_to_utf16(struct hv_kvp_msg *umsg, +hv_kvp_convert_utf8_ipinfo_to_utf16(struct hv_kvp_msg *umsg, struct hv_kvp_ip_msg *host_ip_msg) { int err_ip, err_subnet, err_gway, err_dns, err_adap; int UNUSED_FLAG = 1; - + utf8_to_utf16((uint16_t *)host_ip_msg->kvp_ip_val.ip_addr, MAX_IP_ADDR_SIZE, (char *)umsg->body.kvp_ip_val.ip_addr, @@ -291,7 +287,7 @@ hv_kvp_convert_utf8_ipinfo_to_utf16(stru strlen((char *)umsg->body.kvp_ip_val.adapter_id), UNUSED_FLAG, &err_adap); - + host_ip_msg->kvp_ip_val.dhcp_enabled = umsg->body.kvp_ip_val.dhcp_enabled; host_ip_msg->kvp_ip_val.addr_family = umsg->body.kvp_ip_val.addr_family; @@ -386,7 +382,7 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru MAX_IP_ADDR_SIZE, UNUSED_FLAG, &err_subnet); - + utf16_to_utf8((char *)umsg->body.kvp_ip_val.gate_way, MAX_GATEWAY_SIZE, (uint16_t *)host_ip_msg->kvp_ip_val.gate_way, MAX_GATEWAY_SIZE, @@ -408,16 +404,13 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru * Ensure utf16_utf8 takes care of the additional string terminating char!! */ static void -hv_kvp_convert_hostmsg_to_usermsg(void) +hv_kvp_convert_hostmsg_to_usermsg(struct hv_kvp_msg *hmsg, struct hv_kvp_msg *umsg) { int utf_err = 0; uint32_t value_type; - struct hv_kvp_ip_msg *host_ip_msg = (struct hv_kvp_ip_msg *) - kvp_globals.host_kvp_msg; - - struct hv_kvp_msg *hmsg = kvp_globals.host_kvp_msg; - struct hv_kvp_msg *umsg = &kvp_globals.daemon_kvp_msg; + struct hv_kvp_ip_msg *host_ip_msg; + host_ip_msg = (struct hv_kvp_ip_msg*)hmsg; memset(umsg, 0, sizeof(struct hv_kvp_msg)); umsg->kvp_hdr.operation = hmsg->kvp_hdr.operation; @@ -522,14 +515,12 @@ hv_kvp_convert_hostmsg_to_usermsg(void) * Prepare a host kvp msg based on user kvp msg (utf8 to utf16) */ static int -hv_kvp_convert_usermsg_to_hostmsg(void) +hv_kvp_convert_usermsg_to_hostmsg(struct hv_kvp_msg *umsg, struct hv_kvp_msg *hmsg) { int hkey_len = 0, hvalue_len = 0, utf_err = 0; struct hv_kvp_exchg_msg_value *host_exchg_data; char *key_name, *value; - struct hv_kvp_msg *umsg = &kvp_globals.daemon_kvp_msg; - struct hv_kvp_msg *hmsg = kvp_globals.host_kvp_msg; struct hv_kvp_ip_msg *host_ip_msg = (struct hv_kvp_ip_msg *)hmsg; switch (hmsg->kvp_hdr.operation) { @@ -561,7 +552,7 @@ hv_kvp_convert_usermsg_to_hostmsg(void) if ((hkey_len < 0) || (hvalue_len < 0)) return (HV_KVP_E_FAIL); - + return (KVP_SUCCESS); case HV_KVP_OP_GET: @@ -577,9 +568,9 @@ hv_kvp_convert_usermsg_to_hostmsg(void) /* Use values by string */ host_exchg_data->value_type = HV_REG_SZ; - if ((hkey_len < 0) || (hvalue_len < 0)) + if ((hkey_len < 0) || (hvalue_len < 0)) return (HV_KVP_E_FAIL); - + return (KVP_SUCCESS); default: @@ -592,22 +583,22 @@ hv_kvp_convert_usermsg_to_hostmsg(void) * Send the response back to the host. */ static void -hv_kvp_respond_host(int error) +hv_kvp_respond_host(hv_kvp_sc *sc, int error) { struct hv_vmbus_icmsg_hdr *hv_icmsg_hdrp; hv_icmsg_hdrp = (struct hv_vmbus_icmsg_hdr *) - &kvp_globals.rcv_buf[sizeof(struct hv_vmbus_pipe_hdr)]; + &sc->rcv_buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (error) error = HV_KVP_E_FAIL; hv_icmsg_hdrp->status = error; hv_icmsg_hdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - - error = hv_vmbus_channel_send_packet(kvp_globals.channelp, - kvp_globals.rcv_buf, - kvp_globals.host_msg_len, kvp_globals.host_msg_id, + + error = hv_vmbus_channel_send_packet(sc->util_sc.hv_dev->channel, + sc->rcv_buf, + sc->host_msg_len, sc->host_msg_id, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); if (error) @@ -621,16 +612,19 @@ hv_kvp_respond_host(int error) * and the host */ static void -hv_kvp_send_msg_to_daemon(void) +hv_kvp_send_msg_to_daemon(hv_kvp_sc *sc) { + struct hv_kvp_msg *hmsg = sc->host_kvp_msg; + struct hv_kvp_msg *umsg = &sc->daemon_kvp_msg; + /* Prepare kvp_msg to be sent to user */ - hv_kvp_convert_hostmsg_to_usermsg(); + hv_kvp_convert_hostmsg_to_usermsg(hmsg, umsg); /* Send the msg to user via function deamon_read - setting sema */ - sema_post(&kvp_globals.dev_sema); + sema_post(&sc->dev_sema); /* We should wake up the daemon, in case it's doing poll() */ - selwakeup(&hv_kvp_selinfo); + selwakeup(&sc->hv_kvp_selinfo); } @@ -642,95 +636,80 @@ static void hv_kvp_process_request(void *context, int pending) { uint8_t *kvp_buf; - hv_vmbus_channel *channel = context; + hv_vmbus_channel *channel; uint32_t recvlen = 0; uint64_t requestid; struct hv_vmbus_icmsg_hdr *icmsghdrp; int ret = 0; - uint64_t pending_cnt = 1; - + hv_kvp_sc *sc; + hv_kvp_log_info("%s: entering hv_kvp_process_request\n", __func__); - kvp_buf = receive_buffer[HV_KVP]; + + sc = (hv_kvp_sc*)context; + kvp_buf = sc->util_sc.receive_buffer;; + channel = sc->util_sc.hv_dev->channel; + ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, &recvlen, &requestid); - /* - * We start counting only after the daemon registers - * and therefore there could be requests pending in - * the VMBus that are not reflected in pending_cnt. - * Therefore we continue reading as long as either of - * the below conditions is true. - */ + while ((ret == 0) && (recvlen > 0)) { - while ((pending_cnt>0) || ((ret == 0) && (recvlen > 0))) { + icmsghdrp = (struct hv_vmbus_icmsg_hdr *) + &kvp_buf[sizeof(struct hv_vmbus_pipe_hdr)]; - if ((ret == 0) && (recvlen>0)) { - - icmsghdrp = (struct hv_vmbus_icmsg_hdr *) - &kvp_buf[sizeof(struct hv_vmbus_pipe_hdr)]; - - hv_kvp_transaction_init(recvlen, channel, requestid, kvp_buf); - if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_kvp_negotiate_version(icmsghdrp, NULL, kvp_buf); - hv_kvp_respond_host(ret); - - /* - * It is ok to not acquire the mutex before setting - * req_in_progress here because negotiation is the - * first thing that happens and hence there is no - * chance of a race condition. - */ - - kvp_globals.req_in_progress = false; - hv_kvp_log_info("%s :version negotiated\n", __func__); - - } else { - if (!kvp_globals.daemon_busy) { - - hv_kvp_log_info("%s: issuing qury to daemon\n", __func__); - mtx_lock(&kvp_globals.pending_mutex); - kvp_globals.req_timed_out = false; - kvp_globals.daemon_busy = true; - mtx_unlock(&kvp_globals.pending_mutex); - - hv_kvp_send_msg_to_daemon(); - hv_kvp_log_info("%s: waiting for daemon\n", __func__); - } - - /* Wait 5 seconds for daemon to respond back */ - tsleep(&kvp_globals, 0, "kvpworkitem", 5 * hz); - hv_kvp_log_info("%s: came out of wait\n", __func__); + hv_kvp_transaction_init(sc, recvlen, requestid, kvp_buf); + if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { + hv_kvp_negotiate_version(icmsghdrp, NULL, kvp_buf); + hv_kvp_respond_host(sc, ret); + + /* + * It is ok to not acquire the mutex before setting + * req_in_progress here because negotiation is the + * first thing that happens and hence there is no + * chance of a race condition. + */ + + sc->req_in_progress = false; + hv_kvp_log_info("%s :version negotiated\n", __func__); + + } else { + if (!sc->daemon_busy) { + + hv_kvp_log_info("%s: issuing qury to daemon\n", __func__); + mtx_lock(&sc->pending_mutex); + sc->req_timed_out = false; + sc->daemon_busy = true; + mtx_unlock(&sc->pending_mutex); + + hv_kvp_send_msg_to_daemon(sc); + hv_kvp_log_info("%s: waiting for daemon\n", __func__); } + + /* Wait 5 seconds for daemon to respond back */ + tsleep(sc, 0, "kvpworkitem", 5 * hz); + hv_kvp_log_info("%s: came out of wait\n", __func__); } - mtx_lock(&kvp_globals.pending_mutex); - + mtx_lock(&sc->pending_mutex); + /* Notice that once req_timed_out is set to true * it will remain true until the next request is * sent to the daemon. The response from daemon - * is forwarded to host only when this flag is - * false. + * is forwarded to host only when this flag is + * false. */ - kvp_globals.req_timed_out = true; + sc->req_timed_out = true; /* * Cancel request if so need be. */ - if (hv_kvp_req_in_progress()) { + if (hv_kvp_req_in_progress(sc)) { hv_kvp_log_info("%s: request was still active after wait so failing\n", __func__); - hv_kvp_respond_host(HV_KVP_E_FAIL); - kvp_globals.req_in_progress = false; + hv_kvp_respond_host(sc, HV_KVP_E_FAIL); + sc->req_in_progress = false; } - - /* - * Decrement pending request count and - */ - if (kvp_globals.pending_reqs>0) { - kvp_globals.pending_reqs = kvp_globals.pending_reqs - 1; - } - pending_cnt = kvp_globals.pending_reqs; - - mtx_unlock(&kvp_globals.pending_mutex); + + mtx_unlock(&sc->pending_mutex); /* * Try reading next buffer @@ -738,104 +717,43 @@ hv_kvp_process_request(void *context, in recvlen = 0; ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, &recvlen, &requestid); - hv_kvp_log_info("%s: read: context %p, pending_cnt %llu ret =%d, recvlen=%d\n", - __func__, context, (unsigned long long)pending_cnt, ret, recvlen); - } + hv_kvp_log_info("%s: read: context %p, ret =%d, recvlen=%d\n", + __func__, context, ret, recvlen); + } } /* * Callback routine that gets called whenever there is a message from host */ -void +static void hv_kvp_callback(void *context) { - uint64_t pending_cnt = 0; - - if (kvp_globals.register_done == false) { - kvp_globals.channelp = context; - TASK_INIT(&service_table[HV_KVP].task, 0, hv_kvp_process_request, context); - } else { - mtx_lock(&kvp_globals.pending_mutex); - kvp_globals.pending_reqs = kvp_globals.pending_reqs + 1; - pending_cnt = kvp_globals.pending_reqs; - mtx_unlock(&kvp_globals.pending_mutex); - if (pending_cnt == 1) { - hv_kvp_log_info("%s: Queuing work item\n", __func__); - taskqueue_enqueue(taskqueue_thread, &service_table[HV_KVP].task); - } - } -} - - -/* - * This function is called by the hv_kvp_init - - * creates character device hv_kvp_dev - * allocates memory to hv_kvp_dev_buf - * - */ -static int -hv_kvp_dev_init(void) -{ - int error = 0; - - /* initialize semaphore */ - sema_init(&kvp_globals.dev_sema, 0, "hv_kvp device semaphore"); - /* create character device */ - error = make_dev_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, - &hv_kvp_dev, - &hv_kvp_cdevsw, - 0, - UID_ROOT, - GID_WHEEL, - 0640, - "hv_kvp_dev"); - - if (error != 0) - return (error); - + hv_kvp_sc *sc = (hv_kvp_sc*)context; /* - * Malloc with M_WAITOK flag will never fail. - */ - hv_kvp_dev_buf = malloc(sizeof(*hv_kvp_dev_buf), M_HV_KVP_DEV_BUF, M_WAITOK | - M_ZERO); - - return (0); -} - - -/* - * This function is called by the hv_kvp_deinit - - * destroy character device - */ -static void -hv_kvp_dev_destroy(void) -{ - - if (daemon_task != NULL) { - PROC_LOCK(daemon_task); - kern_psignal(daemon_task, SIGKILL); - PROC_UNLOCK(daemon_task); + The first request from host will not be handled until daemon is registered. + when callback is triggered without a registered daemon, callback just return. + When a new daemon gets regsitered, this callbcak is trigged from _write op. + */ + if (sc->register_done) { + hv_kvp_log_info("%s: Queuing work item\n", __func__); + taskqueue_enqueue(taskqueue_thread, &sc->task); } - - destroy_dev(hv_kvp_dev); - free(hv_kvp_dev_buf, M_HV_KVP_DEV_BUF); - return; } - static int hv_kvp_dev_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { - + hv_kvp_sc *sc = (hv_kvp_sc*)dev->si_drv1; + hv_kvp_log_info("%s: Opened device \"hv_kvp_device\" successfully.\n", __func__); - if (kvp_globals.dev_accessed) + if (sc->dev_accessed) return (-EBUSY); - - daemon_task = curproc; - kvp_globals.dev_accessed = true; - kvp_globals.daemon_busy = false; + + sc->daemon_task = curproc; + sc->dev_accessed = true; + sc->daemon_busy = false; return (0); } @@ -844,10 +762,11 @@ static int hv_kvp_dev_close(struct cdev *dev __unused, int fflag __unused, int devtype __unused, struct thread *td __unused) { + hv_kvp_sc *sc = (hv_kvp_sc*)dev->si_drv1; hv_kvp_log_info("%s: Closing device \"hv_kvp_device\".\n", __func__); - kvp_globals.dev_accessed = false; - kvp_globals.register_done = false; + sc->dev_accessed = false; + sc->register_done = false; return (0); } @@ -857,18 +776,21 @@ hv_kvp_dev_close(struct cdev *dev __unus * acts as a send to daemon */ static int -hv_kvp_dev_daemon_read(struct cdev *dev __unused, struct uio *uio, int ioflag __unused) +hv_kvp_dev_daemon_read(struct cdev *dev, struct uio *uio, int ioflag __unused) { size_t amt; int error = 0; + struct hv_kvp_msg *hv_kvp_dev_buf; + hv_kvp_sc *sc = (hv_kvp_sc*)dev->si_drv1; /* Check hv_kvp daemon registration status*/ - if (!kvp_globals.register_done) + if (!sc->register_done) return (KVP_ERROR); - sema_wait(&kvp_globals.dev_sema); + sema_wait(&sc->dev_sema); - memcpy(hv_kvp_dev_buf, &kvp_globals.daemon_kvp_msg, sizeof(struct hv_kvp_msg)); + hv_kvp_dev_buf = malloc(sizeof(*hv_kvp_dev_buf), M_TEMP, M_WAITOK); + memcpy(hv_kvp_dev_buf, &sc->daemon_kvp_msg, sizeof(struct hv_kvp_msg)); amt = MIN(uio->uio_resid, uio->uio_offset >= BUFFERSIZE + 1 ? 0 : BUFFERSIZE + 1 - uio->uio_offset); @@ -876,6 +798,7 @@ hv_kvp_dev_daemon_read(struct cdev *dev if ((error = uiomove(hv_kvp_dev_buf, amt, uio)) != 0) hv_kvp_log_info("%s: hv_kvp uiomove read failed!\n", __func__); + free(hv_kvp_dev_buf, M_TEMP); return (error); } @@ -885,29 +808,30 @@ hv_kvp_dev_daemon_read(struct cdev *dev * acts as a recieve from daemon */ static int -hv_kvp_dev_daemon_write(struct cdev *dev __unused, struct uio *uio, int ioflag __unused) +hv_kvp_dev_daemon_write(struct cdev *dev, struct uio *uio, int ioflag __unused) { size_t amt; int error = 0; + struct hv_kvp_msg *hv_kvp_dev_buf; + hv_kvp_sc *sc = (hv_kvp_sc*)dev->si_drv1; uio->uio_offset = 0; + hv_kvp_dev_buf = malloc(sizeof(*hv_kvp_dev_buf), M_TEMP, M_WAITOK); amt = MIN(uio->uio_resid, BUFFERSIZE); error = uiomove(hv_kvp_dev_buf, amt, uio); - if (error != 0) + if (error != 0) { + free(hv_kvp_dev_buf, M_TEMP); return (error); + } + memcpy(&sc->daemon_kvp_msg, hv_kvp_dev_buf, sizeof(struct hv_kvp_msg)); - memcpy(&kvp_globals.daemon_kvp_msg, hv_kvp_dev_buf, sizeof(struct hv_kvp_msg)); - - if (kvp_globals.register_done == false) { - if (kvp_globals.daemon_kvp_msg.kvp_hdr.operation == HV_KVP_OP_REGISTER) { - - kvp_globals.register_done = true; - if (kvp_globals.channelp) { - - hv_kvp_callback(kvp_globals.channelp); - } + free(hv_kvp_dev_buf, M_TEMP); + if (sc->register_done == false) { + if (sc->daemon_kvp_msg.kvp_hdr.operation == HV_KVP_OP_REGISTER) { + sc->register_done = true; + hv_kvp_callback(dev->si_drv1); } else { hv_kvp_log_info("%s, KVP Registration Failed\n", __func__); @@ -915,18 +839,20 @@ hv_kvp_dev_daemon_write(struct cdev *dev } } else { - mtx_lock(&kvp_globals.pending_mutex); + mtx_lock(&sc->pending_mutex); - if(!kvp_globals.req_timed_out) { - - hv_kvp_convert_usermsg_to_hostmsg(); - hv_kvp_respond_host(KVP_SUCCESS); - wakeup(&kvp_globals); - kvp_globals.req_in_progress = false; + if(!sc->req_timed_out) { + struct hv_kvp_msg *hmsg = sc->host_kvp_msg; + struct hv_kvp_msg *umsg = &sc->daemon_kvp_msg; + + hv_kvp_convert_usermsg_to_hostmsg(umsg, hmsg); + hv_kvp_respond_host(sc, KVP_SUCCESS); + wakeup(sc); + sc->req_in_progress = false; } - kvp_globals.daemon_busy = false; - mtx_unlock(&kvp_globals.pending_mutex); + sc->daemon_busy = false; + mtx_unlock(&sc->pending_mutex); } return (error); @@ -938,53 +864,106 @@ hv_kvp_dev_daemon_write(struct cdev *dev * for daemon to read. */ static int -hv_kvp_dev_daemon_poll(struct cdev *dev __unused, int events, struct thread *td) +hv_kvp_dev_daemon_poll(struct cdev *dev, int events, struct thread *td) { int revents = 0; + hv_kvp_sc *sc = (hv_kvp_sc*)dev->si_drv1; - mtx_lock(&kvp_globals.pending_mutex); + mtx_lock(&sc->pending_mutex); /* * We check global flag daemon_busy for the data availiability for * userland to read. Deamon_busy is set to true before driver has data * for daemon to read. It is set to false after daemon sends * then response back to driver. */ - if (kvp_globals.daemon_busy == true) + if (sc->daemon_busy == true) revents = POLLIN; else - selrecord(td, &hv_kvp_selinfo); + selrecord(td, &sc->hv_kvp_selinfo); - mtx_unlock(&kvp_globals.pending_mutex); + mtx_unlock(&sc->pending_mutex); return (revents); } +static int +hv_kvp_probe(device_t dev) +{ + const char *p = vmbus_get_type(dev); + if (!memcmp(p, &service_guid, sizeof(hv_guid))) { + device_set_desc(dev, "Hyper-V KVP Service"); + return BUS_PROBE_DEFAULT; + } -/* - * hv_kvp initialization function - * called from hv_util service. - * - */ -int -hv_kvp_init(hv_vmbus_service *srv) + return ENXIO; +} + +static int +hv_kvp_attach(device_t dev) { - int error = 0; + int error; + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; - memset(&kvp_globals, 0, sizeof(kvp_globals)); + hv_kvp_sc *sc = (hv_kvp_sc*)device_get_softc(dev); - error = hv_kvp_dev_init(); - mtx_init(&kvp_globals.pending_mutex, "hv-kvp pending mutex", + sc->util_sc.callback = hv_kvp_callback; + sema_init(&sc->dev_sema, 0, "hv_kvp device semaphore"); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:39:45 2016 Return-Path: Delivered-To: svn-src-stable-10@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 16824B72622; Wed, 15 Jun 2016 01:39:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 DB5572987; Wed, 15 Jun 2016 01:39:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1diTX014901; Wed, 15 Jun 2016 01:39:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1di2R014900; Wed, 15 Jun 2016 01:39:44 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201606150139.u5F1di2R014900@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 15 Jun 2016 01:39:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301902 - stable/10/sys/dev/ntb/if_ntb X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:39:45 -0000 Author: mav Date: Wed Jun 15 01:39:43 2016 New Revision: 301902 URL: https://svnweb.freebsd.org/changeset/base/301902 Log: MFC r300610: Re-enable write combining, disabled by default at r295486. if_ntb(4) strongly benefits from WC, improving throughput from 350Mbit/s to 8-10Gbit/s on my tests. Modified: stable/10/sys/dev/ntb/if_ntb/if_ntb.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/ntb/if_ntb/if_ntb.c ============================================================================== --- stable/10/sys/dev/ntb/if_ntb/if_ntb.c Tue Jun 14 23:58:02 2016 (r301901) +++ stable/10/sys/dev/ntb/if_ntb/if_ntb.c Wed Jun 15 01:39:43 2016 (r301902) @@ -621,6 +621,10 @@ ntb_transport_probe(struct ntb_softc *nt mw->xlat_size = 0; mw->virt_addr = NULL; mw->dma_addr = 0; + + rc = ntb_mw_set_wc(nt->ntb, i, VM_MEMATTR_WRITE_COMBINING); + if (rc) + ntb_printf(0, "Unable to set mw%d caching\n", i); } qp_bitmap = ntb_db_valid_mask(ntb); From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:41:44 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E739EB72733; Wed, 15 Jun 2016 01:41:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 B83182DA4; Wed, 15 Jun 2016 01:41:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1fhmM016268; Wed, 15 Jun 2016 01:41:43 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1fhLr016267; Wed, 15 Jun 2016 01:41:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201606150141.u5F1fhLr016267@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 15 Jun 2016 01:41:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301903 - stable/10/sys/dev/ntb/ntb_hw X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:41:45 -0000 Author: mav Date: Wed Jun 15 01:41:43 2016 New Revision: 301903 URL: https://svnweb.freebsd.org/changeset/base/301903 Log: MFC r301292: When negotiating MSIX parameters, give other head time to see our NTB_MSIX_RECEIVED status, before making upper layers overwrite it. This is not completely perfect, but now it works better then before. Sponsored by: iXsystems, Inc. Modified: stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c Wed Jun 15 01:39:43 2016 (r301902) +++ stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c Wed Jun 15 01:41:43 2016 (r301903) @@ -2820,6 +2820,8 @@ ntb_exchange_msix(void *ctx) ntb = ctx; + if (ntb->peer_msix_good) + goto msix_good; if (ntb->peer_msix_done) goto msix_done; @@ -2851,16 +2853,21 @@ msix_done: goto reschedule; ntb->peer_msix_good = true; + /* Give peer time to see our NTB_MSIX_RECEIVED. */ + goto reschedule; +msix_good: ntb_poll_link(ntb); ntb_link_event(ntb); return; reschedule: ntb->lnk_sta = pci_read_config(ntb->device, ntb->reg->lnk_sta, 2); - if (_xeon_link_is_up(ntb)) - callout_reset(&ntb->peer_msix_work, hz / 100, ntb_exchange_msix, ntb); - else + if (_xeon_link_is_up(ntb)) { + callout_reset(&ntb->peer_msix_work, + hz * (ntb->peer_msix_good ? 2 : 1) / 100, + ntb_exchange_msix, ntb); + } else ntb_spad_clear(ntb); } From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:42:54 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E26D4B72872; Wed, 15 Jun 2016 01:42:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A1EC12F93; Wed, 15 Jun 2016 01:42:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1grwX018524; Wed, 15 Jun 2016 01:42:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1grIs018523; Wed, 15 Jun 2016 01:42:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201606150142.u5F1grIs018523@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 15 Jun 2016 01:42:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301904 - stable/10/sys/dev/ntb/ntb_hw X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:42:55 -0000 Author: mav Date: Wed Jun 15 01:42:53 2016 New Revision: 301904 URL: https://svnweb.freebsd.org/changeset/base/301904 Log: MFC r301293: When negotiating NTB_SB01BASE_LOCKUP workaround, don't try to limit the BAR size to 1MB. According to Xeon v3 specifications and my tests, that size register is write-once and so not writeable after BIOS written it. Instead of that, make the code work with BAR of any sufficient size, properly calculating offset within its base. It also simplifies the code. Sponsored by: iXsystems, Inc. Modified: stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c Wed Jun 15 01:41:43 2016 (r301903) +++ stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c Wed Jun 15 01:42:53 2016 (r301904) @@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$"); #define NTB_MSIX_VER_GUARD 0xaabbccdd #define NTB_MSIX_RECEIVED 0xe0f0e0f0 -#define ONE_MB (1024u * 1024) /* * PCI constants could be somewhere more generic, but aren't defined/used in @@ -239,6 +238,7 @@ struct ntb_softc { /* Memory window used to access peer bar0 */ #define B2B_MW_DISABLED UINT8_MAX uint8_t b2b_mw_idx; + uint32_t msix_xlat; uint8_t msix_mw_idx; uint8_t mw_count; @@ -1375,12 +1375,12 @@ ntb_get_msix_info(struct ntb_softc *ntb) laddr = bus_read_4(msix->msix_table_res, offset + PCI_MSIX_ENTRY_LOWER_ADDR); - ntb_printf(2, "local lower MSIX addr(%u): 0x%x\n", i, laddr); + ntb_printf(2, "local MSIX addr(%u): 0x%x\n", i, laddr); KASSERT((laddr & MSI_INTEL_ADDR_BASE) == MSI_INTEL_ADDR_BASE, ("local MSIX addr 0x%x not in MSI base 0x%x", laddr, MSI_INTEL_ADDR_BASE)); - ntb->msix_data[i].nmd_ofs = laddr & ~MSI_INTEL_ADDR_BASE; + ntb->msix_data[i].nmd_ofs = laddr; data = bus_read_4(msix->msix_table_res, offset + PCI_MSIX_ENTRY_DATA); @@ -1674,15 +1674,6 @@ xeon_reset_sbar_size(struct ntb_softc *n bar_sz--; else bar_sz = 0; - } else if (HAS_FEATURE(NTB_SB01BASE_LOCKUP) && - ntb_mw_to_bar(ntb, ntb->msix_mw_idx) == idx) { - /* Restrict LAPIC BAR to 1MB */ - pci_write_config(ntb->device, bar->psz_off, 20, 1); - pci_write_config(ntb->device, bar->ssz_off, 20, 1); - bar_sz = pci_read_config(ntb->device, bar->psz_off, 1); - bar_sz = pci_read_config(ntb->device, bar->ssz_off, 1); - (void)bar_sz; - return; } pci_write_config(ntb->device, bar->ssz_off, bar_sz, 1); bar_sz = pci_read_config(ntb->device, bar->ssz_off, 1); @@ -1693,24 +1684,19 @@ static void xeon_set_sbar_base_and_limit(struct ntb_softc *ntb, uint64_t bar_addr, enum ntb_bar idx, enum ntb_bar regbar) { - uint64_t reg_val, lmt_addr; + uint64_t reg_val; uint32_t base_reg, lmt_reg; bar_get_xlat_params(ntb, idx, &base_reg, NULL, &lmt_reg); if (idx == regbar) bar_addr += ntb->b2b_off; - lmt_addr = bar_addr; - - if (HAS_FEATURE(NTB_SB01BASE_LOCKUP) && - ntb_mw_to_bar(ntb, ntb->msix_mw_idx) == idx) - lmt_addr += ONE_MB; /* * Set limit registers first to avoid an errata where setting the base * registers locks the limit registers. */ if (!bar_is_64bit(ntb, idx)) { - ntb_reg_write(4, lmt_reg, lmt_addr); + ntb_reg_write(4, lmt_reg, bar_addr); reg_val = ntb_reg_read(4, lmt_reg); (void)reg_val; @@ -1718,7 +1704,7 @@ xeon_set_sbar_base_and_limit(struct ntb_ reg_val = ntb_reg_read(4, base_reg); (void)reg_val; } else { - ntb_reg_write(8, lmt_reg, lmt_addr); + ntb_reg_write(8, lmt_reg, bar_addr); reg_val = ntb_reg_read(8, lmt_reg); (void)reg_val; @@ -1747,31 +1733,13 @@ xeon_set_pbar_xlat(struct ntb_softc *ntb static int xeon_setup_msix_bar(struct ntb_softc *ntb) { - struct ntb_pci_bar_info *lapic_bar; enum ntb_bar bar_num; - int rc; if (!HAS_FEATURE(NTB_SB01BASE_LOCKUP)) return (0); bar_num = ntb_mw_to_bar(ntb, ntb->msix_mw_idx); - lapic_bar = &ntb->bar_info[bar_num]; - - /* Restrict LAPIC BAR to 1MB */ - if (lapic_bar->size > ONE_MB) { - rc = bus_adjust_resource(ntb->device, SYS_RES_MEMORY, - lapic_bar->pci_resource, lapic_bar->pbase, - lapic_bar->pbase + ONE_MB - 1); - if (rc == 0) - lapic_bar->size = ONE_MB; - else { - ntb_printf(0, "Failed to shrink LAPIC BAR resource to " - "1 MB: %d\n", rc); - /* Ignore error */ - } - } - - ntb->peer_lapic_bar = lapic_bar; + ntb->peer_lapic_bar = &ntb->bar_info[bar_num]; return (0); } @@ -1882,10 +1850,13 @@ xeon_setup_b2b_mw(struct ntb_softc *ntb, * We point the chosen MSIX MW BAR xlat to remote LAPIC for * workaround */ - if (size == 4) + if (size == 4) { ntb_reg_write(4, xlatoffset, MSI_INTEL_ADDR_BASE); - else + ntb->msix_xlat = ntb_reg_read(4, xlatoffset); + } else { ntb_reg_write(8, xlatoffset, MSI_INTEL_ADDR_BASE); + ntb->msix_xlat = ntb_reg_read(8, xlatoffset); + } } (void)ntb_reg_read(8, XEON_SBAR2XLAT_OFFSET); (void)ntb_reg_read(8, XEON_SBAR4XLAT_OFFSET); @@ -2829,7 +2800,7 @@ ntb_exchange_msix(void *ctx) ntb_peer_spad_write(ntb, NTB_MSIX_DATA0 + i, ntb->msix_data[i].nmd_data); ntb_peer_spad_write(ntb, NTB_MSIX_OFS0 + i, - ntb->msix_data[i].nmd_ofs); + ntb->msix_data[i].nmd_ofs - ntb->msix_xlat); } ntb_peer_spad_write(ntb, NTB_MSIX_GUARD, NTB_MSIX_VER_GUARD); @@ -2839,8 +2810,10 @@ ntb_exchange_msix(void *ctx) for (i = 0; i < XEON_NONLINK_DB_MSIX_BITS; i++) { ntb_spad_read(ntb, NTB_MSIX_DATA0 + i, &val); + ntb_printf(2, "remote MSIX data(%u): 0x%x\n", i, val); ntb->peer_msix_data[i].nmd_data = val; ntb_spad_read(ntb, NTB_MSIX_OFS0 + i, &val); + ntb_printf(2, "remote MSIX addr(%u): 0x%x\n", i, val); ntb->peer_msix_data[i].nmd_ofs = val; } From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:49:02 2016 Return-Path: Delivered-To: svn-src-stable-10@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 E653FB72941; Wed, 15 Jun 2016 01:49:02 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C30152210; Wed, 15 Jun 2016 01:49:02 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1n2rU018855; Wed, 15 Jun 2016 01:49:02 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1n1eT018853; Wed, 15 Jun 2016 01:49:01 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201606150149.u5F1n1eT018853@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Wed, 15 Jun 2016 01:49:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301905 - in stable/10: lib/libc/sys sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:49:03 -0000 Author: jamie Date: Wed Jun 15 01:49:01 2016 New Revision: 301905 URL: https://svnweb.freebsd.org/changeset/base/301905 Log: MFC r300983: Mark jail(2), and the sysctls that it (and only it) uses as deprecated. jail(8) has long used jail_set(2), and those sysctl only cause confusion. Modified: stable/10/lib/libc/sys/jail.2 stable/10/sys/kern/kern_jail.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/sys/jail.2 ============================================================================== --- stable/10/lib/libc/sys/jail.2 Wed Jun 15 01:42:53 2016 (r301904) +++ stable/10/lib/libc/sys/jail.2 Wed Jun 15 01:49:01 2016 (r301905) @@ -106,7 +106,7 @@ pointers can be set to an arrays of IPv4 the prison, or NULL if none. IPv4 addresses must be in network byte order. .Pp -This is equivalent to the +This is equivalent to, and deprecated in favor of, the .Fn jail_set system call (see below), with the parameters .Va path , Modified: stable/10/sys/kern/kern_jail.c ============================================================================== --- stable/10/sys/kern/kern_jail.c Wed Jun 15 01:42:53 2016 (r301904) +++ stable/10/sys/kern/kern_jail.c Wed Jun 15 01:49:01 2016 (r301905) @@ -4306,7 +4306,7 @@ SYSCTL_PROC(_security_jail, OID_AUTO, vn #if defined(INET) || defined(INET6) SYSCTL_UINT(_security_jail, OID_AUTO, jail_max_af_ips, CTLFLAG_RW, &jail_max_af_ips, 0, - "Number of IP addresses a jail may have at most per address family"); + "Number of IP addresses a jail may have at most per address family (deprecated)"); #endif /* @@ -4346,59 +4346,59 @@ sysctl_jail_default_allow(SYSCTL_HANDLER SYSCTL_PROC(_security_jail, OID_AUTO, set_hostname_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_SET_HOSTNAME, sysctl_jail_default_allow, "I", - "Processes in jail can set their hostnames"); + "Processes in jail can set their hostnames (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, socket_unixiproute_only, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, (void *)1, PR_ALLOW_SOCKET_AF, sysctl_jail_default_allow, "I", - "Processes in jail are limited to creating UNIX/IP/route sockets only"); + "Processes in jail are limited to creating UNIX/IP/route sockets only (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, sysvipc_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_SYSVIPC, sysctl_jail_default_allow, "I", - "Processes in jail can use System V IPC primitives"); + "Processes in jail can use System V IPC primitives (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, allow_raw_sockets, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_RAW_SOCKETS, sysctl_jail_default_allow, "I", - "Prison root can create raw sockets"); + "Prison root can create raw sockets (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, chflags_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_CHFLAGS, sysctl_jail_default_allow, "I", - "Processes in jail can alter system file flags"); + "Processes in jail can alter system file flags (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT, sysctl_jail_default_allow, "I", - "Processes in jail can mount/unmount jail-friendly file systems"); + "Processes in jail can mount/unmount jail-friendly file systems (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_devfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_DEVFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount the devfs file system"); + "Processes in jail can mount the devfs file system (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_fdescfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_FDESCFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount the fdescfs file system"); + "Processes in jail can mount the fdescfs file system (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_nullfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_NULLFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount the nullfs file system"); + "Processes in jail can mount the nullfs file system (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_procfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_PROCFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount the procfs file system"); + "Processes in jail can mount the procfs file system (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_linprocfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_LINPROCFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount the linprocfs file system"); + "Processes in jail can mount the linprocfs file system (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_linsysfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_LINSYSFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount the linsysfs file system"); + "Processes in jail can mount the linsysfs file system (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_tmpfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_TMPFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount the tmpfs file system"); + "Processes in jail can mount the tmpfs file system (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_zfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_ZFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount the zfs file system"); + "Processes in jail can mount the zfs file system (deprecated)"); static int sysctl_jail_default_level(SYSCTL_HANDLER_ARGS) @@ -4419,13 +4419,13 @@ SYSCTL_PROC(_security_jail, OID_AUTO, en CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &jail_default_enforce_statfs, offsetof(struct prison, pr_enforce_statfs), sysctl_jail_default_level, "I", - "Processes in jail cannot see all mounted file systems"); + "Processes in jail cannot see all mounted file systems (deprecated)"); SYSCTL_PROC(_security_jail, OID_AUTO, devfs_ruleset, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &jail_default_devfs_rsnum, offsetof(struct prison, pr_devfs_rsnum), sysctl_jail_default_level, "I", - "Ruleset for the devfs filesystem in jail"); + "Ruleset for the devfs filesystem in jail (deprecated)"); /* * Nodes to describe jail parameters. Maximum length of string parameters From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:54:18 2016 Return-Path: Delivered-To: svn-src-stable-10@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 A8FAFB72B8F; Wed, 15 Jun 2016 01:54:18 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7B1B92846; Wed, 15 Jun 2016 01:54:18 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1sHCl022291; Wed, 15 Jun 2016 01:54:17 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1sH8F022290; Wed, 15 Jun 2016 01:54:17 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201606150154.u5F1sH8F022290@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Wed, 15 Jun 2016 01:54:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301906 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:54:18 -0000 Author: jamie Date: Wed Jun 15 01:54:17 2016 New Revision: 301906 URL: https://svnweb.freebsd.org/changeset/base/301906 Log: MFC r301737: Remove a comment that was part of copied code, and is misleading in the new location. Modified: stable/10/sys/kern/sysv_msg.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/sysv_msg.c ============================================================================== --- stable/10/sys/kern/sysv_msg.c Wed Jun 15 01:49:01 2016 (r301905) +++ stable/10/sys/kern/sysv_msg.c Wed Jun 15 01:54:17 2016 (r301906) @@ -326,12 +326,6 @@ msgunload() #endif for (msqid = 0; msqid < msginfo.msgmni; msqid++) { - /* - * Look for an unallocated and unlocked msqid_ds. - * msqid_ds's can be locked by msgsnd or msgrcv while - * they are copying the message in/out. We can't - * re-use the entry until they release it. - */ msqkptr = &msqids[msqid]; if (msqkptr->u.msg_qbytes != 0 || (msqkptr->u.msg_perm.mode & MSG_LOCKED) != 0) From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:56:21 2016 Return-Path: Delivered-To: svn-src-stable-10@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 63435B72C3E; Wed, 15 Jun 2016 01:56:21 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 17EFD29CC; Wed, 15 Jun 2016 01:56:21 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1uKQ2022431; Wed, 15 Jun 2016 01:56:20 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1uKEq022430; Wed, 15 Jun 2016 01:56:20 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201606150156.u5F1uKEq022430@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Wed, 15 Jun 2016 01:56:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301907 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:56:21 -0000 Author: jamie Date: Wed Jun 15 01:56:20 2016 New Revision: 301907 URL: https://svnweb.freebsd.org/changeset/base/301907 Log: MFC r301745: Make sure the OSD methods for jail set and remove can't run concurrently, by holding allprison_lock exclusively (even if only for a moment before downgrading) on all paths that call PR_METHOD_REMOVE. Since they may run on a downgraded lock, it's still possible for them to run concurrently with PR_METHOD_GET, which will need to use the prison lock. Modified: stable/10/sys/kern/kern_jail.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_jail.c ============================================================================== --- stable/10/sys/kern/kern_jail.c Wed Jun 15 01:54:17 2016 (r301906) +++ stable/10/sys/kern/kern_jail.c Wed Jun 15 01:56:20 2016 (r301907) @@ -2400,7 +2400,14 @@ sys_jail_attach(struct thread *td, struc if (error) return (error); - sx_slock(&allprison_lock); + /* + * Start with exclusive hold on allprison_lock to ensure that a possible + * PR_METHOD_REMOVE call isn't concurrent with jail_set or jail_remove. + * But then immediately downgrade it since we don't need to stop + * readers. + */ + sx_xlock(&allprison_lock); + sx_downgrade(&allprison_lock); pr = prison_find_child(td->td_ucred->cr_prison, uap->jid); if (pr == NULL) { sx_sunlock(&allprison_lock); @@ -2618,9 +2625,11 @@ prison_complete(void *context, int pendi { struct prison *pr = context; + sx_xlock(&allprison_lock); mtx_lock(&pr->pr_mtx); prison_deref(pr, pr->pr_uref - ? PD_DEREF | PD_DEUREF | PD_LOCKED : PD_LOCKED); + ? PD_DEREF | PD_DEUREF | PD_LOCKED | PD_LIST_XLOCKED + : PD_LOCKED | PD_LIST_XLOCKED); } /* @@ -2664,13 +2673,8 @@ prison_deref(struct prison *pr, int flag */ if (lasturef) { if (!(flags & (PD_LIST_SLOCKED | PD_LIST_XLOCKED))) { - if (ref > 1) { - sx_slock(&allprison_lock); - flags |= PD_LIST_SLOCKED; - } else { - sx_xlock(&allprison_lock); - flags |= PD_LIST_XLOCKED; - } + sx_xlock(&allprison_lock); + flags |= PD_LIST_XLOCKED; } (void)osd_jail_call(pr, PR_METHOD_REMOVE, NULL); mtx_lock(&pr->pr_mtx); From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:57:23 2016 Return-Path: Delivered-To: svn-src-stable-10@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 D83F1B72CC3; Wed, 15 Jun 2016 01:57:23 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A56B22B72; Wed, 15 Jun 2016 01:57:23 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1vMtJ022518; Wed, 15 Jun 2016 01:57:22 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1vMbb022517; Wed, 15 Jun 2016 01:57:22 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201606150157.u5F1vMbb022517@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Wed, 15 Jun 2016 01:57:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301908 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:57:23 -0000 Author: jamie Date: Wed Jun 15 01:57:22 2016 New Revision: 301908 URL: https://svnweb.freebsd.org/changeset/base/301908 Log: MFC r301758: Clean up some logic in jail error messages, replacing a missing test and a redundant test with a single correct test. Modified: stable/10/sys/kern/kern_jail.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_jail.c ============================================================================== --- stable/10/sys/kern/kern_jail.c Wed Jun 15 01:56:20 2016 (r301907) +++ stable/10/sys/kern/kern_jail.c Wed Jun 15 01:57:22 2016 (r301908) @@ -1943,19 +1943,17 @@ kern_jail_set(struct thread *td, struct vrele(root); done_errmsg: if (error) { - vfs_getopt(opts, "errmsg", (void **)&errmsg, &errmsg_len); - if (errmsg_len > 0) { + if (vfs_getopt(opts, "errmsg", (void **)&errmsg, + &errmsg_len) == 0 && errmsg_len > 0) { errmsg_pos = 2 * vfs_getopt_pos(opts, "errmsg") + 1; - if (errmsg_pos > 0) { - if (optuio->uio_segflg == UIO_SYSSPACE) - bcopy(errmsg, - optuio->uio_iov[errmsg_pos].iov_base, - errmsg_len); - else - copyout(errmsg, - optuio->uio_iov[errmsg_pos].iov_base, - errmsg_len); - } + if (optuio->uio_segflg == UIO_SYSSPACE) + bcopy(errmsg, + optuio->uio_iov[errmsg_pos].iov_base, + errmsg_len); + else + copyout(errmsg, + optuio->uio_iov[errmsg_pos].iov_base, + errmsg_len); } } done_free: From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:58:55 2016 Return-Path: Delivered-To: svn-src-stable-10@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 6FD0EB72D3E; Wed, 15 Jun 2016 01:58:55 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 3231D2CEA; Wed, 15 Jun 2016 01:58:55 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1wsUN022631; Wed, 15 Jun 2016 01:58:54 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1wsiJ022630; Wed, 15 Jun 2016 01:58:54 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201606150158.u5F1wsiJ022630@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Wed, 15 Jun 2016 01:58:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301909 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:58:55 -0000 Author: jamie Date: Wed Jun 15 01:58:54 2016 New Revision: 301909 URL: https://svnweb.freebsd.org/changeset/base/301909 Log: MFC r301760: Re-order some jail parameter reading to prevent a vnode leak. Modified: stable/10/sys/kern/kern_jail.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_jail.c ============================================================================== --- stable/10/sys/kern/kern_jail.c Wed Jun 15 01:57:22 2016 (r301908) +++ stable/10/sys/kern/kern_jail.c Wed Jun 15 01:58:54 2016 (r301909) @@ -932,6 +932,46 @@ kern_jail_set(struct thread *td, struct } #endif + error = vfs_getopt(opts, "osrelease", (void **)&osrelstr, &len); + if (error == ENOENT) + osrelstr = NULL; + else if (error != 0) + goto done_free; + else { + if (flags & JAIL_UPDATE) { + error = EINVAL; + vfs_opterror(opts, + "osrelease cannot be changed after creation"); + goto done_errmsg; + } + if (len == 0 || len >= OSRELEASELEN) { + error = EINVAL; + vfs_opterror(opts, + "osrelease string must be 1-%d bytes long", + OSRELEASELEN - 1); + goto done_errmsg; + } + } + + error = vfs_copyopt(opts, "osreldate", &osreldt, sizeof(osreldt)); + if (error == ENOENT) + osreldt = 0; + else if (error != 0) + goto done_free; + else { + if (flags & JAIL_UPDATE) { + error = EINVAL; + vfs_opterror(opts, + "osreldate cannot be changed after creation"); + goto done_errmsg; + } + if (osreldt == 0) { + error = EINVAL; + vfs_opterror(opts, "osreldate cannot be 0"); + goto done_errmsg; + } + } + fullpath_disabled = 0; root = NULL; error = vfs_getopt(opts, "path", (void **)&path, &len); @@ -987,46 +1027,6 @@ kern_jail_set(struct thread *td, struct } } - error = vfs_getopt(opts, "osrelease", (void **)&osrelstr, &len); - if (error == ENOENT) - osrelstr = NULL; - else if (error != 0) - goto done_free; - else { - if (flags & JAIL_UPDATE) { - error = EINVAL; - vfs_opterror(opts, - "osrelease cannot be changed after creation"); - goto done_errmsg; - } - if (len == 0 || len >= OSRELEASELEN) { - error = EINVAL; - vfs_opterror(opts, - "osrelease string must be 1-%d bytes long", - OSRELEASELEN - 1); - goto done_errmsg; - } - } - - error = vfs_copyopt(opts, "osreldate", &osreldt, sizeof(osreldt)); - if (error == ENOENT) - osreldt = 0; - else if (error != 0) - goto done_free; - else { - if (flags & JAIL_UPDATE) { - error = EINVAL; - vfs_opterror(opts, - "osreldate cannot be changed after creation"); - goto done_errmsg; - } - if (osreldt == 0) { - error = EINVAL; - vfs_opterror(opts, "osreldate cannot be 0"); - goto done_errmsg; - } - } - /* * Find the specified jail, or at least its parent. * This abuses the file error codes ENOENT and EEXIST. From owner-svn-src-stable-10@freebsd.org Wed Jun 15 01:59:56 2016 Return-Path: Delivered-To: svn-src-stable-10@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 80F47B72DA1; Wed, 15 Jun 2016 01:59:56 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 4EA1C2E51; Wed, 15 Jun 2016 01:59:56 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F1xt1r022718; Wed, 15 Jun 2016 01:59:55 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F1xtxh022717; Wed, 15 Jun 2016 01:59:55 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201606150159.u5F1xtxh022717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Wed, 15 Jun 2016 01:59:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301910 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 01:59:56 -0000 Author: jamie Date: Wed Jun 15 01:59:55 2016 New Revision: 301910 URL: https://svnweb.freebsd.org/changeset/base/301910 Log: MFC r301764: Fix a vnode leak when giving a child jail a too-long path when debug.disablefullpath=1. Modified: stable/10/sys/kern/kern_jail.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_jail.c ============================================================================== --- stable/10/sys/kern/kern_jail.c Wed Jun 15 01:58:54 2016 (r301909) +++ stable/10/sys/kern/kern_jail.c Wed Jun 15 01:59:55 2016 (r301910) @@ -1022,6 +1022,7 @@ kern_jail_set(struct thread *td, struct if (len + (path[0] == '/' && strcmp(mypr->pr_path, "/") ? strlen(mypr->pr_path) : 0) > MAXPATHLEN) { error = ENAMETOOLONG; + vrele(root); goto done_free; } } From owner-svn-src-stable-10@freebsd.org Wed Jun 15 03:17:07 2016 Return-Path: Delivered-To: svn-src-stable-10@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 20ABAB728A0; Wed, 15 Jun 2016 03:17:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F19982FEB; Wed, 15 Jun 2016 03:17:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F3H6ii051850; Wed, 15 Jun 2016 03:17:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F3H5gT051847; Wed, 15 Jun 2016 03:17:05 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150317.u5F3H5gT051847@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 03:17:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301911 - in stable/10/sys/dev/hyperv: netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 03:17:07 -0000 Author: sephe Date: Wed Jun 15 03:17:05 2016 New Revision: 301911 URL: https://svnweb.freebsd.org/changeset/base/301911 Log: MFC 296022,296024,296076 296022 hyperv/hn: Implement ifnet.if_transmit method It will be turned on by default later. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5415 296024 hyperv/hn: Hold the TX ring lock then drain TX desc buf_ring Reported by: Hongxiong Xian MFC after: 1 week Sponsored by: Microsoft OSTC 296076 hyperv: Use atomic_fetchadd_int to get GPADL id. Reviewed by: Hongjiang Zhang MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5439 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Jun 15 01:59:55 2016 (r301910) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Jun 15 03:17:05 2016 (r301911) @@ -1034,6 +1034,9 @@ struct hn_tx_ring { struct task hn_tx_task; struct task hn_txeof_task; + struct buf_ring *hn_mbuf_br; + int hn_oactive; + struct mtx hn_tx_lock; struct hn_softc *hn_sc; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Jun 15 01:59:55 2016 (r301910) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Jun 15 03:17:05 2016 (r301911) @@ -274,6 +274,10 @@ static int hn_bind_tx_taskq = -1; SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN, &hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu"); +static int hn_use_if_start = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN, + &hn_use_if_start, 0, "Use if_start TX method"); + /* * Forward declarations */ @@ -313,6 +317,13 @@ static void hn_create_rx_data(struct hn_ static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_tx_chimney_size(struct hn_softc *, int); +static int hn_transmit(struct ifnet *, struct mbuf *); +static void hn_xmit_qflush(struct ifnet *); +static int hn_xmit(struct hn_tx_ring *, int); +static void hn_xmit_txeof(struct hn_tx_ring *); +static void hn_xmit_taskfunc(void *, int); +static void hn_xmit_txeof_taskfunc(void *, int); + static int hn_ifmedia_upd(struct ifnet *ifp __unused) { @@ -444,13 +455,18 @@ netvsc_attach(device_t dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; - ifp->if_start = hn_start; ifp->if_init = hn_ifinit; /* needed by hv_rf_on_device_add() code */ ifp->if_mtu = ETHERMTU; - IFQ_SET_MAXLEN(&ifp->if_snd, 512); - ifp->if_snd.ifq_drv_maxlen = 511; - IFQ_SET_READY(&ifp->if_snd); + if (hn_use_if_start) { + ifp->if_start = hn_start; + IFQ_SET_MAXLEN(&ifp->if_snd, 512); + ifp->if_snd.ifq_drv_maxlen = 511; + IFQ_SET_READY(&ifp->if_snd); + } else { + ifp->if_transmit = hn_transmit; + ifp->if_qflush = hn_xmit_qflush; + } ifmedia_init(&sc->hn_media, 0, hn_ifmedia_upd, hn_ifmedia_sts); ifmedia_add(&sc->hn_media, IFM_ETHER | IFM_AUTO, 0, NULL); @@ -946,6 +962,12 @@ again: if (!error) { ETHER_BPF_MTAP(ifp, txd->m); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if (!hn_use_if_start) { + if_inc_counter(ifp, IFCOUNTER_OBYTES, + txd->m->m_pkthdr.len); + if (txd->m->m_flags & M_MCAST) + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); + } } hn_txdesc_put(txr, txd); @@ -998,6 +1020,8 @@ hn_start_locked(struct hn_tx_ring *txr, struct ifnet *ifp = sc->hn_ifp; struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); + KASSERT(hn_use_if_start, + ("hn_start_locked is called, when if_start is disabled")); KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); mtx_assert(&txr->hn_tx_lock, MA_OWNED); @@ -1555,7 +1579,7 @@ static void hn_stop(hn_softc_t *sc) { struct ifnet *ifp; - int ret; + int ret, i; struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); ifp = sc->hn_ifp; @@ -1565,6 +1589,9 @@ hn_stop(hn_softc_t *sc) atomic_clear_int(&ifp->if_drv_flags, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + sc->hn_tx_ring[i].hn_oactive = 0; + if_link_state_change(ifp, LINK_STATE_DOWN); sc->hn_initdone = 0; @@ -1637,7 +1664,7 @@ hn_ifinit_locked(hn_softc_t *sc) { struct ifnet *ifp; struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); - int ret; + int ret, i; ifp = sc->hn_ifp; @@ -1653,7 +1680,11 @@ hn_ifinit_locked(hn_softc_t *sc) } else { sc->hn_initdone = 1; } + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + sc->hn_tx_ring[i].hn_oactive = 0; + atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); if_link_state_change(ifp, LINK_STATE_UP); } @@ -2187,8 +2218,18 @@ hn_create_tx_ring(struct hn_softc *sc, i #endif txr->hn_tx_taskq = sc->hn_tx_taskq; - TASK_INIT(&txr->hn_tx_task, 0, hn_start_taskfunc, txr); - TASK_INIT(&txr->hn_txeof_task, 0, hn_start_txeof_taskfunc, txr); + + if (hn_use_if_start) { + txr->hn_txeof = hn_start_txeof; + TASK_INIT(&txr->hn_tx_task, 0, hn_start_taskfunc, txr); + TASK_INIT(&txr->hn_txeof_task, 0, hn_start_txeof_taskfunc, txr); + } else { + txr->hn_txeof = hn_xmit_txeof; + TASK_INIT(&txr->hn_tx_task, 0, hn_xmit_taskfunc, txr); + TASK_INIT(&txr->hn_txeof_task, 0, hn_xmit_txeof_taskfunc, txr); + txr->hn_mbuf_br = buf_ring_alloc(txr->hn_txdesc_cnt, M_NETVSC, + M_WAITOK, &txr->hn_tx_lock); + } txr->hn_direct_tx_size = hn_direct_tx_size; if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1) @@ -2202,8 +2243,6 @@ hn_create_tx_ring(struct hn_softc *sc, i */ txr->hn_sched_tx = 1; - txr->hn_txeof = hn_start_txeof; /* TODO: if_transmit */ - parent_dtag = bus_get_dma_tag(sc->hn_dev); /* DMA tag for RNDIS messages. */ @@ -2320,6 +2359,11 @@ hn_create_tx_ring(struct hn_softc *sc, i SYSCTL_ADD_INT(ctx, child, OID_AUTO, "txdesc_avail", CTLFLAG_RD, &txr->hn_txdesc_avail, 0, "# of available TX descs"); + if (!hn_use_if_start) { + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "oactive", + CTLFLAG_RD, &txr->hn_oactive, 0, + "over active"); + } } } @@ -2354,8 +2398,10 @@ hn_destroy_tx_ring(struct hn_tx_ring *tx hn_txdesc_dmamap_destroy(txd); } #else + mtx_lock(&txr->hn_tx_lock); while ((txd = buf_ring_dequeue_sc(txr->hn_txdesc_br)) != NULL) hn_txdesc_dmamap_destroy(txd); + mtx_unlock(&txr->hn_tx_lock); #endif if (txr->hn_tx_data_dtag != NULL) @@ -2370,6 +2416,9 @@ hn_destroy_tx_ring(struct hn_tx_ring *tx free(txr->hn_txdesc, M_NETVSC); txr->hn_txdesc = NULL; + if (txr->hn_mbuf_br != NULL) + buf_ring_free(txr->hn_mbuf_br, M_NETVSC); + #ifndef HN_USE_TXDESC_BUFRING mtx_destroy(&txr->hn_txlist_spin); #endif @@ -2383,7 +2432,12 @@ hn_create_tx_data(struct hn_softc *sc) struct sysctl_ctx_list *ctx; int i; - sc->hn_tx_ring_cnt = 1; /* TODO: vRSS */ + if (hn_use_if_start) { + /* ifnet.if_start only needs one TX ring */ + sc->hn_tx_ring_cnt = 1; + } else { + sc->hn_tx_ring_cnt = 1; /* TODO: vRSS */ + } sc->hn_tx_ring = malloc(sizeof(struct hn_tx_ring) * sc->hn_tx_ring_cnt, M_NETVSC, M_WAITOK | M_ZERO); @@ -2508,6 +2562,166 @@ hn_stop_tx_tasks(struct hn_softc *sc) } } +static int +hn_xmit(struct hn_tx_ring *txr, int len) +{ + struct hn_softc *sc = txr->hn_sc; + struct ifnet *ifp = sc->hn_ifp; + struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); + struct mbuf *m_head; + + mtx_assert(&txr->hn_tx_lock, MA_OWNED); + KASSERT(hn_use_if_start == 0, + ("hn_xmit is called, when if_start is enabled")); + + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || txr->hn_oactive) + return 0; + + while ((m_head = drbr_peek(ifp, txr->hn_mbuf_br)) != NULL) { + struct hn_txdesc *txd; + int error; + + if (len > 0 && m_head->m_pkthdr.len > len) { + /* + * This sending could be time consuming; let callers + * dispatch this packet sending (and sending of any + * following up packets) to tx taskqueue. + */ + drbr_putback(ifp, txr->hn_mbuf_br, m_head); + return 1; + } + + txd = hn_txdesc_get(txr); + if (txd == NULL) { + txr->hn_no_txdescs++; + drbr_putback(ifp, txr->hn_mbuf_br, m_head); + txr->hn_oactive = 1; + break; + } + + error = hn_encap(txr, txd, &m_head); + if (error) { + /* Both txd and m_head are freed; discard */ + drbr_advance(ifp, txr->hn_mbuf_br); + continue; + } + + error = hn_send_pkt(ifp, device_ctx, txr, txd); + if (__predict_false(error)) { + /* txd is freed, but m_head is not */ + drbr_putback(ifp, txr->hn_mbuf_br, m_head); + txr->hn_oactive = 1; + break; + } + + /* Sent */ + drbr_advance(ifp, txr->hn_mbuf_br); + } + return 0; +} + +static int +hn_transmit(struct ifnet *ifp, struct mbuf *m) +{ + struct hn_softc *sc = ifp->if_softc; + struct hn_tx_ring *txr; + int error; + + /* TODO: vRSS, TX ring selection */ + txr = &sc->hn_tx_ring[0]; + + error = drbr_enqueue(ifp, txr->hn_mbuf_br, m); + if (error) + return error; + + if (txr->hn_oactive) + return 0; + + if (txr->hn_sched_tx) + goto do_sched; + + if (mtx_trylock(&txr->hn_tx_lock)) { + int sched; + + sched = hn_xmit(txr, txr->hn_direct_tx_size); + mtx_unlock(&txr->hn_tx_lock); + if (!sched) + return 0; + } +do_sched: + taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_tx_task); + return 0; +} + +static void +hn_xmit_qflush(struct ifnet *ifp) +{ + struct hn_softc *sc = ifp->if_softc; + int i; + + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + struct mbuf *m; + + mtx_lock(&txr->hn_tx_lock); + while ((m = buf_ring_dequeue_sc(txr->hn_mbuf_br)) != NULL) + m_freem(m); + mtx_unlock(&txr->hn_tx_lock); + } + if_qflush(ifp); +} + +static void +hn_xmit_txeof(struct hn_tx_ring *txr) +{ + + if (txr->hn_sched_tx) + goto do_sched; + + if (mtx_trylock(&txr->hn_tx_lock)) { + int sched; + + txr->hn_oactive = 0; + sched = hn_xmit(txr, txr->hn_direct_tx_size); + mtx_unlock(&txr->hn_tx_lock); + if (sched) { + taskqueue_enqueue(txr->hn_tx_taskq, + &txr->hn_tx_task); + } + } else { +do_sched: + /* + * Release the oactive earlier, with the hope, that + * others could catch up. The task will clear the + * oactive again with the hn_tx_lock to avoid possible + * races. + */ + txr->hn_oactive = 0; + taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); + } +} + +static void +hn_xmit_taskfunc(void *xtxr, int pending __unused) +{ + struct hn_tx_ring *txr = xtxr; + + mtx_lock(&txr->hn_tx_lock); + hn_xmit(txr, 0); + mtx_unlock(&txr->hn_tx_lock); +} + +static void +hn_xmit_txeof_taskfunc(void *xtxr, int pending __unused) +{ + struct hn_tx_ring *txr = xtxr; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_oactive = 0; + hn_xmit(txr, 0); + mtx_unlock(&txr->hn_tx_lock); +} + static void hn_tx_taskq_create(void *arg __unused) { Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Jun 15 01:59:55 2016 (r301910) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Jun 15 03:17:05 2016 (r301911) @@ -384,17 +384,22 @@ hv_vmbus_channel_establish_gpadl( hv_vmbus_channel_msg_info* curr; uint32_t next_gpadl_handle; - next_gpadl_handle = hv_vmbus_g_connection.next_gpadl_handle; - atomic_add_int((int*) &hv_vmbus_g_connection.next_gpadl_handle, 1); + next_gpadl_handle = atomic_fetchadd_int( + &hv_vmbus_g_connection.next_gpadl_handle, 1); ret = vmbus_channel_create_gpadl_header( contig_buffer, size, &msg_info, &msg_count); - if(ret != 0) { /* if(allocation failed) return immediately */ - /* reverse atomic_add_int above */ - atomic_subtract_int((int*) - &hv_vmbus_g_connection.next_gpadl_handle, 1); - return ret; + if(ret != 0) { + /* + * XXX + * We can _not_ even revert the above incremental, + * if multiple GPADL establishments are running + * parallelly, decrement the global next_gpadl_handle + * is calling for _big_ trouble. A better solution + * is to have a 0-based GPADL id bitmap ... + */ + return ret; } sema_init(&msg_info->wait_sema, 0, "Open Info Sema"); From owner-svn-src-stable-10@freebsd.org Wed Jun 15 03:48:58 2016 Return-Path: Delivered-To: svn-src-stable-10@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 00742B72EB3; Wed, 15 Jun 2016 03:48:58 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C07632E47; Wed, 15 Jun 2016 03:48:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F3mvAS062862; Wed, 15 Jun 2016 03:48:57 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F3musq062852; Wed, 15 Jun 2016 03:48:56 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150348.u5F3musq062852@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 03:48:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301912 - in stable/10/sys/dev/hyperv: include netvsc storvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 03:48:58 -0000 Author: sephe Date: Wed Jun 15 03:48:55 2016 New Revision: 301912 URL: https://svnweb.freebsd.org/changeset/base/301912 Log: MFC 296083,296084,296085,296086,296087,296088,296089 296083 hyperv: Remove useless channel inbound_lock It serves no purpose. Reviewed by: Hongjiang Zhang MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5450 296084 hyperv: Always set device for channels And unregister hv_device only for primary channels, who own the hv_device. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5451 296085 hyperv/hn: Pass channel as the channel callback argument This is the preamble to pass channel back to hn(4) upon TX/RX done. Reviewed by: Hongjiang Zhang MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5452 296086 hyperv/hn: Pass channel to TX/RX done This is preamble to associate the TX/RX rings to their channel. While I'm here, revoke unused netvsc_recv_rollup. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5453 296087 hyperv/hn: Associate TX/RX ring with channel This fixes the TX/RX ring selection for TX/RX done. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5454 296088 hyperv/hn: Remove the useless num_outstanding_sends We rely on taskqueue draining now. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5456 296089 hyperv/hn: Make transmission path channel aware Chimney sending buffer still needs conversion, which will be done along with the upcoming vRSS support. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5457 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/include/hyperv.h Wed Jun 15 03:48:55 2016 (r301912) @@ -753,8 +753,6 @@ typedef struct hv_vmbus_channel { */ hv_vmbus_ring_buffer_info inbound; - struct mtx inbound_lock; - struct taskqueue * rxq; struct task channel_task; hv_vmbus_pfn_channel_callback on_channel_callback; @@ -824,12 +822,16 @@ typedef struct hv_vmbus_channel { * This will be NULL for the primary channel. */ struct hv_vmbus_channel *primary_channel; + /* - * Support per channel state for use by vmbus drivers. + * Driver private data */ - void *per_channel_state; + void *hv_chan_priv1; + void *hv_chan_priv2; } hv_vmbus_channel; +#define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) + static inline void hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state) { Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Jun 15 03:48:55 2016 (r301912) @@ -62,7 +62,8 @@ static int hv_nv_connect_to_vsp(struct static void hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_device *device, hv_vm_packet_descriptor *pkt); static void hv_nv_on_receive(netvsc_dev *net_dev, - struct hv_device *device, hv_vm_packet_descriptor *pkt); + struct hv_device *device, struct hv_vmbus_channel *chan, + hv_vm_packet_descriptor *pkt); /* * @@ -115,7 +116,7 @@ hv_nv_get_inbound_net_device(struct hv_d * permit incoming packets if and only if there * are outstanding sends. */ - if (net_dev->destroy && net_dev->num_outstanding_sends == 0) { + if (net_dev->destroy) { return (NULL); } @@ -678,7 +679,7 @@ hv_nv_on_device_add(struct hv_device *de */ ret = hv_vmbus_channel_open(device->channel, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, - NULL, 0, hv_nv_on_channel_callback, device); + NULL, 0, hv_nv_on_channel_callback, device->channel); if (ret != 0) goto cleanup; @@ -719,14 +720,7 @@ hv_nv_on_device_remove(struct hv_device netvsc_dev *net_dev = sc->net_dev;; /* Stop outbound traffic ie sends and receives completions */ - mtx_lock(&device->channel->inbound_lock); net_dev->destroy = TRUE; - mtx_unlock(&device->channel->inbound_lock); - - /* Wait for all send completions */ - while (net_dev->num_outstanding_sends) { - DELAY(100); - } hv_nv_disconnect_from_vsp(net_dev); @@ -805,8 +799,6 @@ hv_nv_on_send_completion(netvsc_dev *net net_vsc_pkt->compl.send.send_completion_context); } - - atomic_subtract_int(&net_dev->num_outstanding_sends, 1); } } @@ -816,16 +808,11 @@ hv_nv_on_send_completion(netvsc_dev *net * Returns 0 on success, non-zero on failure. */ int -hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt) +hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt) { - netvsc_dev *net_dev; nvsp_msg send_msg; int ret; - net_dev = hv_nv_get_outbound_net_device(device); - if (!net_dev) - return (ENODEV); - send_msg.hdr.msg_type = nvsp_msg_1_type_send_rndis_pkt; if (pkt->is_data_pkt) { /* 0 is RMC_DATA */ @@ -841,20 +828,16 @@ hv_nv_on_send(struct hv_device *device, pkt->send_buf_section_size; if (pkt->page_buf_count) { - ret = hv_vmbus_channel_send_packet_pagebuffer(device->channel, + ret = hv_vmbus_channel_send_packet_pagebuffer(chan, pkt->page_buffers, pkt->page_buf_count, &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); } else { - ret = hv_vmbus_channel_send_packet(device->channel, + ret = hv_vmbus_channel_send_packet(chan, &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); } - /* Record outstanding send only if send_packet() succeeded */ - if (ret == 0) - atomic_add_int(&net_dev->num_outstanding_sends, 1); - return (ret); } @@ -866,7 +849,7 @@ hv_nv_on_send(struct hv_device *device, */ static void hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device, - hv_vm_packet_descriptor *pkt) + struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt) { hv_vm_transfer_page_packet_header *vm_xfer_page_pkt; nvsp_msg *nvsp_msg_pkt; @@ -916,7 +899,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st net_vsc_pkt->tot_data_buf_len = vm_xfer_page_pkt->ranges[i].byte_count; - hv_rf_on_receive(net_dev, device, net_vsc_pkt); + hv_rf_on_receive(net_dev, device, chan, net_vsc_pkt); if (net_vsc_pkt->status != nvsp_status_success) { status = nvsp_status_failure; } @@ -929,7 +912,6 @@ hv_nv_on_receive(netvsc_dev *net_dev, st */ hv_nv_on_receive_completion(device, vm_xfer_page_pkt->d.transaction_id, status); - hv_rf_receive_rollup(net_dev); } /* @@ -973,9 +955,10 @@ retry_send_cmplt: * Net VSC on channel callback */ static void -hv_nv_on_channel_callback(void *context) +hv_nv_on_channel_callback(void *xchan) { - struct hv_device *device = (struct hv_device *)context; + struct hv_vmbus_channel *chan = xchan; + struct hv_device *device = chan->device; netvsc_dev *net_dev; device_t dev = device->device; uint32_t bytes_rxed; @@ -992,7 +975,7 @@ hv_nv_on_channel_callback(void *context) buffer = net_dev->callback_buf; do { - ret = hv_vmbus_channel_recv_packet_raw(device->channel, + ret = hv_vmbus_channel_recv_packet_raw(chan, buffer, bufferlen, &bytes_rxed, &request_id); if (ret == 0) { if (bytes_rxed > 0) { @@ -1002,7 +985,7 @@ hv_nv_on_channel_callback(void *context) hv_nv_on_send_completion(net_dev, device, desc); break; case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES: - hv_nv_on_receive(net_dev, device, desc); + hv_nv_on_receive(net_dev, device, chan, desc); break; default: device_printf(dev, @@ -1036,5 +1019,5 @@ hv_nv_on_channel_callback(void *context) if (bufferlen > NETVSC_PACKET_SIZE) free(buffer, M_NETVSC); - hv_rf_channel_rollup(net_dev); + hv_rf_channel_rollup(chan); } Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Jun 15 03:48:55 2016 (r301912) @@ -893,7 +893,6 @@ typedef struct nvsp_msg_ { */ typedef struct netvsc_dev_ { struct hv_device *dev; - int num_outstanding_sends; /* Send buffer allocated by us but manages by NetVSP */ void *send_buf; @@ -1000,6 +999,7 @@ struct buf_ring; #endif struct hn_rx_ring { + struct ifnet *hn_ifp; struct lro_ctrl hn_lro; /* Trust csum verification on host side */ @@ -1017,6 +1017,8 @@ struct hn_rx_ring { #define HN_TRUST_HCSUM_TCP 0x0002 #define HN_TRUST_HCSUM_UDP 0x0004 +struct hv_vmbus_channel; + struct hn_tx_ring { #ifndef HN_USE_TXDESC_BUFRING struct mtx hn_txlist_spin; @@ -1039,6 +1041,7 @@ struct hn_tx_ring { struct mtx hn_tx_lock; struct hn_softc *hn_sc; + struct hv_vmbus_channel *hn_chan; int hn_direct_tx_size; int hn_tx_chimney_size; @@ -1097,7 +1100,7 @@ netvsc_dev *hv_nv_on_device_add(struct h void *additional_info); int hv_nv_on_device_remove(struct hv_device *device, boolean_t destroy_channel); -int hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt); +int hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt); int hv_nv_get_next_send_section(netvsc_dev *net_dev); #endif /* __HV_NET_VSC_H__ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Jun 15 03:48:55 2016 (r301912) @@ -119,6 +119,8 @@ __FBSDID("$FreeBSD$"); #include "hv_rndis.h" #include "hv_rndis_filter.h" +#define hv_chan_rxr hv_chan_priv1 +#define hv_chan_txr hv_chan_priv2 /* Short for Hyper-V network interface */ #define NETVSC_DEVNAME "hn" @@ -397,6 +399,7 @@ static int netvsc_attach(device_t dev) { struct hv_device *device_ctx = vmbus_get_devctx(dev); + struct hv_vmbus_channel *chan; netvsc_device_info device_info; hn_softc_t *sc; int unit = device_get_unit(dev); @@ -449,6 +452,14 @@ netvsc_attach(device_t dev) hn_create_rx_data(sc); + /* + * Associate the first TX/RX ring w/ the primary channel. + */ + chan = device_ctx->channel; + chan->hv_chan_rxr = &sc->hn_rx_ring[0]; + chan->hv_chan_txr = &sc->hn_tx_ring[0]; + sc->hn_tx_ring[0].hn_chan = chan; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_dunit = unit; ifp->if_dname = NETVSC_DEVNAME; @@ -706,12 +717,11 @@ hn_tx_done(void *xpkt) } void -netvsc_channel_rollup(struct hv_device *device_ctx) +netvsc_channel_rollup(struct hv_vmbus_channel *chan) { - struct hn_softc *sc = device_get_softc(device_ctx->device); - struct hn_tx_ring *txr = &sc->hn_tx_ring[0]; /* TODO: vRSS */ + struct hn_tx_ring *txr = chan->hv_chan_txr; #if defined(INET) || defined(INET6) - struct hn_rx_ring *rxr = &sc->hn_rx_ring[0]; /* TODO: vRSS */ + struct hn_rx_ring *rxr = chan->hv_chan_rxr; struct lro_ctrl *lro = &rxr->hn_lro; struct lro_entry *queued; @@ -721,7 +731,12 @@ netvsc_channel_rollup(struct hv_device * } #endif - if (!txr->hn_has_txeof) + /* + * NOTE: + * 'txr' could be NULL, if multiple channels and + * ifnet.if_start method are enabled. + */ + if (txr == NULL || !txr->hn_has_txeof) return; txr->hn_has_txeof = 0; @@ -862,6 +877,8 @@ hn_encap(struct hn_tx_ring *txr, struct /* * Chimney send, if the packet could fit into one chimney buffer. + * + * TODO: vRSS, chimney buffer should be per-channel. */ if (packet->tot_data_buf_len < txr->hn_tx_chimney_size) { netvsc_dev *net_dev = txr->hn_sc->net_dev; @@ -948,8 +965,7 @@ done: * associated w/ the txd will _not_ be freed. */ static int -hn_send_pkt(struct ifnet *ifp, struct hv_device *device_ctx, - struct hn_tx_ring *txr, struct hn_txdesc *txd) +hn_send_pkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd) { int error, send_failed = 0; @@ -958,7 +974,7 @@ again: * Make sure that txd is not freed before ETHER_BPF_MTAP. */ hn_txdesc_hold(txd); - error = hv_nv_on_send(device_ctx, &txd->netvsc_pkt); + error = hv_nv_on_send(txr->hn_chan, &txd->netvsc_pkt); if (!error) { ETHER_BPF_MTAP(ifp, txd->m); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); @@ -1018,7 +1034,6 @@ hn_start_locked(struct hn_tx_ring *txr, { struct hn_softc *sc = txr->hn_sc; struct ifnet *ifp = sc->hn_ifp; - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); KASSERT(hn_use_if_start, ("hn_start_locked is called, when if_start is disabled")); @@ -1062,7 +1077,7 @@ hn_start_locked(struct hn_tx_ring *txr, continue; } - error = hn_send_pkt(ifp, device_ctx, txr, txd); + error = hn_send_pkt(ifp, txr, txd); if (__predict_false(error)) { /* txd is freed, but m_head is not */ IFQ_DRV_PREPEND(&ifp->if_snd, m_head); @@ -1157,26 +1172,16 @@ hv_m_append(struct mbuf *m0, int len, c_ * Note: This is no longer used as a callback */ int -netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet, +netvsc_recv(struct hv_vmbus_channel *chan, netvsc_packet *packet, rndis_tcp_ip_csum_info *csum_info) { - struct hn_softc *sc = device_get_softc(device_ctx->device); - struct hn_rx_ring *rxr = &sc->hn_rx_ring[0]; /* TODO: vRSS */ + struct hn_rx_ring *rxr = chan->hv_chan_rxr; + struct ifnet *ifp = rxr->hn_ifp; struct mbuf *m_new; - struct ifnet *ifp; int size, do_lro = 0, do_csum = 1; - if (sc == NULL) { - return (0); /* TODO: KYS how can this be! */ - } - - ifp = sc->hn_ifp; - - ifp = sc->arpcom.ac_ifp; - - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) return (0); - } /* * Bail out if packet contains more data than configured MTU. @@ -1329,11 +1334,6 @@ skip: return (0); } -void -netvsc_recv_rollup(struct hv_device *device_ctx __unused) -{ -} - /* * Rules for using sc->temp_unusable: * 1. sc->temp_unusable can only be read or written while holding NV_LOCK() @@ -2084,6 +2084,7 @@ hn_create_rx_data(struct hn_softc *sc) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_UDP; if (hn_trust_hostip) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_IP; + rxr->hn_ifp = sc->hn_ifp; /* * Initialize LRO. @@ -2567,7 +2568,6 @@ hn_xmit(struct hn_tx_ring *txr, int len) { struct hn_softc *sc = txr->hn_sc; struct ifnet *ifp = sc->hn_ifp; - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); struct mbuf *m_head; mtx_assert(&txr->hn_tx_lock, MA_OWNED); @@ -2606,7 +2606,7 @@ hn_xmit(struct hn_tx_ring *txr, int len) continue; } - error = hn_send_pkt(ifp, device_ctx, txr, txd); + error = hn_send_pkt(ifp, txr, txd); if (__predict_false(error)) { /* txd is freed, but m_head is not */ drbr_putback(ifp, txr->hn_mbuf_br, m_head); Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Wed Jun 15 03:48:55 2016 (r301912) @@ -1046,11 +1046,11 @@ typedef struct rndismp_rx_bufs_info_ { /* * Externs */ -int netvsc_recv(struct hv_device *device_ctx, - netvsc_packet *packet, - rndis_tcp_ip_csum_info *csum_info); -void netvsc_recv_rollup(struct hv_device *device_ctx); -void netvsc_channel_rollup(struct hv_device *device_ctx); +struct hv_vmbus_channel; + +int netvsc_recv(struct hv_vmbus_channel *chan, + netvsc_packet *packet, rndis_tcp_ip_csum_info *csum_info); +void netvsc_channel_rollup(struct hv_vmbus_channel *chan); void* hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Jun 15 03:48:55 2016 (r301912) @@ -59,6 +59,7 @@ static void hv_rf_receive_response(rndis static void hv_rf_receive_indicate_status(rndis_device *device, rndis_msg *response); static void hv_rf_receive_data(rndis_device *device, rndis_msg *message, + struct hv_vmbus_channel *chan, netvsc_packet *pkt); static int hv_rf_query_device(rndis_device *device, uint32_t oid, void *result, uint32_t *result_size); @@ -250,7 +251,7 @@ hv_rf_send_request(rndis_device *device, NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; packet->send_buf_section_size = 0; - ret = hv_nv_on_send(device->net_dev->dev, packet); + ret = hv_nv_on_send(device->net_dev->dev->channel, packet); return (ret); } @@ -406,7 +407,8 @@ hv_rf_receive_indicate_status(rndis_devi * RNDIS filter receive data */ static void -hv_rf_receive_data(rndis_device *device, rndis_msg *message, netvsc_packet *pkt) +hv_rf_receive_data(rndis_device *device, rndis_msg *message, + struct hv_vmbus_channel *chan, netvsc_packet *pkt) { rndis_packet *rndis_pkt; ndis_8021q_info *rppi_vlan_info; @@ -444,14 +446,15 @@ hv_rf_receive_data(rndis_device *device, } csum_info = hv_get_ppi_data(rndis_pkt, tcpip_chksum_info); - netvsc_recv(device->net_dev->dev, pkt, csum_info); + netvsc_recv(chan, pkt, csum_info); } /* * RNDIS filter on receive */ int -hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, netvsc_packet *pkt) +hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, + struct hv_vmbus_channel *chan, netvsc_packet *pkt) { rndis_device *rndis_dev; rndis_msg *rndis_hdr; @@ -474,7 +477,7 @@ hv_rf_on_receive(netvsc_dev *net_dev, st /* data message */ case REMOTE_NDIS_PACKET_MSG: - hv_rf_receive_data(rndis_dev, rndis_hdr, pkt); + hv_rf_receive_data(rndis_dev, rndis_hdr, chan, pkt); break; /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: @@ -958,32 +961,9 @@ hv_rf_on_send_request_halt_completion(vo request->halt_complete_flag = 1; } -/* - * RNDIS filter when "all" reception is done - */ void -hv_rf_receive_rollup(netvsc_dev *net_dev) +hv_rf_channel_rollup(struct hv_vmbus_channel *chan) { - rndis_device *rndis_dev; - - rndis_dev = (rndis_device *)net_dev->extension; - netvsc_recv_rollup(rndis_dev->net_dev->dev); -} -void -hv_rf_channel_rollup(netvsc_dev *net_dev) -{ - rndis_device *rndis_dev; - - rndis_dev = (rndis_device *)net_dev->extension; - - /* - * This could be called pretty early, so we need - * to make sure everything has been setup. - */ - if (rndis_dev == NULL || - rndis_dev->net_dev == NULL || - rndis_dev->net_dev->dev == NULL) - return; - netvsc_channel_rollup(rndis_dev->net_dev->dev); + netvsc_channel_rollup(chan); } Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Wed Jun 15 03:48:55 2016 (r301912) @@ -95,11 +95,12 @@ typedef struct rndis_device_ { /* * Externs */ +struct hv_vmbus_channel; -int hv_rf_on_receive(netvsc_dev *net_dev, - struct hv_device *device, netvsc_packet *pkt); +int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, + struct hv_vmbus_channel *chan, netvsc_packet *pkt); void hv_rf_receive_rollup(netvsc_dev *net_dev); -void hv_rf_channel_rollup(netvsc_dev *net_dev); +void hv_rf_channel_rollup(struct hv_vmbus_channel *chan); int hv_rf_on_device_add(struct hv_device *device, void *additl_info); int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel); int hv_rf_on_open(struct hv_device *device); Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Jun 15 03:48:55 2016 (r301912) @@ -365,7 +365,7 @@ storvsc_handle_sc_creation(void *context int ret = 0; new_channel = (hv_vmbus_channel *)context; - device = new_channel->primary_channel->device; + device = new_channel->device; sc = get_stor_device(device, TRUE); if (sc == NULL) return; @@ -883,12 +883,7 @@ hv_storvsc_on_channel_callback(void *con struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; - if (channel->primary_channel != NULL){ - device = channel->primary_channel->device; - } else { - device = channel->device; - } - + device = channel->device; KASSERT(device, ("device is NULL")); sc = get_stor_device(device, FALSE); @@ -1186,9 +1181,7 @@ storvsc_detach(device_t dev) struct hv_sgl_node *sgl_node = NULL; int j = 0; - mtx_lock(&hv_device->channel->inbound_lock); sc->hs_destroy = TRUE; - mtx_unlock(&hv_device->channel->inbound_lock); /* * At this point, all outbound traffic should be disabled. We Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Jun 15 03:48:55 2016 (r301912) @@ -537,13 +537,7 @@ hv_vmbus_channel_close_internal(hv_vmbus */ channel->rxq = NULL; taskqueue_drain(rxq, &channel->channel_task); - /* - * Grab the lock to prevent race condition when a packet received - * and unloading driver is in the process. - */ - mtx_lock(&channel->inbound_lock); channel->on_channel_callback = NULL; - mtx_unlock(&channel->inbound_lock); /** * Send a closing message @@ -920,12 +914,6 @@ VmbusProcessChannelEvent(void* context, * callback to NULL. This closes the window. */ - /* - * Disable the lock due to newly added WITNESS check in r277723. - * Will seek other way to avoid race condition. - * -- whu - */ - // mtx_lock(&channel->inbound_lock); if (channel->on_channel_callback != NULL) { arg = channel->channel_callback_context; is_batched_reading = channel->batched_reading; @@ -952,5 +940,4 @@ VmbusProcessChannelEvent(void* context, bytes_to_read = 0; } while (is_batched_reading && (bytes_to_read != 0)); } - // mtx_unlock(&channel->inbound_lock); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Wed Jun 15 03:17:05 2016 (r301911) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Wed Jun 15 03:48:55 2016 (r301912) @@ -143,9 +143,7 @@ hv_vmbus_allocate_channel(void) M_DEVBUF, M_WAITOK | M_ZERO); - mtx_init(&channel->inbound_lock, "channel inbound", NULL, MTX_DEF); mtx_init(&channel->sc_lock, "vmbus multi channel", NULL, MTX_DEF); - TAILQ_INIT(&channel->sc_list_anchor); return (channel); @@ -158,8 +156,6 @@ void hv_vmbus_free_vmbus_channel(hv_vmbus_channel* channel) { mtx_destroy(&channel->sc_lock); - mtx_destroy(&channel->inbound_lock); - free(channel, M_DEVBUF); } @@ -218,6 +214,7 @@ vmbus_channel_process_offer(hv_vmbus_cha * It is a sub channel offer, process it. */ new_channel->primary_channel = channel; + new_channel->device = channel->device; mtx_lock(&channel->sc_lock); TAILQ_INSERT_TAIL( &channel->sc_list_anchor, @@ -458,7 +455,10 @@ vmbus_channel_on_offer_rescind_internal( hv_vmbus_channel* channel; channel = (hv_vmbus_channel*)context; - hv_vmbus_child_device_unregister(channel->device); + if (HV_VMBUS_CHAN_ISPRIMARY(channel)) { + /* Only primary channel owns the hv_device */ + hv_vmbus_child_device_unregister(channel->device); + } } /** @@ -679,7 +679,10 @@ hv_vmbus_release_unattached_channels(voi TAILQ_REMOVE(&hv_vmbus_g_connection.channel_anchor, channel, list_entry); - hv_vmbus_child_device_unregister(channel->device); + if (HV_VMBUS_CHAN_ISPRIMARY(channel)) { + /* Only primary channel owns the hv_device */ + hv_vmbus_child_device_unregister(channel->device); + } hv_vmbus_free_vmbus_channel(channel); } bzero(hv_vmbus_g_connection.channels, From owner-svn-src-stable-10@freebsd.org Wed Jun 15 05:16:39 2016 Return-Path: Delivered-To: svn-src-stable-10@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 140D7B72EBA; Wed, 15 Jun 2016 05:16:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 DF4362BF2; Wed, 15 Jun 2016 05:16:38 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F5Gc8e095698; Wed, 15 Jun 2016 05:16:38 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F5Gbvn095696; Wed, 15 Jun 2016 05:16:37 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150516.u5F5Gbvn095696@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 05:16:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301913 - in stable/10/sys: net sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 05:16:39 -0000 Author: sephe Date: Wed Jun 15 05:16:37 2016 New Revision: 301913 URL: https://svnweb.freebsd.org/changeset/base/301913 Log: MFC 296178 buf_ring/drbr: Add buf_ring_peek_clear_sc and use it in drbr_peek Unlike buf_ring_peek, it only supports single consumer mode, and it clears the cons_head if DEBUG_BUFRING/INVARIANTS is defined. The normal use case of drbr_peek for network drivers is: m = drbr_peek(br); err = hw_spec_encap(&m); /* could m_defrag/m_collapse */ (*) if (err) { if (m == NULL) drbr_advance(br); else drbr_putback(br, m); /* break the loop */ } drbr_advance(br); The race is: If hw_spec_encap() m_defrag or m_collapse the mbuf, i.e. the old mbuf was freed, or like the Hyper-V's network driver, that transmission- done does not even require the TX lock; then on the other CPU at the (*) time, the freed mbuf could be recycled and being drbr_enqueue even before the current CPU had the chance to call drbr_{advance,putback}. This triggers a panic in drbr_enqueue duplicated element check, if DEBUG_BUFRING/INVARIANTS is defined. Use buf_ring_peek_clear_sc() in drbr_peek() to fix the above race. This change is a NO-OP, if neither DEBUG_BUFRING nor INVARIANTS are defined. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5416 Modified: stable/10/sys/net/if_var.h stable/10/sys/sys/buf_ring.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/net/if_var.h ============================================================================== --- stable/10/sys/net/if_var.h Wed Jun 15 03:48:55 2016 (r301912) +++ stable/10/sys/net/if_var.h Wed Jun 15 05:16:37 2016 (r301913) @@ -705,7 +705,7 @@ drbr_peek(struct ifnet *ifp, struct buf_ return (m); } #endif - return(buf_ring_peek(br)); + return(buf_ring_peek_clear_sc(br)); } static __inline void Modified: stable/10/sys/sys/buf_ring.h ============================================================================== --- stable/10/sys/sys/buf_ring.h Wed Jun 15 03:48:55 2016 (r301912) +++ stable/10/sys/sys/buf_ring.h Wed Jun 15 05:16:37 2016 (r301913) @@ -263,6 +263,37 @@ buf_ring_peek(struct buf_ring *br) return (br->br_ring[br->br_cons_head]); } +static __inline void * +buf_ring_peek_clear_sc(struct buf_ring *br) +{ +#ifdef DEBUG_BUFRING + void *ret; + + if (!mtx_owned(br->br_lock)) + panic("lock not held on single consumer dequeue"); +#endif + /* + * I believe it is safe to not have a memory barrier + * here because we control cons and tail is worst case + * a lagging indicator so we worst case we might + * return NULL immediately after a buffer has been enqueued + */ + if (br->br_cons_head == br->br_prod_tail) + return (NULL); + +#ifdef DEBUG_BUFRING + /* + * Single consumer, i.e. cons_head will not move while we are + * running, so atomic_swap_ptr() is not necessary here. + */ + ret = br->br_ring[br->br_cons_head]; + br->br_ring[br->br_cons_head] = NULL; + return (ret); +#else + return (br->br_ring[br->br_cons_head]); +#endif +} + static __inline int buf_ring_full(struct buf_ring *br) { From owner-svn-src-stable-10@freebsd.org Wed Jun 15 05:31:37 2016 Return-Path: Delivered-To: svn-src-stable-10@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 51E16B720F4; Wed, 15 Jun 2016 05:31:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 ED6672227; Wed, 15 Jun 2016 05:31:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F5Vad4001584; Wed, 15 Jun 2016 05:31:36 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F5VaDX001583; Wed, 15 Jun 2016 05:31:36 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150531.u5F5VaDX001583@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 05:31:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301914 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 05:31:37 -0000 Author: sephe Date: Wed Jun 15 05:31:35 2016 New Revision: 301914 URL: https://svnweb.freebsd.org/changeset/base/301914 Log: MFC 296180,297634 296180 hyperv: Use proper fence function to keep store-load order for msgs sfence only makes sure about the store-store order, which is not sufficient here. Use atomic_thread_fence_seq_cst() as suggested jhb and kib (a locked op in the nutshell, which should have the Reviewed by: jhb, kib, Jun Su MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5436 297634 hyperv: Use mb() instead of atomic_thread_fence_seq_cst() Since atomic_thread_fence_seq_cst() will become compiler fence on UP kernel. Reviewed by: kib, Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5852 Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Wed Jun 15 05:16:37 2016 (r301913) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Wed Jun 15 05:31:35 2016 (r301914) @@ -116,8 +116,12 @@ handled: * message_pending and EOMing. Otherwise, the EOMing will * not deliver any more messages * since there is no empty slot + * + * NOTE: + * mb() is used here, since atomic_thread_fence_seq_cst() + * will become compler fence on UP kernel. */ - wmb(); + mb(); if (msg->header.message_flags.u.message_pending) { /* @@ -186,8 +190,12 @@ hv_vmbus_isr(struct trapframe *frame) * message_pending and EOMing. Otherwise, the EOMing will * not deliver any more messages * since there is no empty slot + * + * NOTE: + * mb() is used here, since atomic_thread_fence_seq_cst() + * will become compler fence on UP kernel. */ - wmb(); + mb(); if (msg->header.message_flags.u.message_pending) { /* From owner-svn-src-stable-10@freebsd.org Wed Jun 15 05:57:08 2016 Return-Path: Delivered-To: svn-src-stable-10@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 9DA3BB72624; Wed, 15 Jun 2016 05:57:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5A2912C38; Wed, 15 Jun 2016 05:57:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F5v7jZ010545; Wed, 15 Jun 2016 05:57:07 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F5v7kL010539; Wed, 15 Jun 2016 05:57:07 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150557.u5F5v7kL010539@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 05:57:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301915 - in stable/10/sys/dev/hyperv: netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 05:57:08 -0000 Author: sephe Date: Wed Jun 15 05:57:06 2016 New Revision: 301915 URL: https://svnweb.freebsd.org/changeset/base/301915 Log: MFC 296181,296184,296187,296188,296252,296253,296289,296290 296181 hyperv/channel: Add debug sysctl nodes for channel indices It would serve as a debug tool, if the shared buffer ring's indices stopped updating. Submitted by: HongJiang Zhang Reviewed by: sephe, Jun Su Modified by: sephe MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5402 296184 hyperv/hn: Switch to if_transmit by default after r296178 MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5485 296187 hyperv/hn: Utilize mbuf flowid MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5488 296188 hyperv/channel: Add sysctl node for channel owner cpu And add sysctl node for sub-channel's channel id. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5489 296252 hyperv/hn: Set hash per-packet-info for each packet transmission So that the host could dispatch the TX done back to this TX ring's owner channel MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5498 296253 hyperv/channel: Nuke useless stack variable MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5499 296289 hyperv/chan: Add sysctl node to check whether monitor is allocated or not MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5502 296290 hyperv/chan: Function renaming; no functional change The renamed function create a sysctl tree for channel, and many non-statistics nodes exists, so don't claim it only adds sysctl nodes for statistics. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5503 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Jun 15 05:31:35 2016 (r301914) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Jun 15 05:57:06 2016 (r301915) @@ -1000,10 +1000,11 @@ struct buf_ring; struct hn_rx_ring { struct ifnet *hn_ifp; - struct lro_ctrl hn_lro; + int hn_rx_idx; /* Trust csum verification on host side */ int hn_trust_hcsum; /* HN_TRUST_HCSUM_ */ + struct lro_ctrl hn_lro; u_long hn_csum_ip; u_long hn_csum_tcp; @@ -1038,6 +1039,7 @@ struct hn_tx_ring { struct buf_ring *hn_mbuf_br; int hn_oactive; + int hn_tx_idx; struct mtx hn_tx_lock; struct hn_softc *hn_sc; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Jun 15 05:31:35 2016 (r301914) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Jun 15 05:57:06 2016 (r301915) @@ -140,6 +140,7 @@ __FBSDID("$FreeBSD$"); #define HN_RNDIS_MSG_LEN \ (sizeof(rndis_msg) + \ + RNDIS_HASH_PPI_SIZE + \ RNDIS_VLAN_PPI_SIZE + \ RNDIS_TSO_PPI_SIZE + \ RNDIS_CSUM_PPI_SIZE) @@ -276,7 +277,7 @@ static int hn_bind_tx_taskq = -1; SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN, &hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu"); -static int hn_use_if_start = 1; +static int hn_use_if_start = 0; SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN, &hn_use_if_start, 0, "Use if_start TX method"); @@ -757,6 +758,7 @@ hn_encap(struct hn_tx_ring *txr, struct rndis_msg *rndis_mesg; rndis_packet *rndis_pkt; rndis_per_packet_info *rppi; + struct ndis_hash_info *hash_info; uint32_t rndis_msg_size; packet = &txd->netvsc_pkt; @@ -781,6 +783,18 @@ hn_encap(struct hn_tx_ring *txr, struct rndis_msg_size = RNDIS_MESSAGE_SIZE(rndis_packet); + /* + * Set the hash info for this packet, so that the host could + * dispatch the TX done event for this packet back to this TX + * ring's channel. + */ + rndis_msg_size += RNDIS_HASH_PPI_SIZE; + rppi = hv_set_rppi_data(rndis_mesg, RNDIS_HASH_PPI_SIZE, + nbl_hash_value); + hash_info = (struct ndis_hash_info *)((uint8_t *)rppi + + rppi->per_packet_info_offset); + hash_info->hash = txr->hn_tx_idx; + if (m_head->m_flags & M_VLANTAG) { ndis_8021q_info *rppi_vlan_info; @@ -1307,6 +1321,9 @@ skip: m_new->m_flags |= M_VLANTAG; } + m_new->m_pkthdr.flowid = rxr->hn_rx_idx; + M_HASHTYPE_SET(m_new, M_HASHTYPE_OPAQUE); + /* * Note: Moved RX completion back to hv_nv_on_receive() so all * messages (not just data messages) will trigger a response. @@ -2085,6 +2102,7 @@ hn_create_rx_data(struct hn_softc *sc) if (hn_trust_hostip) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_IP; rxr->hn_ifp = sc->hn_ifp; + rxr->hn_rx_idx = i; /* * Initialize LRO. @@ -2202,6 +2220,7 @@ hn_create_tx_ring(struct hn_softc *sc, i int error, i; txr->hn_sc = sc; + txr->hn_tx_idx = id; #ifndef HN_USE_TXDESC_BUFRING mtx_init(&txr->hn_txlist_spin, "hn txlist", NULL, MTX_SPIN); @@ -2625,10 +2644,14 @@ hn_transmit(struct ifnet *ifp, struct mb { struct hn_softc *sc = ifp->if_softc; struct hn_tx_ring *txr; - int error; + int error, idx = 0; - /* TODO: vRSS, TX ring selection */ - txr = &sc->hn_tx_ring[0]; + /* + * Select the TX ring based on flowid + */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) + idx = m->m_pkthdr.flowid % sc->hn_tx_ring_cnt; + txr = &sc->hn_tx_ring[idx]; error = drbr_enqueue(ifp, txr->hn_mbuf_br, m); if (error) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Wed Jun 15 05:31:35 2016 (r301914) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Wed Jun 15 05:57:06 2016 (r301915) @@ -608,6 +608,8 @@ typedef enum ndis_per_pkt_infotype_ { max_perpkt_info } ndis_per_pkt_infotype; +#define nbl_hash_value pkt_cancel_id + typedef struct ndis_8021q_info_ { union { struct { @@ -620,6 +622,10 @@ typedef struct ndis_8021q_info_ { } u1; } ndis_8021q_info; +struct ndis_hash_info { + uint32_t hash; +} __packed; + struct rndis_object_header { uint8_t type; uint8_t revision; @@ -713,6 +719,9 @@ typedef struct rndis_tcp_tso_info_ { }; } rndis_tcp_tso_info; +#define RNDIS_HASH_PPI_SIZE (sizeof(rndis_per_packet_info) + \ + sizeof(struct ndis_hash_info)) + #define RNDIS_VLAN_PPI_SIZE (sizeof(rndis_per_packet_info) + \ sizeof(ndis_8021q_info)) Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Jun 15 05:31:35 2016 (r301914) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Jun 15 05:57:06 2016 (r301915) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -80,6 +81,90 @@ vmbus_channel_set_event(hv_vmbus_channel } +static int +vmbus_channel_sysctl_monalloc(SYSCTL_HANDLER_ARGS) +{ + struct hv_vmbus_channel *chan = arg1; + int alloc = 0; + + if (chan->offer_msg.monitor_allocated) + alloc = 1; + return sysctl_handle_int(oidp, &alloc, 0, req); +} + +static void +vmbus_channel_sysctl_create(hv_vmbus_channel* channel) +{ + device_t dev; + struct sysctl_oid *devch_sysctl; + struct sysctl_oid *devch_id_sysctl, *devch_sub_sysctl; + struct sysctl_oid *devch_id_in_sysctl, *devch_id_out_sysctl; + struct sysctl_ctx_list *ctx; + uint32_t ch_id; + uint16_t sub_ch_id; + char name[16]; + + hv_vmbus_channel* primary_ch = channel->primary_channel; + + if (primary_ch == NULL) { + dev = channel->device->device; + ch_id = channel->offer_msg.child_rel_id; + } else { + dev = primary_ch->device->device; + ch_id = primary_ch->offer_msg.child_rel_id; + sub_ch_id = channel->offer_msg.offer.sub_channel_index; + } + ctx = device_get_sysctl_ctx(dev); + /* This creates dev.DEVNAME.DEVUNIT.channel tree */ + devch_sysctl = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "channel", CTLFLAG_RD, 0, ""); + /* This creates dev.DEVNAME.DEVUNIT.channel.CHANID tree */ + snprintf(name, sizeof(name), "%d", ch_id); + devch_id_sysctl = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(devch_sysctl), + OID_AUTO, name, CTLFLAG_RD, 0, ""); + + if (primary_ch != NULL) { + devch_sub_sysctl = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(devch_id_sysctl), + OID_AUTO, "sub", CTLFLAG_RD, 0, ""); + snprintf(name, sizeof(name), "%d", sub_ch_id); + devch_id_sysctl = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(devch_sub_sysctl), + OID_AUTO, name, CTLFLAG_RD, 0, ""); + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), + OID_AUTO, "chanid", CTLFLAG_RD, + &channel->offer_msg.child_rel_id, 0, "channel id"); + } + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, + "cpu", CTLFLAG_RD, &channel->target_cpu, 0, "owner CPU id"); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, + "monitor_allocated", CTLTYPE_INT | CTLFLAG_RD, channel, 0, + vmbus_channel_sysctl_monalloc, "I", + "is monitor allocated to this channel"); + + devch_id_in_sysctl = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(devch_id_sysctl), + OID_AUTO, + "in", + CTLFLAG_RD, 0, ""); + devch_id_out_sysctl = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(devch_id_sysctl), + OID_AUTO, + "out", + CTLFLAG_RD, 0, ""); + hv_ring_buffer_stat(ctx, + SYSCTL_CHILDREN(devch_id_in_sysctl), + &(channel->inbound), + "inbound ring buffer stats"); + hv_ring_buffer_stat(ctx, + SYSCTL_CHILDREN(devch_id_out_sysctl), + &(channel->outbound), + "outbound ring buffer stats"); +} + /** * @brief Open the specified channel */ @@ -143,6 +228,9 @@ hv_vmbus_channel_open( in, recv_ring_buffer_size); + /* Create sysctl tree for this channel */ + vmbus_channel_sysctl_create(new_channel); + /** * Establish the gpadl for the ring buffer */ @@ -856,7 +944,6 @@ hv_vmbus_channel_recv_packet_raw( { int ret; uint32_t packetLen; - uint32_t userLen; hv_vm_packet_descriptor desc; *buffer_actual_len = 0; @@ -870,8 +957,6 @@ hv_vmbus_channel_recv_packet_raw( return (0); packetLen = desc.length8 << 3; - userLen = packetLen - (desc.data_offset8 << 3); - *buffer_actual_len = packetLen; if (packetLen > buffer_len) Modified: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Jun 15 05:31:35 2016 (r301914) +++ stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Jun 15 05:57:06 2016 (r301915) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "hv_vmbus_priv.h" @@ -39,6 +40,47 @@ __FBSDID("$FreeBSD$"); #define HV_BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r))? \ ((z) - ((w) - (r))):((r) - (w)) +static int +hv_rbi_sysctl_stats(SYSCTL_HANDLER_ARGS) +{ + hv_vmbus_ring_buffer_info* rbi; + uint32_t read_index, write_index, interrupt_mask, sz; + uint32_t read_avail, write_avail; + char rbi_stats[256]; + + rbi = (hv_vmbus_ring_buffer_info*)arg1; + read_index = rbi->ring_buffer->read_index; + write_index = rbi->ring_buffer->write_index; + interrupt_mask = rbi->ring_buffer->interrupt_mask; + sz = rbi->ring_data_size; + write_avail = HV_BYTES_AVAIL_TO_WRITE(read_index, + write_index, sz); + read_avail = sz - write_avail; + snprintf(rbi_stats, sizeof(rbi_stats), + "r_idx:%d " + "w_idx:%d " + "int_mask:%d " + "r_avail:%d " + "w_avail:%d", + read_index, write_index, interrupt_mask, + read_avail, write_avail); + + return (sysctl_handle_string(oidp, rbi_stats, + sizeof(rbi_stats), req)); +} + +void +hv_ring_buffer_stat( + struct sysctl_ctx_list *ctx, + struct sysctl_oid_list *tree_node, + hv_vmbus_ring_buffer_info *rbi, + const char *desc) +{ + SYSCTL_ADD_PROC(ctx, tree_node, OID_AUTO, + "ring_buffer_stats", + CTLTYPE_STRING|CTLFLAG_RD, rbi, 0, + hv_rbi_sysctl_stats, "A", desc); +} /** * @brief Get number of bytes available to read and to write to * for the specified ring buffer Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Wed Jun 15 05:31:35 2016 (r301914) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Wed Jun 15 05:57:06 2016 (r301915) @@ -639,6 +639,14 @@ extern hv_vmbus_channel_msg_table_entry /* * Private, VM Bus functions */ +struct sysctl_ctx_list; +struct sysctl_oid_list; + +void hv_ring_buffer_stat( + struct sysctl_ctx_list *ctx, + struct sysctl_oid_list *tree_node, + hv_vmbus_ring_buffer_info *rbi, + const char *desc); int hv_vmbus_ring_buffer_init( hv_vmbus_ring_buffer_info *ring_info, From owner-svn-src-stable-10@freebsd.org Wed Jun 15 06:08:07 2016 Return-Path: Delivered-To: svn-src-stable-10@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 25A08B7286E; Wed, 15 Jun 2016 06:08:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 00848217A; Wed, 15 Jun 2016 06:08:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F6864x014183; Wed, 15 Jun 2016 06:08:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F686ZG014182; Wed, 15 Jun 2016 06:08:06 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150608.u5F686ZG014182@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 06:08:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301916 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 06:08:07 -0000 Author: sephe Date: Wed Jun 15 06:08:05 2016 New Revision: 301916 URL: https://svnweb.freebsd.org/changeset/base/301916 Log: MFC 296291,301109 296291 hyperv/chan: Factor out the vcpu setting And use it for cpu0 assignment; it does not sound right to assume that cpu0 maps to vcpu0. And this factored out function will be exposed to drivers, if driver specific CPU binding is needed, e.g. hn(4). Move default cpu select after saving channel offer message. This makes sure that all useful information of the channel has been setup. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5504 301109 hyperv/channel: Only cpu0 is supported as channel target cpu on WIN7 MFC after: 1 week Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Wed Jun 15 05:57:06 2016 (r301915) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Wed Jun 15 06:08:05 2016 (r301916) @@ -277,6 +277,27 @@ vmbus_channel_process_offer(hv_vmbus_cha } } +static void +vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu) +{ + KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu)); + + if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 || + hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) { + /* Only cpu0 is supported */ + cpu = 0; + } + + chan->target_cpu = cpu; + chan->target_vcpu = hv_vmbus_g_context.hv_vcpu_index[cpu]; + + if (bootverbose) { + printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", + chan->offer_msg.child_rel_id, + chan->target_cpu, chan->target_vcpu); + } +} + /** * Array of device guids that are performance critical. We try to distribute * the interrupt load for these devices across all online cpus. @@ -309,11 +330,12 @@ static uint32_t next_vcpu; * distributed across all available CPUs. */ static void -vmbus_channel_select_cpu(hv_vmbus_channel *channel, hv_guid *guid) +vmbus_channel_select_defcpu(struct hv_vmbus_channel *channel) { uint32_t current_cpu; int i; boolean_t is_perf_channel = FALSE; + const hv_guid *guid = &channel->offer_msg.offer.interface_type; for (i = PERF_CHN_NIC; i < MAX_PERF_CHN; i++) { if (memcmp(guid->data, high_perf_devices[i].data, @@ -323,24 +345,14 @@ vmbus_channel_select_cpu(hv_vmbus_channe } } - if ((hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008) || - (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) || - (!is_perf_channel)) { - /* Host's view of guest cpu */ - channel->target_vcpu = 0; - /* Guest's own view of cpu */ - channel->target_cpu = 0; + if (!is_perf_channel) { + /* Stick to cpu0 */ + vmbus_channel_cpu_set(channel, 0); return; } /* mp_ncpus should have the number cpus currently online */ current_cpu = (++next_vcpu % mp_ncpus); - channel->target_cpu = current_cpu; - channel->target_vcpu = - hv_vmbus_g_context.hv_vcpu_index[current_cpu]; - if (bootverbose) - printf("VMBUS: Total online cpus %d, assign perf channel %d " - "to vcpu %d, cpu %d\n", mp_ncpus, i, channel->target_vcpu, - current_cpu); + vmbus_channel_cpu_set(channel, current_cpu); } /** @@ -411,17 +423,14 @@ vmbus_channel_on_offer_internal(void* co offer->connection_id; } - /* - * Bind the channel to a chosen cpu. - */ - vmbus_channel_select_cpu(new_channel, - &offer->offer.interface_type); - memcpy(&new_channel->offer_msg, offer, sizeof(hv_vmbus_channel_offer_channel)); new_channel->monitor_group = (uint8_t) offer->monitor_id / 32; new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32; + /* Select default cpu for this channel. */ + vmbus_channel_select_defcpu(new_channel); + vmbus_channel_process_offer(new_channel); free(offer, M_DEVBUF); From owner-svn-src-stable-10@freebsd.org Wed Jun 15 06:32:02 2016 Return-Path: Delivered-To: svn-src-stable-10@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 071ABB84222; Wed, 15 Jun 2016 06:32:02 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 BEC686C868; Wed, 15 Jun 2016 06:32:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F6W1ep022505; Wed, 15 Jun 2016 06:32:01 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F6W0SL022499; Wed, 15 Jun 2016 06:32:00 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150632.u5F6W0SL022499@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 06:32:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301918 - in stable/10/sys/dev/hyperv: include netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 06:32:02 -0000 Author: sephe Date: Wed Jun 15 06:32:00 2016 New Revision: 301918 URL: https://svnweb.freebsd.org/changeset/base/301918 Log: MFC 296293,296296,296297,296305 296293 hyperv/hn: Pass channel to hv_nv_on_receive_completion() While I'm here, staticize this function. Submitted by: Hongjiang Zhang Modified by: sephe MFC after: 1 week Sponsored by: Microsoft OSTC 296296 hyperv/hn: Make read buffer per-channel Submitted by: Hongjiang Zhang Reorganized by: sephe MFC after: 1 week Sponsored by: Microsoft OSTC 296297 hyperv/hn: Fix typo in comment MFC after: 1 week Sponsored by: Microsoft OSTC 296305 hyperv/hn: Make # of rings configurable And since the host may not being able to allocate the # of rings requested by us, save the # of rings allocated by the host in the ring_inuse counters; use ring_inuse counters for run time operation. This paves the way for the upcoming vRSS support. MFC after: 1 week Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Wed Jun 15 06:27:43 2016 (r301917) +++ stable/10/sys/dev/hyperv/include/hyperv.h Wed Jun 15 06:32:00 2016 (r301918) @@ -828,6 +828,7 @@ typedef struct hv_vmbus_channel { */ void *hv_chan_priv1; void *hv_chan_priv2; + void *hv_chan_priv3; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Jun 15 06:27:43 2016 (r301917) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Jun 15 06:32:00 2016 (r301918) @@ -48,6 +48,9 @@ #include "hv_rndis.h" #include "hv_rndis_filter.h" +/* priv1 and priv2 are consumed by the main driver */ +#define hv_chan_rdbuf hv_chan_priv3 + MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); /* @@ -61,6 +64,8 @@ static int hv_nv_destroy_rx_buffer(netv static int hv_nv_connect_to_vsp(struct hv_device *device); static void hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_device *device, hv_vm_packet_descriptor *pkt); +static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, + uint64_t tid, uint32_t status); static void hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device, struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt); @@ -663,25 +668,30 @@ hv_nv_disconnect_from_vsp(netvsc_dev *ne netvsc_dev * hv_nv_on_device_add(struct hv_device *device, void *additional_info) { + struct hv_vmbus_channel *chan = device->channel; netvsc_dev *net_dev; int ret = 0; net_dev = hv_nv_alloc_net_device(device); - if (!net_dev) - goto cleanup; + if (net_dev == NULL) + return NULL; /* Initialize the NetVSC channel extension */ sema_init(&net_dev->channel_init_sema, 0, "netdev_sema"); + chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); + /* * Open the channel */ - ret = hv_vmbus_channel_open(device->channel, + ret = hv_vmbus_channel_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, - NULL, 0, hv_nv_on_channel_callback, device->channel); - if (ret != 0) + NULL, 0, hv_nv_on_channel_callback, chan); + if (ret != 0) { + free(chan->hv_chan_rdbuf, M_NETVSC); goto cleanup; + } /* * Connect with the NetVsp @@ -694,8 +704,8 @@ hv_nv_on_device_add(struct hv_device *de close: /* Now, we can close the channel safely */ - - hv_vmbus_channel_close(device->channel); + free(chan->hv_chan_rdbuf, M_NETVSC); + hv_vmbus_channel_close(chan); cleanup: /* @@ -733,6 +743,7 @@ hv_nv_on_device_remove(struct hv_device HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE; } + free(device->channel->hv_chan_rdbuf, M_NETVSC); hv_vmbus_channel_close(device->channel); sema_destroy(&net_dev->channel_init_sema); @@ -910,7 +921,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * messages (not just data messages) will trigger a response * message back to the host. */ - hv_nv_on_receive_completion(device, vm_xfer_page_pkt->d.transaction_id, + hv_nv_on_receive_completion(chan, vm_xfer_page_pkt->d.transaction_id, status); } @@ -919,8 +930,8 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * * Send a receive completion packet to RNDIS device (ie NetVsp) */ -void -hv_nv_on_receive_completion(struct hv_device *device, uint64_t tid, +static void +hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid, uint32_t status) { nvsp_msg rx_comp_msg; @@ -935,7 +946,7 @@ hv_nv_on_receive_completion(struct hv_de retry_send_cmplt: /* Send the completion */ - ret = hv_vmbus_channel_send_packet(device->channel, &rx_comp_msg, + ret = hv_vmbus_channel_send_packet(chan, &rx_comp_msg, sizeof(nvsp_msg), tid, HV_VMBUS_PACKET_TYPE_COMPLETION, 0); if (ret == 0) { /* success */ @@ -972,7 +983,7 @@ hv_nv_on_channel_callback(void *xchan) if (net_dev == NULL) return; - buffer = net_dev->callback_buf; + buffer = chan->hv_chan_rdbuf; do { ret = hv_vmbus_channel_recv_packet_raw(chan, Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Jun 15 06:27:43 2016 (r301917) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Jun 15 06:32:00 2016 (r301918) @@ -923,8 +923,6 @@ typedef struct netvsc_dev_ { hv_bool_uint8_t destroy; /* Negotiated NVSP version */ uint32_t nvsp_version; - - uint8_t callback_buf[NETVSC_PACKET_SIZE]; } netvsc_dev; @@ -1081,9 +1079,11 @@ typedef struct hn_softc { netvsc_dev *net_dev; int hn_rx_ring_cnt; + int hn_rx_ring_inuse; struct hn_rx_ring *hn_rx_ring; int hn_tx_ring_cnt; + int hn_tx_ring_inuse; struct hn_tx_ring *hn_tx_ring; int hn_tx_chimney_max; struct taskqueue *hn_tx_taskq; @@ -1096,8 +1096,6 @@ typedef struct hn_softc { extern int hv_promisc_mode; void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status); -void hv_nv_on_receive_completion(struct hv_device *device, - uint64_t tid, uint32_t status); netvsc_dev *hv_nv_on_device_add(struct hv_device *device, void *additional_info); int hv_nv_on_device_remove(struct hv_device *device, Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Jun 15 06:27:43 2016 (r301917) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Jun 15 06:32:00 2016 (r301918) @@ -281,6 +281,14 @@ static int hn_use_if_start = 0; SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN, &hn_use_if_start, 0, "Use if_start TX method"); +static int hn_ring_cnt = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, ring_cnt, CTLFLAG_RDTUN, + &hn_ring_cnt, 0, "# of TX/RX rings to used"); + +static int hn_single_tx_ring = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, single_tx_ring, CTLFLAG_RDTUN, + &hn_single_tx_ring, 0, "Use one TX ring"); + /* * Forward declarations */ @@ -310,13 +318,13 @@ static int hn_tx_conf_int_sysctl(SYSCTL_ static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *, int); static void hn_destroy_tx_ring(struct hn_tx_ring *); -static int hn_create_tx_data(struct hn_softc *); +static int hn_create_tx_data(struct hn_softc *, int); static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *, int); static void hn_start_txeof_taskfunc(void *, int); static void hn_stop_tx_tasks(struct hn_softc *); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); -static void hn_create_rx_data(struct hn_softc *sc); +static void hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_tx_chimney_size(struct hn_softc *, int); @@ -405,7 +413,7 @@ netvsc_attach(device_t dev) hn_softc_t *sc; int unit = device_get_unit(dev); struct ifnet *ifp = NULL; - int error; + int error, ring_cnt, tx_ring_cnt; #if __FreeBSD_version >= 1100045 int tso_maxlen; #endif @@ -447,11 +455,24 @@ netvsc_attach(device_t dev) ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; - error = hn_create_tx_data(sc); + ring_cnt = hn_ring_cnt; + if (ring_cnt <= 0 || ring_cnt >= mp_ncpus) + ring_cnt = mp_ncpus; + + tx_ring_cnt = ring_cnt; + if (hn_single_tx_ring || hn_use_if_start) { + /* + * - Explicitly asked to use single TX ring. + * - ifnet.if_start is used; ifnet.if_start only needs + * one TX ring. + */ + tx_ring_cnt = 1; + } + error = hn_create_tx_data(sc, tx_ring_cnt); if (error) goto failed; - hn_create_rx_data(sc); + hn_create_rx_data(sc, ring_cnt); /* * Associate the first TX/RX ring w/ the primary channel. @@ -498,10 +519,16 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; - error = hv_rf_on_device_add(device_ctx, &device_info); + error = hv_rf_on_device_add(device_ctx, &device_info, ring_cnt); if (error) goto failed; + /* TODO: vRSS */ + sc->hn_tx_ring_inuse = 1; + sc->hn_rx_ring_inuse = 1; + device_printf(dev, "%d TX ring, %d RX ring\n", + sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); + if (device_info.link_state == 0) { sc->hn_carrier = 1; } @@ -1416,7 +1443,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, if (sc->hn_rx_ring[0].hn_lro.lro_length_lim < HN_LRO_LENLIM_MIN(ifp)) { int i; - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { sc->hn_rx_ring[i].hn_lro.lro_length_lim = HN_LRO_LENLIM_MIN(ifp); } @@ -1453,7 +1480,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, NV_UNLOCK(sc); break; } - error = hv_rf_on_device_add(hn_dev, &device_info); + error = hv_rf_on_device_add(hn_dev, &device_info, + sc->hn_rx_ring_inuse); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -1606,7 +1634,7 @@ hn_stop(hn_softc_t *sc) atomic_clear_int(&ifp->if_drv_flags, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_oactive = 0; if_link_state_change(ifp, LINK_STATE_DOWN); @@ -1699,7 +1727,7 @@ hn_ifinit_locked(hn_softc_t *sc) } atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_oactive = 0; atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); @@ -1764,7 +1792,7 @@ hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS return EINVAL; NV_LOCK(sc); - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) sc->hn_rx_ring[i].hn_lro.lro_length_lim = lenlim; NV_UNLOCK(sc); return 0; @@ -1794,7 +1822,7 @@ hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS */ --ackcnt; NV_LOCK(sc); - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) sc->hn_rx_ring[i].hn_lro.lro_ackcnt_lim = ackcnt; NV_UNLOCK(sc); return 0; @@ -1818,7 +1846,7 @@ hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARG return error; NV_LOCK(sc); - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; if (on) @@ -1858,7 +1886,7 @@ hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARG uint64_t stat; stat = 0; - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { rxr = &sc->hn_rx_ring[i]; stat += *((int *)((uint8_t *)rxr + ofs)); } @@ -1868,7 +1896,7 @@ hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARG return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { rxr = &sc->hn_rx_ring[i]; *((int *)((uint8_t *)rxr + ofs)) = 0; } @@ -1884,7 +1912,7 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARG uint64_t stat; stat = 0; - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { rxr = &sc->hn_rx_ring[i]; stat += *((uint64_t *)((uint8_t *)rxr + ofs)); } @@ -1894,7 +1922,7 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARG return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { rxr = &sc->hn_rx_ring[i]; *((uint64_t *)((uint8_t *)rxr + ofs)) = 0; } @@ -1938,7 +1966,7 @@ hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_A u_long stat; stat = 0; - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { txr = &sc->hn_tx_ring[i]; stat += *((u_long *)((uint8_t *)txr + ofs)); } @@ -1948,7 +1976,7 @@ hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_A return error; /* Zero out this stat. */ - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { txr = &sc->hn_tx_ring[i]; *((u_long *)((uint8_t *)txr + ofs)) = 0; } @@ -1970,7 +1998,7 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG return error; NV_LOCK(sc); - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { txr = &sc->hn_tx_ring[i]; *((int *)((uint8_t *)txr + ofs)) = conf; } @@ -2067,7 +2095,7 @@ hn_dma_map_paddr(void *arg, bus_dma_segm } static void -hn_create_rx_data(struct hn_softc *sc) +hn_create_rx_data(struct hn_softc *sc, int ring_cnt) { struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; @@ -2079,7 +2107,9 @@ hn_create_rx_data(struct hn_softc *sc) #endif int i; - sc->hn_rx_ring_cnt = 1; /* TODO: vRSS */ + sc->hn_rx_ring_cnt = ring_cnt; + sc->hn_rx_ring_inuse = sc->hn_rx_ring_cnt; + sc->hn_rx_ring = malloc(sizeof(struct hn_rx_ring) * sc->hn_rx_ring_cnt, M_NETVSC, M_WAITOK | M_ZERO); @@ -2190,6 +2220,10 @@ hn_create_rx_data(struct hn_softc *sc) CTLTYPE_ULONG | CTLFLAG_RW, sc, __offsetof(struct hn_rx_ring, hn_small_pkts), hn_rx_stat_ulong_sysctl, "LU", "# of small packets received"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "rx_ring_cnt", + CTLFLAG_RD, &sc->hn_rx_ring_cnt, 0, "# created RX rings"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "rx_ring_inuse", + CTLFLAG_RD, &sc->hn_rx_ring_inuse, 0, "# used RX rings"); } static void @@ -2210,6 +2244,7 @@ hn_destroy_rx_data(struct hn_softc *sc) sc->hn_rx_ring = NULL; sc->hn_rx_ring_cnt = 0; + sc->hn_rx_ring_inuse = 0; } static int @@ -2446,18 +2481,15 @@ hn_destroy_tx_ring(struct hn_tx_ring *tx } static int -hn_create_tx_data(struct hn_softc *sc) +hn_create_tx_data(struct hn_softc *sc, int ring_cnt) { struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; int i; - if (hn_use_if_start) { - /* ifnet.if_start only needs one TX ring */ - sc->hn_tx_ring_cnt = 1; - } else { - sc->hn_tx_ring_cnt = 1; /* TODO: vRSS */ - } + sc->hn_tx_ring_cnt = ring_cnt; + sc->hn_tx_ring_inuse = sc->hn_tx_ring_cnt; + sc->hn_tx_ring = malloc(sizeof(struct hn_tx_ring) * sc->hn_tx_ring_cnt, M_NETVSC, M_WAITOK | M_ZERO); @@ -2516,6 +2548,10 @@ hn_create_tx_data(struct hn_softc *sc) hn_tx_conf_int_sysctl, "I", "Always schedule transmission " "instead of doing direct transmission"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "tx_ring_cnt", + CTLFLAG_RD, &sc->hn_tx_ring_cnt, 0, "# created TX rings"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "tx_ring_inuse", + CTLFLAG_RD, &sc->hn_tx_ring_inuse, 0, "# used TX rings"); return 0; } @@ -2526,7 +2562,7 @@ hn_set_tx_chimney_size(struct hn_softc * int i; NV_LOCK(sc); - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_tx_chimney_size = chimney_size; NV_UNLOCK(sc); } @@ -2546,6 +2582,7 @@ hn_destroy_tx_data(struct hn_softc *sc) sc->hn_tx_ring = NULL; sc->hn_tx_ring_cnt = 0; + sc->hn_tx_ring_inuse = 0; } static void @@ -2574,7 +2611,7 @@ hn_stop_tx_tasks(struct hn_softc *sc) { int i; - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task); @@ -2650,7 +2687,7 @@ hn_transmit(struct ifnet *ifp, struct mb * Select the TX ring based on flowid */ if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) - idx = m->m_pkthdr.flowid % sc->hn_tx_ring_cnt; + idx = m->m_pkthdr.flowid % sc->hn_tx_ring_inuse; txr = &sc->hn_tx_ring[idx]; error = drbr_enqueue(ifp, txr->hn_mbuf_br, m); @@ -2682,7 +2719,7 @@ hn_xmit_qflush(struct ifnet *ifp) struct hn_softc *sc = ifp->if_softc; int i; - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; struct mbuf *m; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Jun 15 06:27:43 2016 (r301917) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Jun 15 06:32:00 2016 (r301918) @@ -816,7 +816,8 @@ hv_rf_close_device(rndis_device *device) * RNDIS filter on device add */ int -hv_rf_on_device_add(struct hv_device *device, void *additl_info) +hv_rf_on_device_add(struct hv_device *device, void *additl_info, + int nchan __unused) { int ret; netvsc_dev *net_dev; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Wed Jun 15 06:27:43 2016 (r301917) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Wed Jun 15 06:32:00 2016 (r301918) @@ -101,7 +101,7 @@ int hv_rf_on_receive(netvsc_dev *net_dev struct hv_vmbus_channel *chan, netvsc_packet *pkt); void hv_rf_receive_rollup(netvsc_dev *net_dev); void hv_rf_channel_rollup(struct hv_vmbus_channel *chan); -int hv_rf_on_device_add(struct hv_device *device, void *additl_info); +int hv_rf_on_device_add(struct hv_device *device, void *additl_info, int nchan); int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel); int hv_rf_on_open(struct hv_device *device); int hv_rf_on_close(struct hv_device *device); From owner-svn-src-stable-10@freebsd.org Wed Jun 15 06:33:41 2016 Return-Path: Delivered-To: svn-src-stable-10@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 BFACCB842C7; Wed, 15 Jun 2016 06:33:41 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 8FCB56C937; Wed, 15 Jun 2016 06:33:41 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F6Xe7o025252; Wed, 15 Jun 2016 06:33:40 GMT (envelope-from truckman@FreeBSD.org) Received: (from truckman@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F6Xe3j025251; Wed, 15 Jun 2016 06:33:40 GMT (envelope-from truckman@FreeBSD.org) Message-Id: <201606150633.u5F6Xe3j025251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: truckman set sender to truckman@FreeBSD.org using -f From: Don Lewis Date: Wed, 15 Jun 2016 06:33:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301919 - stable/10/bin/setfacl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 06:33:41 -0000 Author: truckman Date: Wed Jun 15 06:33:40 2016 New Revision: 301919 URL: https://svnweb.freebsd.org/changeset/base/301919 Log: MFC r301582 Explicitly NUL terminate the buffer filled by fread(). The fix in r300649 was not sufficient to convince Coverity that the buffer was NUL terminated, even with the buffer pre-zeroed. Swap the size and nmemb arguments to fread() so that a valid lenght is returned, which we can use to terminate the string in the buffer at the correct location. This should also quiet the complaint about the return value of fread() not being checked. Reported by: Coverity CID: 1019054, 1009614 Secur3ty: Sponsore dby: Modified: stable/10/bin/setfacl/file.c Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/setfacl/file.c ============================================================================== --- stable/10/bin/setfacl/file.c Wed Jun 15 06:32:00 2016 (r301918) +++ stable/10/bin/setfacl/file.c Wed Jun 15 06:33:40 2016 (r301919) @@ -43,13 +43,12 @@ acl_t get_acl_from_file(const char *filename) { FILE *file; + size_t len; char buf[BUFSIZ+1]; if (filename == NULL) err(1, "(null) filename in get_acl_from_file()"); - bzero(&buf, sizeof(buf)); - if (strcmp(filename, "-") == 0) { if (have_stdin != 0) err(1, "cannot specify more than one stdin"); @@ -61,7 +60,8 @@ get_acl_from_file(const char *filename) err(1, "fopen() %s failed", filename); } - fread(buf, sizeof(buf) - 1, (size_t)1, file); + len = fread(buf, (size_t)1, sizeof(buf) - 1, file); + buf[len] = '\0'; if (ferror(file) != 0) { fclose(file); err(1, "error reading from %s", filename); From owner-svn-src-stable-10@freebsd.org Wed Jun 15 06:40:31 2016 Return-Path: Delivered-To: svn-src-stable-10@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 68601B843E1; Wed, 15 Jun 2016 06:40:31 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 1E9DA6CBCB; Wed, 15 Jun 2016 06:40:31 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F6eUnE025727; Wed, 15 Jun 2016 06:40:30 GMT (envelope-from truckman@FreeBSD.org) Received: (from truckman@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F6eUaw025726; Wed, 15 Jun 2016 06:40:30 GMT (envelope-from truckman@FreeBSD.org) Message-Id: <201606150640.u5F6eUaw025726@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: truckman set sender to truckman@FreeBSD.org using -f From: Don Lewis Date: Wed, 15 Jun 2016 06:40:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301920 - stable/10/lib/libc/resolv X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 06:40:31 -0000 Author: truckman Date: Wed Jun 15 06:40:30 2016 New Revision: 301920 URL: https://svnweb.freebsd.org/changeset/base/301920 Log: MFC r301592 Don't leak addrinfo if ai->ai_addrlen <= minsiz test fails. If the ai->ai_addrlen <= minsiz test fails, then freeaddrinfo() does not get called to free the memory just allocated by getaddrinfo(). Fix by moving ai->ai_addrlen <= minsiz to a separate nested if block, and keep freeaddrinfo() in the outer block so that freeaddrinfo() will be called whenever getaddrinfo() succeeds. Reported by: Coverity CID: 1273652 Reviewed by: ume Differential Revision: https://reviews.freebsd.org/D6756 Modified: stable/10/lib/libc/resolv/res_init.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/resolv/res_init.c ============================================================================== --- stable/10/lib/libc/resolv/res_init.c Wed Jun 15 06:33:40 2016 (r301919) +++ stable/10/lib/libc/resolv/res_init.c Wed Jun 15 06:40:30 2016 (r301920) @@ -412,20 +412,21 @@ __res_vinit(res_state statp, int preinit hints.ai_socktype = SOCK_DGRAM; /*dummy*/ hints.ai_flags = AI_NUMERICHOST; sprintf(sbuf, "%u", NAMESERVER_PORT); - if (getaddrinfo(cp, sbuf, &hints, &ai) == 0 && - ai->ai_addrlen <= minsiz) { - if (statp->_u._ext.ext != NULL) { - memcpy(&statp->_u._ext.ext->nsaddrs[nserv], - ai->ai_addr, ai->ai_addrlen); + if (getaddrinfo(cp, sbuf, &hints, &ai) == 0) { + if (ai->ai_addrlen <= minsiz) { + if (statp->_u._ext.ext != NULL) { + memcpy(&statp->_u._ext.ext->nsaddrs[nserv], + ai->ai_addr, ai->ai_addrlen); + } + if (ai->ai_addrlen <= + sizeof(statp->nsaddr_list[nserv])) { + memcpy(&statp->nsaddr_list[nserv], + ai->ai_addr, ai->ai_addrlen); + } else + statp->nsaddr_list[nserv].sin_family = 0; + nserv++; } - if (ai->ai_addrlen <= - sizeof(statp->nsaddr_list[nserv])) { - memcpy(&statp->nsaddr_list[nserv], - ai->ai_addr, ai->ai_addrlen); - } else - statp->nsaddr_list[nserv].sin_family = 0; freeaddrinfo(ai); - nserv++; } } continue; From owner-svn-src-stable-10@freebsd.org Wed Jun 15 06:42:31 2016 Return-Path: Delivered-To: svn-src-stable-10@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 80710B8457C; Wed, 15 Jun 2016 06:42:31 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 501381313; Wed, 15 Jun 2016 06:42:31 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F6gUIJ029294; Wed, 15 Jun 2016 06:42:30 GMT (envelope-from truckman@FreeBSD.org) Received: (from truckman@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F6gU4U029293; Wed, 15 Jun 2016 06:42:30 GMT (envelope-from truckman@FreeBSD.org) Message-Id: <201606150642.u5F6gU4U029293@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: truckman set sender to truckman@FreeBSD.org using -f From: Don Lewis Date: Wed, 15 Jun 2016 06:42:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301921 - stable/10/lib/libc/gen X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 06:42:31 -0000 Author: truckman Date: Wed Jun 15 06:42:30 2016 New Revision: 301921 URL: https://svnweb.freebsd.org/changeset/base/301921 Log: MFC r301596 Don't leak olinep if malloc() fails. If malloc() fails to allocate linep, then free olinep (if it exists) before returning to avoid a memory leak. Reported by: Coverity CID: 1016716 Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D6755 Modified: stable/10/lib/libc/gen/getnetgrent.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/getnetgrent.c ============================================================================== --- stable/10/lib/libc/gen/getnetgrent.c Wed Jun 15 06:40:30 2016 (r301920) +++ stable/10/lib/libc/gen/getnetgrent.c Wed Jun 15 06:42:30 2016 (r301921) @@ -615,6 +615,8 @@ read_for_group(const char *group) if (linep == NULL) { free(lp->l_groupname); free(lp); + if (olen > 0) + free(olinep); return (NULL); } if (olen > 0) { From owner-svn-src-stable-10@freebsd.org Wed Jun 15 06:44:36 2016 Return-Path: Delivered-To: svn-src-stable-10@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 557D4B845E3; Wed, 15 Jun 2016 06:44:36 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 07A4C14FF; Wed, 15 Jun 2016 06:44:35 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F6RikX021700; Wed, 15 Jun 2016 06:27:44 GMT (envelope-from truckman@FreeBSD.org) Received: (from truckman@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F6Ri4K021699; Wed, 15 Jun 2016 06:27:44 GMT (envelope-from truckman@FreeBSD.org) Message-Id: <201606150627.u5F6Ri4K021699@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: truckman set sender to truckman@FreeBSD.org using -f From: Don Lewis Date: Wed, 15 Jun 2016 06:27:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301917 - stable/10/games/random X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 06:44:36 -0000 Author: truckman Date: Wed Jun 15 06:27:43 2016 New Revision: 301917 URL: https://svnweb.freebsd.org/changeset/base/301917 Log: MFC r299484, r301574 r299484 | cem | 2016-05-11 15:04:28 -0700 (Wed, 11 May 2016) | 13 lines random(6): Fix double-close In the case where a file lacks a trailing newline, there is some "evil" code to reverse goto the tokenizing code ("make_token") for the final token in the file. In this case, 'fd' is closed more than once. Use a negative sentinel value to guard close(2), preventing the double close. Ideally, this code would be restructured to avoid this ugly construction. r301574 | truckman | 2016-06-07 19:14:05 -0700 (Tue, 07 Jun 2016) | 15 lines Fix a (false positive?) Argument cannot be negative coverity defect. Rather than guarding close(fd) with an fd >= 0 test and setting fd to -1 when it is closed to avoid a potential double-close, just move the close() call after the conditional "goto make_token". This moves the close() call totally outside the loop to avoid the possibility of calling it twice. This should also prevent a Coverity warning about checking fd for validity after it was previously passed to read(). Reported by: Coverity CID: 1006123, 1355335 Modified: stable/10/games/random/randomize_fd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/games/random/randomize_fd.c ============================================================================== --- stable/10/games/random/randomize_fd.c Wed Jun 15 06:08:05 2016 (r301916) +++ stable/10/games/random/randomize_fd.c Wed Jun 15 06:27:43 2016 (r301917) @@ -174,7 +174,7 @@ randomize_fd(int fd, int type, int uniqu if ((type == RANDOM_TYPE_LINES && buf[i] == '\n') || (type == RANDOM_TYPE_WORDS && isspace(buf[i])) || (eof && i == buflen - 1)) { - make_token: +make_token: if (numnode == RANDOM_MAX_PLUS1) { errno = EFBIG; err(1, "too many delimiters"); @@ -199,14 +199,14 @@ randomize_fd(int fd, int type, int uniqu } } - (void)close(fd); - /* Necessary evil to compensate for files that don't end with a newline */ if (bufc != i) { i--; goto make_token; } + (void)close(fd); + free(buf); for (i = numnode; i > 0; i--) { From owner-svn-src-stable-10@freebsd.org Wed Jun 15 09:39:42 2016 Return-Path: Delivered-To: svn-src-stable-10@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 D3712A1D1CA; Wed, 15 Jun 2016 09:39:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 AB1ED1DEA; Wed, 15 Jun 2016 09:39:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F9df2j093517; Wed, 15 Jun 2016 09:39:41 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F9dffE093515; Wed, 15 Jun 2016 09:39:41 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150939.u5F9dffE093515@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 09:39:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301924 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 09:39:42 -0000 Author: sephe Date: Wed Jun 15 09:39:41 2016 New Revision: 301924 URL: https://svnweb.freebsd.org/changeset/base/301924 Log: MFC 297219 hyperv/vmbus: use a better retry method in hv_vmbus_post_message() Most often, hv_vmbus_post_message() doesn't fail. However, it fails intermittently when GPADLs of large shared memory is to be established with the host, e.g. on the hn(4) attach path: a GPADL of 15MB sendbuf is created, for which lots of messages will be flooded to the host. The host side tries to throttle the message rate by returning HV_STATUS_INSUFFICIENT_BUFFERS. Before this commit, we do several retries for failed messages, but the delay between each retry is pretty/too low, which will cause sporadic message posting failure. We now use large delay (>=1ms) between each retry to fix the message posting failure. Submitted by: Dexuan Cui Reviewed by: sephe MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5715 Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_connection.c Wed Jun 15 09:08:14 2016 (r301923) +++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c Wed Jun 15 09:39:41 2016 (r301924) @@ -367,31 +367,35 @@ hv_vmbus_on_events(int cpu) /** * Send a msg on the vmbus's message connection */ -int hv_vmbus_post_message(void *buffer, size_t bufferLen) { - int ret = 0; +int hv_vmbus_post_message(void *buffer, size_t bufferLen) +{ hv_vmbus_connection_id connId; - unsigned retries = 0; - - /* NetScaler delays from previous code were consolidated here */ - static int delayAmount[] = {100, 100, 100, 500, 500, 5000, 5000, 5000}; - - /* for(each entry in delayAmount) try to post message, - * delay a little bit before retrying + sbintime_t time = SBT_1MS; + int retries; + int ret; + + connId.as_uint32_t = 0; + connId.u.id = HV_VMBUS_MESSAGE_CONNECTION_ID; + + /* + * We retry to cope with transient failures caused by host side's + * insufficient resources. 20 times should suffice in practice. */ - for (retries = 0; - retries < sizeof(delayAmount)/sizeof(delayAmount[0]); retries++) { - connId.as_uint32_t = 0; - connId.u.id = HV_VMBUS_MESSAGE_CONNECTION_ID; - ret = hv_vmbus_post_msg_via_msg_ipc(connId, 1, buffer, bufferLen); - if (ret != HV_STATUS_INSUFFICIENT_BUFFERS) - break; - /* TODO: KYS We should use a blocking wait call */ - DELAY(delayAmount[retries]); + for (retries = 0; retries < 20; retries++) { + ret = hv_vmbus_post_msg_via_msg_ipc(connId, 1, buffer, + bufferLen); + if (ret == HV_STATUS_SUCCESS) + return (0); + + pause_sbt("pstmsg", time, 0, C_HARDCLOCK); + if (time < SBT_1S * 2) + time *= 2; } - KASSERT(ret == 0, ("Error VMBUS: Message Post Failed\n")); + KASSERT(ret == HV_STATUS_SUCCESS, + ("Error VMBUS: Message Post Failed, ret=%d\n", ret)); - return (ret); + return (EAGAIN); } /** Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Wed Jun 15 09:08:14 2016 (r301923) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Wed Jun 15 09:39:41 2016 (r301924) @@ -70,6 +70,7 @@ typedef uint16_t hv_vmbus_status; * You did not supply enough message buffers to send a message. */ +#define HV_STATUS_SUCCESS ((uint16_t)0) #define HV_STATUS_INSUFFICIENT_BUFFERS ((uint16_t)0x0013) typedef void (*hv_vmbus_channel_callback)(void *context); From owner-svn-src-stable-10@freebsd.org Wed Jun 15 09:52:03 2016 Return-Path: Delivered-To: svn-src-stable-10@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 02DC2A1D64C; Wed, 15 Jun 2016 09:52:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 CA13D1737; Wed, 15 Jun 2016 09:52:02 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5F9q1L4000707; Wed, 15 Jun 2016 09:52:01 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F9q1k6000704; Wed, 15 Jun 2016 09:52:01 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150952.u5F9q1k6000704@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 09:52:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301925 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 09:52:03 -0000 Author: sephe Date: Wed Jun 15 09:52:01 2016 New Revision: 301925 URL: https://svnweb.freebsd.org/changeset/base/301925 Log: MFC 297635 hyperv/vmbus: Use default mtx for channel message queue First of all sema_post() can't be called w/ spinlock, and the channel message queue processing is not on hot code path, i.e. spinlock is not necessary. Submitted by: Jun Su Reviewed by: sephe, Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5812 Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_connection.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Jun 15 09:39:41 2016 (r301924) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Jun 15 09:52:01 2016 (r301925) @@ -270,12 +270,12 @@ hv_vmbus_channel_open( if (user_data_len) memcpy(open_msg->user_data, user_data, user_data_len); - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_INSERT_TAIL( &hv_vmbus_g_connection.channel_msg_anchor, open_info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); ret = hv_vmbus_post_message( open_msg, sizeof(hv_vmbus_channel_open_channel)); @@ -302,12 +302,12 @@ hv_vmbus_channel_open( } cleanup: - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_REMOVE( &hv_vmbus_g_connection.channel_msg_anchor, open_info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); sema_destroy(&open_info->wait_sema); free(open_info, M_DEVBUF); @@ -496,13 +496,13 @@ hv_vmbus_channel_establish_gpadl( gpadl_msg->child_rel_id = channel->offer_msg.child_rel_id; gpadl_msg->gpadl = next_gpadl_handle; - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_INSERT_TAIL( &hv_vmbus_g_connection.channel_msg_anchor, msg_info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); ret = hv_vmbus_post_message( gpadl_msg, @@ -541,10 +541,10 @@ hv_vmbus_channel_establish_gpadl( cleanup: - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor, msg_info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); sema_destroy(&msg_info->wait_sema); free(msg_info, M_DEVBUF); @@ -583,10 +583,10 @@ hv_vmbus_channel_teardown_gpdal( msg->child_rel_id = channel->offer_msg.child_rel_id; msg->gpadl = gpadl_handle; - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_msg_anchor, info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); ret = hv_vmbus_post_message(msg, sizeof(hv_vmbus_channel_gpadl_teardown)); @@ -599,10 +599,10 @@ cleanup: /* * Received a torndown response */ - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor, info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); sema_destroy(&info->wait_sema); free(info, M_DEVBUF); Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Wed Jun 15 09:39:41 2016 (r301924) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Wed Jun 15 09:52:01 2016 (r301925) @@ -499,7 +499,7 @@ vmbus_channel_on_open_result(hv_vmbus_ch /* * Find the open msg, copy the result and signal/unblock the wait event */ - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, msg_list_entry) { @@ -517,7 +517,7 @@ vmbus_channel_on_open_result(hv_vmbus_ch } } } - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); } @@ -541,7 +541,7 @@ vmbus_channel_on_gpadl_created(hv_vmbus_ /* Find the establish msg, copy the result and signal/unblock * the wait event */ - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, msg_list_entry) { request_header = (hv_vmbus_channel_msg_header*) msg_info->msg; @@ -560,7 +560,7 @@ vmbus_channel_on_gpadl_created(hv_vmbus_ } } } - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); } /** @@ -585,7 +585,7 @@ vmbus_channel_on_gpadl_torndown(hv_vmbus * wait event. */ - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, msg_list_entry) { @@ -605,7 +605,7 @@ vmbus_channel_on_gpadl_torndown(hv_vmbus } } } - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); } /** @@ -625,7 +625,7 @@ vmbus_channel_on_version_response(hv_vmb versionResponse = (hv_vmbus_channel_version_response*)hdr; - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, msg_list_entry) { requestHeader = (hv_vmbus_channel_msg_header*) msg_info->msg; @@ -639,7 +639,7 @@ vmbus_channel_on_version_response(hv_vmb sema_post(&msg_info->wait_sema); } } - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_connection.c Wed Jun 15 09:39:41 2016 (r301924) +++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c Wed Jun 15 09:52:01 2016 (r301925) @@ -99,26 +99,26 @@ hv_vmbus_negotiate_version(hv_vmbus_chan * Add to list before we send the request since we may receive the * response before returning from this routine */ - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_INSERT_TAIL( &hv_vmbus_g_connection.channel_msg_anchor, msg_info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); ret = hv_vmbus_post_message( msg, sizeof(hv_vmbus_channel_initiate_contact)); if (ret != 0) { - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_REMOVE( &hv_vmbus_g_connection.channel_msg_anchor, msg_info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); return (ret); } @@ -127,12 +127,12 @@ hv_vmbus_negotiate_version(hv_vmbus_chan */ ret = sema_timedwait(&msg_info->wait_sema, 5 * hz); /* KYS 5 seconds */ - mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); TAILQ_REMOVE( &hv_vmbus_g_connection.channel_msg_anchor, msg_info, msg_list_entry); - mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock); + mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); /** * Check if successful @@ -169,7 +169,7 @@ hv_vmbus_connect(void) { TAILQ_INIT(&hv_vmbus_g_connection.channel_msg_anchor); mtx_init(&hv_vmbus_g_connection.channel_msg_lock, "vmbus channel msg", - NULL, MTX_SPIN); + NULL, MTX_DEF); TAILQ_INIT(&hv_vmbus_g_connection.channel_anchor); mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel", From owner-svn-src-stable-10@freebsd.org Wed Jun 15 14:11:50 2016 Return-Path: Delivered-To: svn-src-stable-10@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 C3820A44132; Wed, 15 Jun 2016 14:11:50 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 94912197B; Wed, 15 Jun 2016 14:11:50 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5FEBnho092697; Wed, 15 Jun 2016 14:11:49 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5FEBnGc092696; Wed, 15 Jun 2016 14:11:49 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201606151411.u5FEBnGc092696@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Wed, 15 Jun 2016 14:11:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301926 - stable/10/usr.sbin/newsyslog X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 14:11:50 -0000 Author: vangyzen Date: Wed Jun 15 14:11:49 2016 New Revision: 301926 URL: https://svnweb.freebsd.org/changeset/base/301926 Log: MFC r301532 newsyslog: Eliminate unnecessary sleep(10) when -R and -s are specified After going through the signal work list, during which do_sigwork() is called and essentially does nothing because -s and -R were specified on the command line, newsyslog will sleep for 10 seconds as the (verbose) code says: "Pause 10 seconds to allow daemon(s) to close log file(s)". However, the man page verbiage for -R (and -s) seems quite clear that this sleep() is unnecessary because the daemon was expected to have already closed the log file before calling newsyslog. PR: 210020 Submitted by: David A. Bright Sponsored by: Dell Inc. Modified: stable/10/usr.sbin/newsyslog/newsyslog.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/newsyslog/newsyslog.c ============================================================================== --- stable/10/usr.sbin/newsyslog/newsyslog.c Wed Jun 15 09:52:01 2016 (r301925) +++ stable/10/usr.sbin/newsyslog/newsyslog.c Wed Jun 15 14:11:49 2016 (r301926) @@ -333,13 +333,15 @@ main(int argc, char **argv) printf("Signal all daemon process(es)...\n"); SLIST_FOREACH(stmp, &swhead, sw_nextp) do_sigwork(stmp); - if (noaction) - printf("\tsleep 10\n"); - else { - if (verbose) - printf("Pause 10 seconds to allow daemon(s)" - " to close log file(s)\n"); - sleep(10); + if (!(rotatereq && nosignal)) { + if (noaction) + printf("\tsleep 10\n"); + else { + if (verbose) + printf("Pause 10 seconds to allow " + "daemon(s) to close log file(s)\n"); + sleep(10); + } } } /* From owner-svn-src-stable-10@freebsd.org Thu Jun 16 01:57:17 2016 Return-Path: Delivered-To: svn-src-stable-10@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 614CFA31D51; Thu, 16 Jun 2016 01:57:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 3CD121202; Thu, 16 Jun 2016 01:57:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G1vGbn020947; Thu, 16 Jun 2016 01:57:16 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G1vGkX020945; Thu, 16 Jun 2016 01:57:16 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160157.u5G1vGkX020945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 01:57:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301942 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 01:57:17 -0000 Author: sephe Date: Thu Jun 16 01:57:16 2016 New Revision: 301942 URL: https://svnweb.freebsd.org/changeset/base/301942 Log: MFC 297802,297803(297481),297804 297802 hyperv: Identify Hyper-V features and recommends properly Features bits will be used to detect devices, e.g. timers, which do not have corresponding event channels. Submitted by: Jun Su Reviewed by: sephe, Dexuan Cui Rearranged by: sephe MFC after: 1 week Sponsored by: Microsoft OSTC 279803(297481) hyperv: Register Hyper-V timer early enough for TSC freq calibration The i8254 simulation in Hyper-V is kinda broken and is not available in Generation 2 Hyper-V VMs, so Hyper-V timer must be registered early enough so that it can be used to do the TSC freq calibration. This fixes the notorious warning like this: calcru: runtime went backwards from 50 usec to 25 usec for pid 0 (kernel) Submitted by: Dexuan Cui Reviewed by: kib, sephe Tested by: kib, sephe MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5778 ================= hyperv: Resurrect r297481 This time we make sure that the TIME_REF_COUNT MSR exists. Submitted by: Jun Su Reviewed by: sephe, Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC 297804 hyperv: Declare hyperv_{features,recommends} properly MFC after: 1 week Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_hv.c Wed Jun 15 23:58:09 2016 (r301941) +++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c Thu Jun 16 01:57:16 2016 (r301942) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -50,6 +51,9 @@ __FBSDID("$FreeBSD$"); static u_int hv_get_timecount(struct timecounter *tc); +u_int hyperv_features; +u_int hyperv_recommends; + /** * Globals */ @@ -207,8 +211,6 @@ hv_vmbus_init(void) hv_vmbus_g_context.hypercall_page = virt_addr; - tc_init(&hv_timecounter); /* register virtual timecount */ - hv_et_init(); return (0); @@ -423,3 +425,93 @@ void hv_vmbus_synic_cleanup(void *arg) wrmsr(HV_X64_MSR_SIEFP, siefp.as_uint64_t); } +static bool +hyperv_identify(void) +{ + u_int regs[4]; + unsigned int maxLeaf; + unsigned int op; + + if (vm_guest != VM_GUEST_HV) + return (false); + + op = HV_CPU_ID_FUNCTION_HV_VENDOR_AND_MAX_FUNCTION; + do_cpuid(op, regs); + maxLeaf = regs[0]; + if (maxLeaf < HV_CPU_ID_FUNCTION_MS_HV_IMPLEMENTATION_LIMITS) + return (false); + + op = HV_CPU_ID_FUNCTION_HV_INTERFACE; + do_cpuid(op, regs); + if (regs[0] != 0x31237648 /* HV#1 */) + return (false); + + op = HV_CPU_ID_FUNCTION_MS_HV_FEATURES; + do_cpuid(op, regs); + if ((regs[0] & HV_FEATURE_MSR_HYPERCALL) == 0) { + /* + * Hyper-V w/o Hypercall is impossible; someone + * is faking Hyper-V. + */ + return (false); + } + hyperv_features = regs[0]; + + op = HV_CPU_ID_FUNCTION_MS_HV_VERSION; + do_cpuid(op, regs); + printf("Hyper-V Version: %d.%d.%d [SP%d]\n", + regs[1] >> 16, regs[1] & 0xffff, regs[0], regs[2]); + + printf(" Features: 0x%b\n", hyperv_features, + "\020" + "\001VPRUNTIME" + "\002TMREFCNT" + "\003SYNCIC" + "\004SYNCTM" + "\005APIC" + "\006HYERCALL" + "\007VPINDEX" + "\010RESET" + "\011STATS" + "\012REFTSC" + "\013IDLE" + "\014TMFREQ" + "\015DEBUG"); + + op = HV_CPU_ID_FUNCTION_MS_HV_ENLIGHTENMENT_INFORMATION; + do_cpuid(op, regs); + hyperv_recommends = regs[0]; + if (bootverbose) + printf(" Recommends: %08x %08x\n", regs[0], regs[1]); + + op = HV_CPU_ID_FUNCTION_MS_HV_IMPLEMENTATION_LIMITS; + do_cpuid(op, regs); + if (bootverbose) { + printf(" Limits: Vcpu:%d Lcpu:%d Int:%d\n", + regs[0], regs[1], regs[2]); + } + + if (maxLeaf >= HV_CPU_ID_FUNCTION_MS_HV_HARDWARE_FEATURE) { + op = HV_CPU_ID_FUNCTION_MS_HV_HARDWARE_FEATURE; + do_cpuid(op, regs); + if (bootverbose) { + printf(" HW Features: %08x AMD: %08x\n", + regs[0], regs[3]); + } + } + + return (true); +} + +static void +hyperv_init(void *dummy __unused) +{ + if (!hyperv_identify()) + return; + + if (hyperv_features & HV_FEATURE_MSR_TIME_REFCNT) { + /* Register virtual timecount */ + tc_init(&hv_timecounter); + } +} +SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init, NULL); Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Wed Jun 15 23:58:09 2016 (r301941) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Thu Jun 16 01:57:16 2016 (r301942) @@ -470,10 +470,17 @@ typedef enum { HV_CPU_ID_FUNCTION_MS_HV_VERSION = 0x40000002, HV_CPU_ID_FUNCTION_MS_HV_FEATURES = 0x40000003, HV_CPU_ID_FUNCTION_MS_HV_ENLIGHTENMENT_INFORMATION = 0x40000004, - HV_CPU_ID_FUNCTION_MS_HV_IMPLEMENTATION_LIMITS = 0x40000005 - + HV_CPU_ID_FUNCTION_MS_HV_IMPLEMENTATION_LIMITS = 0x40000005, + HV_CPU_ID_FUNCTION_MS_HV_HARDWARE_FEATURE = 0x40000006 } hv_vmbus_cpuid_function; +#define HV_FEATURE_MSR_TIME_REFCNT (1 << 1) +#define HV_FEATURE_MSR_SYNCIC (1 << 2) +#define HV_FEATURE_MSR_STIMER (1 << 3) +#define HV_FEATURE_MSR_APIC (1 << 4) +#define HV_FEATURE_MSR_HYPERCALL (1 << 5) +#define HV_FEATURE_MSR_GUEST_IDLE (1 << 10) + /* * Define the format of the SIMP register */ @@ -627,6 +634,9 @@ typedef enum { extern hv_vmbus_context hv_vmbus_g_context; extern hv_vmbus_connection hv_vmbus_g_connection; +extern u_int hyperv_features; +extern u_int hyperv_recommends; + typedef void (*vmbus_msg_handler)(hv_vmbus_channel_msg_header *msg); typedef struct hv_vmbus_channel_msg_table_entry { From owner-svn-src-stable-10@freebsd.org Thu Jun 16 02:48:19 2016 Return-Path: Delivered-To: svn-src-stable-10@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 CBE5CA47B0D; Thu, 16 Jun 2016 02:48:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9151B1C5F; Thu, 16 Jun 2016 02:48:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G2mIWG039220; Thu, 16 Jun 2016 02:48:18 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G2mIOP039213; Thu, 16 Jun 2016 02:48:18 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160248.u5G2mIOP039213@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 02:48:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301943 - in stable/10/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 02:48:19 -0000 Author: sephe Date: Thu Jun 16 02:48:18 2016 New Revision: 301943 URL: https://svnweb.freebsd.org/changeset/base/301943 Log: MFC 296379,296380,296381,296593,296594,296595 296379 hyperv/hn: Add multiple channel support, a.k.a. vRSS Each channel contains one RX ring and one TX ring. And we try to distribute the channels to different evenly. Note: Currently we don't have enough information to extract the RSS type and RSS hash value from the received packets. This greatly improves the TX/RX performance for 8 virtual CPU Hyper-V over 10Ge: it can max out 10Ge for TCP when multiple RX/TX rings are enabled. This almost doubles the TX/RX performance for locally connected Hyper-Vs: was 6Gbps w/ 128 TCP streams, now 11Gbps w/ multiple RX/TX rings enabled. It is not enabled by default; it will be switched on after more tests. Collaborated with: Hongjiang Zhang MFC after: 2 week Sponsored by: Microsoft OSTC 296380 hyperv/hn: Pass channel to send done callbacks. Mainly to strigent the data packet send done check. MFC after: 2 weeks Sponsored by: Microsoft OSTC 296381 hyperv/hn: Add per-TX ring stats for # of transmitted packets MFC after: 2 weeks Sponsored by: Microsoft OSTC 296593 hyperv/hn: Move if_initname to an earlier place So that functions shared w/ attach path could use if_printf(). While I'm here, remove unnecessary if_dunit and if_dname assignment. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5576 296594 hyperv/hn: Factor out hn_channel_attach MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5577 296595 hyperv/hn: Make the # of TX rings configurable. Rename the tunables to avoid confusion. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5578 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Thu Jun 16 01:57:16 2016 (r301942) +++ stable/10/sys/dev/hyperv/include/hyperv.h Thu Jun 16 02:48:18 2016 (r301943) @@ -911,6 +911,8 @@ int hv_vmbus_channel_teardown_gpdal( struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary); +void vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu); + /** * @brief Get physical address from virtual */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Jun 16 01:57:16 2016 (r301942) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Jun 16 02:48:18 2016 (r301943) @@ -56,14 +56,14 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper /* * Forward declarations */ -static void hv_nv_on_channel_callback(void *context); +static void hv_nv_on_channel_callback(void *xchan); static int hv_nv_init_send_buffer_with_net_vsp(struct hv_device *device); static int hv_nv_init_rx_buffer_with_net_vsp(struct hv_device *device); static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); static int hv_nv_connect_to_vsp(struct hv_device *device); static void hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_device *device, hv_vm_packet_descriptor *pkt); + struct hv_device *device, struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt); static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid, uint32_t status); static void hv_nv_on_receive(netvsc_dev *net_dev, @@ -661,6 +661,34 @@ hv_nv_disconnect_from_vsp(netvsc_dev *ne } /* + * Callback handler for subchannel offer + * @@param context new subchannel + */ +static void +hv_nv_subchan_callback(void *xchan) +{ + struct hv_vmbus_channel *chan = xchan; + netvsc_dev *net_dev; + uint16_t chn_index = chan->offer_msg.offer.sub_channel_index; + struct hv_device *device = chan->device; + hn_softc_t *sc = device_get_softc(device->device); + int ret; + + net_dev = sc->net_dev; + + if (chn_index >= net_dev->num_channel) { + /* Would this ever happen? */ + return; + } + netvsc_subchan_callback(sc, chan); + + chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); + ret = hv_vmbus_channel_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, + NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, + hv_nv_on_channel_callback, chan); +} + +/* * Net VSC on device add * * Callback when the device belonging to this driver is added @@ -692,6 +720,7 @@ hv_nv_on_device_add(struct hv_device *de free(chan->hv_chan_rdbuf, M_NETVSC); goto cleanup; } + chan->sc_creation_callback = hv_nv_subchan_callback; /* * Connect with the NetVsp @@ -757,7 +786,8 @@ hv_nv_on_device_remove(struct hv_device */ static void hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_device *device, hv_vm_packet_descriptor *pkt) + struct hv_device *device, struct hv_vmbus_channel *chan, + hv_vm_packet_descriptor *pkt) { nvsp_msg *nvsp_msg_pkt; netvsc_packet *net_vsc_pkt; @@ -769,7 +799,9 @@ hv_nv_on_send_completion(netvsc_dev *net || nvsp_msg_pkt->hdr.msg_type == nvsp_msg_1_type_send_rx_buf_complete || nvsp_msg_pkt->hdr.msg_type - == nvsp_msg_1_type_send_send_buf_complete) { + == nvsp_msg_1_type_send_send_buf_complete + || nvsp_msg_pkt->hdr.msg_type + == nvsp_msg5_type_subchannel) { /* Copy the response back */ memcpy(&net_dev->channel_init_packet, nvsp_msg_pkt, sizeof(nvsp_msg)); @@ -806,7 +838,7 @@ hv_nv_on_send_completion(netvsc_dev *net } /* Notify the layer above us */ - net_vsc_pkt->compl.send.on_send_completion( + net_vsc_pkt->compl.send.on_send_completion(chan, net_vsc_pkt->compl.send.send_completion_context); } @@ -963,6 +995,46 @@ retry_send_cmplt: } /* + * Net VSC receiving vRSS send table from VSP + */ +static void +hv_nv_send_table(struct hv_device *device, hv_vm_packet_descriptor *pkt) +{ + netvsc_dev *net_dev; + nvsp_msg *nvsp_msg_pkt; + int i; + uint32_t count, *table; + + net_dev = hv_nv_get_inbound_net_device(device); + if (!net_dev) + return; + + nvsp_msg_pkt = + (nvsp_msg *)((unsigned long)pkt + (pkt->data_offset8 << 3)); + + if (nvsp_msg_pkt->hdr.msg_type != + nvsp_msg5_type_send_indirection_table) { + printf("Netvsc: !Warning! receive msg type not " + "send_indirection_table. type = %d\n", + nvsp_msg_pkt->hdr.msg_type); + return; + } + + count = nvsp_msg_pkt->msgs.vers_5_msgs.send_table.count; + if (count != VRSS_SEND_TABLE_SIZE) { + printf("Netvsc: Received wrong send table size: %u\n", count); + return; + } + + table = (uint32_t *) + ((unsigned long)&nvsp_msg_pkt->msgs.vers_5_msgs.send_table + + nvsp_msg_pkt->msgs.vers_5_msgs.send_table.offset); + + for (i = 0; i < count; i++) + net_dev->vrss_send_table[i] = table[i]; +} + +/* * Net VSC on channel callback */ static void @@ -993,11 +1065,15 @@ hv_nv_on_channel_callback(void *xchan) desc = (hv_vm_packet_descriptor *)buffer; switch (desc->type) { case HV_VMBUS_PACKET_TYPE_COMPLETION: - hv_nv_on_send_completion(net_dev, device, desc); + hv_nv_on_send_completion(net_dev, device, + chan, desc); break; case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES: hv_nv_on_receive(net_dev, device, chan, desc); break; + case HV_VMBUS_PACKET_TYPE_DATA_IN_BAND: + hv_nv_send_table(device, desc); + break; default: device_printf(dev, "hv_cb recv unknow type %d " Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Jun 16 01:57:16 2016 (r301942) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Jun 16 02:48:18 2016 (r301943) @@ -86,6 +86,92 @@ MALLOC_DECLARE(M_NETVSC); */ #define NVSP_MAX_PACKETS_PER_RECEIVE 375 +/* vRSS stuff */ +#define RNDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88 +#define RNDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89 + +#define RNDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2 +#define RNDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2 + +struct rndis_obj_header { + uint8_t type; + uint8_t rev; + uint16_t size; +} __packed; + +/* rndis_recv_scale_cap/cap_flag */ +#define RNDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x01000000 +#define RNDIS_RSS_CAPS_CLASSIFICATION_AT_ISR 0x02000000 +#define RNDIS_RSS_CAPS_CLASSIFICATION_AT_DPC 0x04000000 +#define RNDIS_RSS_CAPS_USING_MSI_X 0x08000000 +#define RNDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS 0x10000000 +#define RNDIS_RSS_CAPS_SUPPORTS_MSI_X 0x20000000 +#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4 0x00000100 +#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6 0x00000200 +#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX 0x00000400 + +/* RNDIS_RECEIVE_SCALE_CAPABILITIES */ +struct rndis_recv_scale_cap { + struct rndis_obj_header hdr; + uint32_t cap_flag; + uint32_t num_int_msg; + uint32_t num_recv_que; + uint16_t num_indirect_tabent; +} __packed; + +/* rndis_recv_scale_param flags */ +#define RNDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001 +#define RNDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED 0x0002 +#define RNDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED 0x0004 +#define RNDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008 +#define RNDIS_RSS_PARAM_FLAG_DISABLE_RSS 0x0010 + +/* Hash info bits */ +#define RNDIS_HASH_FUNC_TOEPLITZ 0x00000001 +#define RNDIS_HASH_IPV4 0x00000100 +#define RNDIS_HASH_TCP_IPV4 0x00000200 +#define RNDIS_HASH_IPV6 0x00000400 +#define RNDIS_HASH_IPV6_EX 0x00000800 +#define RNDIS_HASH_TCP_IPV6 0x00001000 +#define RNDIS_HASH_TCP_IPV6_EX 0x00002000 + +#define RNDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4) +#define RNDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 40 + +#define ITAB_NUM 128 +#define HASH_KEYLEN RNDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 + +/* RNDIS_RECEIVE_SCALE_PARAMETERS */ +typedef struct rndis_recv_scale_param_ { + struct rndis_obj_header hdr; + + /* Qualifies the rest of the information */ + uint16_t flag; + + /* The base CPU number to do receive processing. not used */ + uint16_t base_cpu_number; + + /* This describes the hash function and type being enabled */ + uint32_t hashinfo; + + /* The size of indirection table array */ + uint16_t indirect_tabsize; + + /* The offset of the indirection table from the beginning of this + * structure + */ + uint32_t indirect_taboffset; + + /* The size of the hash secret key */ + uint16_t hashkey_size; + + /* The offset of the secret key from the beginning of this structure */ + uint32_t hashkey_offset; + + uint32_t processor_masks_offset; + uint32_t num_processor_masks; + uint32_t processor_masks_entry_size; +} rndis_recv_scale_param; typedef enum nvsp_msg_type_ { nvsp_msg_type_none = 0, @@ -146,6 +232,27 @@ typedef enum nvsp_msg_type_ { nvsp_msg_2_type_alloc_chimney_handle, nvsp_msg_2_type_alloc_chimney_handle_complete, + + nvsp_msg2_max = nvsp_msg_2_type_alloc_chimney_handle_complete, + + /* + * Version 4 Messages + */ + nvsp_msg4_type_send_vf_association, + nvsp_msg4_type_switch_data_path, + nvsp_msg4_type_uplink_connect_state_deprecated, + + nvsp_msg4_max = nvsp_msg4_type_uplink_connect_state_deprecated, + + /* + * Version 5 Messages + */ + nvsp_msg5_type_oid_query_ex, + nvsp_msg5_type_oid_query_ex_comp, + nvsp_msg5_type_subchannel, + nvsp_msg5_type_send_indirection_table, + + nvsp_msg5_max = nvsp_msg5_type_send_indirection_table, } nvsp_msg_type; typedef enum nvsp_status_ { @@ -793,6 +900,39 @@ typedef struct nvsp_2_msg_send_vmq_rndis uint32_t status; } __packed nvsp_2_msg_send_vmq_rndis_pkt_complete; +/* + * Version 5 messages + */ +enum nvsp_subchannel_operation { + NVSP_SUBCHANNEL_NONE = 0, + NVSP_SUBCHANNE_ALLOCATE, + NVSP_SUBCHANNE_MAX +}; + +typedef struct nvsp_5_subchannel_request_ +{ + uint32_t op; + uint32_t num_subchannels; +} __packed nvsp_5_subchannel_request; + +typedef struct nvsp_5_subchannel_complete_ +{ + uint32_t status; + /* Actual number of subchannels allocated */ + uint32_t num_subchannels; +} __packed nvsp_5_subchannel_complete; + +typedef struct nvsp_5_send_indirect_table_ +{ + /* The number of entries in the send indirection table */ + uint32_t count; + /* + * The offset of the send indireciton table from top of + * this struct. The send indirection table tells which channel + * to put the send traffic on. Each entry is a channel number. + */ + uint32_t offset; +} __packed nvsp_5_send_indirect_table; typedef union nvsp_1_msg_uber_ { nvsp_1_msg_send_ndis_version send_ndis_vers; @@ -838,11 +978,18 @@ typedef union nvsp_2_msg_uber_ { nvsp_2_msg_alloc_chimney_handle_complete alloc_chimney_handle_complete; } __packed nvsp_2_msg_uber; +typedef union nvsp_5_msg_uber_ +{ + nvsp_5_subchannel_request subchannel_request; + nvsp_5_subchannel_complete subchn_complete; + nvsp_5_send_indirect_table send_table; +} __packed nvsp_5_msg_uber; typedef union nvsp_all_msgs_ { nvsp_msg_init_uber init_msgs; nvsp_1_msg_uber vers_1_msgs; nvsp_2_msg_uber vers_2_msgs; + nvsp_5_msg_uber vers_5_msgs; } __packed nvsp_all_msgs; /* @@ -883,6 +1030,7 @@ typedef struct nvsp_msg_ { #define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024) #define NETVSC_PACKET_SIZE PAGE_SIZE +#define VRSS_SEND_TABLE_SIZE 16 /* * Data types @@ -923,10 +1071,15 @@ typedef struct netvsc_dev_ { hv_bool_uint8_t destroy; /* Negotiated NVSP version */ uint32_t nvsp_version; + + uint32_t num_channel; + + uint32_t vrss_send_table[VRSS_SEND_TABLE_SIZE]; } netvsc_dev; +struct hv_vmbus_channel; -typedef void (*pfn_on_send_rx_completion)(void *); +typedef void (*pfn_on_send_rx_completion)(struct hv_vmbus_channel *, void *); #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) #define NETVSC_PACKET_MAXPAGE 32 @@ -1010,13 +1163,18 @@ struct hn_rx_ring { u_long hn_csum_trusted; u_long hn_lro_tried; u_long hn_small_pkts; + u_long hn_pkts; + + /* Rarely used stuffs */ + struct sysctl_oid *hn_rx_sysctl_tree; + int hn_rx_flags; } __aligned(CACHE_LINE_SIZE); #define HN_TRUST_HCSUM_IP 0x0001 #define HN_TRUST_HCSUM_TCP 0x0002 #define HN_TRUST_HCSUM_UDP 0x0004 -struct hv_vmbus_channel; +#define HN_RX_FLAG_ATTACHED 0x1 struct hn_tx_ring { #ifndef HN_USE_TXDESC_BUFRING @@ -1053,13 +1211,17 @@ struct hn_tx_ring { u_long hn_txdma_failed; u_long hn_tx_collapsed; u_long hn_tx_chimney; + u_long hn_pkts; /* Rarely used stuffs */ struct hn_txdesc *hn_txdesc; bus_dma_tag_t hn_tx_rndis_dtag; struct sysctl_oid *hn_tx_sysctl_tree; + int hn_tx_flags; } __aligned(CACHE_LINE_SIZE); +#define HN_TX_FLAG_ATTACHED 0x1 + /* * Device-specific softc structure */ @@ -1085,9 +1247,12 @@ typedef struct hn_softc { int hn_tx_ring_cnt; int hn_tx_ring_inuse; struct hn_tx_ring *hn_tx_ring; + + int hn_cpu; int hn_tx_chimney_max; struct taskqueue *hn_tx_taskq; struct sysctl_oid *hn_tx_sysctl_tree; + struct sysctl_oid *hn_rx_sysctl_tree; } hn_softc_t; /* Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 01:57:16 2016 (r301942) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 02:48:18 2016 (r301943) @@ -281,13 +281,16 @@ static int hn_use_if_start = 0; SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN, &hn_use_if_start, 0, "Use if_start TX method"); -static int hn_ring_cnt = 1; -SYSCTL_INT(_hw_hn, OID_AUTO, ring_cnt, CTLFLAG_RDTUN, - &hn_ring_cnt, 0, "# of TX/RX rings to used"); - -static int hn_single_tx_ring = 1; -SYSCTL_INT(_hw_hn, OID_AUTO, single_tx_ring, CTLFLAG_RDTUN, - &hn_single_tx_ring, 0, "Use one TX ring"); +static int hn_chan_cnt = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, chan_cnt, CTLFLAG_RDTUN, + &hn_chan_cnt, 0, + "# of channels to use; each channel has one RX ring and one TX ring"); + +static int hn_tx_ring_cnt = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_ring_cnt, CTLFLAG_RDTUN, + &hn_tx_ring_cnt, 0, "# of TX rings to use"); + +static u_int hn_cpu_index; /* * Forward declarations @@ -327,6 +330,7 @@ static int hn_encap(struct hn_tx_ring *, static void hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_tx_chimney_size(struct hn_softc *, int); +static void hn_channel_attach(struct hn_softc *, struct hv_vmbus_channel *); static int hn_transmit(struct ifnet *, struct mbuf *); static void hn_xmit_qflush(struct ifnet *); @@ -454,37 +458,46 @@ netvsc_attach(device_t dev) ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ring_cnt = hn_ring_cnt; - if (ring_cnt <= 0 || ring_cnt >= mp_ncpus) + /* + * Figure out the # of RX rings (ring_cnt) and the # of TX rings + * to use (tx_ring_cnt). + * + * NOTE: + * The # of RX rings to use is same as the # of channels to use. + */ + ring_cnt = hn_chan_cnt; + if (ring_cnt <= 0 || ring_cnt > mp_ncpus) ring_cnt = mp_ncpus; - tx_ring_cnt = ring_cnt; - if (hn_single_tx_ring || hn_use_if_start) { - /* - * - Explicitly asked to use single TX ring. - * - ifnet.if_start is used; ifnet.if_start only needs - * one TX ring. - */ + tx_ring_cnt = hn_tx_ring_cnt; + if (tx_ring_cnt <= 0 || tx_ring_cnt > ring_cnt) + tx_ring_cnt = ring_cnt; + if (hn_use_if_start) { + /* ifnet.if_start only needs one TX ring. */ tx_ring_cnt = 1; } + + /* + * Set the leader CPU for channels. + */ + sc->hn_cpu = atomic_fetchadd_int(&hn_cpu_index, ring_cnt) % mp_ncpus; + error = hn_create_tx_data(sc, tx_ring_cnt); if (error) goto failed; - hn_create_rx_data(sc, ring_cnt); /* * Associate the first TX/RX ring w/ the primary channel. */ chan = device_ctx->channel; - chan->hv_chan_rxr = &sc->hn_rx_ring[0]; - chan->hv_chan_txr = &sc->hn_tx_ring[0]; - sc->hn_tx_ring[0].hn_chan = chan; - - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_dunit = unit; - ifp->if_dname = NETVSC_DEVNAME; + KASSERT(HV_VMBUS_CHAN_ISPRIMARY(chan), ("not primary channel")); + KASSERT(chan->offer_msg.offer.sub_channel_index == 0, + ("primary channel subidx %u", + chan->offer_msg.offer.sub_channel_index)); + hn_channel_attach(sc, chan); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; @@ -522,10 +535,18 @@ netvsc_attach(device_t dev) error = hv_rf_on_device_add(device_ctx, &device_info, ring_cnt); if (error) goto failed; + KASSERT(sc->net_dev->num_channel > 0 && + sc->net_dev->num_channel <= sc->hn_rx_ring_inuse, + ("invalid channel count %u, should be less than %d", + sc->net_dev->num_channel, sc->hn_rx_ring_inuse)); - /* TODO: vRSS */ - sc->hn_tx_ring_inuse = 1; - sc->hn_rx_ring_inuse = 1; + /* + * Set the # of TX/RX rings that could be used according to + * the # of channels that host offered. + */ + if (sc->hn_tx_ring_inuse > sc->net_dev->num_channel) + sc->hn_tx_ring_inuse = sc->net_dev->num_channel; + sc->hn_rx_ring_inuse = sc->net_dev->num_channel; device_printf(dev, "%d TX ring, %d RX ring\n", sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); @@ -730,7 +751,7 @@ hn_txdesc_hold(struct hn_txdesc *txd) } static void -hn_tx_done(void *xpkt) +hn_tx_done(struct hv_vmbus_channel *chan, void *xpkt) { netvsc_packet *packet = xpkt; struct hn_txdesc *txd; @@ -740,6 +761,11 @@ hn_tx_done(void *xpkt) packet->compl.send.send_completion_tid; txr = txd->txr; + KASSERT(txr->hn_chan == chan, + ("channel mismatch, on channel%u, should be channel%u", + chan->offer_msg.offer.sub_channel_index, + txr->hn_chan->offer_msg.offer.sub_channel_index)); + txr->hn_has_txeof = 1; hn_txdesc_put(txr, txd); } @@ -1025,6 +1051,7 @@ again: if (txd->m->m_flags & M_MCAST) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); } + txr->hn_pkts++; } hn_txdesc_put(txr, txd); @@ -1357,6 +1384,7 @@ skip: */ ifp->if_ipackets++; + rxr->hn_pkts++; if ((ifp->if_capenable & IFCAP_LRO) && do_lro) { #if defined(INET) || defined(INET6) @@ -2122,6 +2150,13 @@ hn_create_rx_data(struct hn_softc *sc, i #endif #endif /* INET || INET6 */ + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + + /* Create dev.hn.UNIT.rx sysctl tree */ + sc->hn_rx_sysctl_tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "rx", + CTLFLAG_RD, 0, ""); + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; @@ -2149,10 +2184,27 @@ hn_create_rx_data(struct hn_softc *sc, i rxr->hn_lro.lro_ackcnt_lim = HN_LRO_ACKCNT_DEF; #endif #endif /* INET || INET6 */ - } - ctx = device_get_sysctl_ctx(dev); - child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + if (sc->hn_rx_sysctl_tree != NULL) { + char name[16]; + + /* + * Create per RX ring sysctl tree: + * dev.hn.UNIT.rx.RINGID + */ + snprintf(name, sizeof(name), "%d", i); + rxr->hn_rx_sysctl_tree = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(sc->hn_rx_sysctl_tree), + OID_AUTO, name, CTLFLAG_RD, 0, ""); + + if (rxr->hn_rx_sysctl_tree != NULL) { + SYSCTL_ADD_ULONG(ctx, + SYSCTL_CHILDREN(rxr->hn_rx_sysctl_tree), + OID_AUTO, "packets", CTLFLAG_RW, + &rxr->hn_pkts, "# of packets received"); + } + } + } SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_queued", CTLTYPE_U64 | CTLFLAG_RW, sc, @@ -2419,6 +2471,9 @@ hn_create_tx_ring(struct hn_softc *sc, i CTLFLAG_RD, &txr->hn_oactive, 0, "over active"); } + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "packets", + CTLFLAG_RW, &txr->hn_pkts, + "# of packets transmitted"); } } @@ -2783,6 +2838,55 @@ hn_xmit_txeof_taskfunc(void *xtxr, int p } static void +hn_channel_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan) +{ + struct hn_rx_ring *rxr; + int idx; + + idx = chan->offer_msg.offer.sub_channel_index; + + KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, + ("invalid channel index %d, should > 0 && < %d", + idx, sc->hn_rx_ring_inuse)); + rxr = &sc->hn_rx_ring[idx]; + KASSERT((rxr->hn_rx_flags & HN_RX_FLAG_ATTACHED) == 0, + ("RX ring %d already attached", idx)); + rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED; + + chan->hv_chan_rxr = rxr; + if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", + idx, chan->offer_msg.child_rel_id); + + if (idx < sc->hn_tx_ring_inuse) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[idx]; + + KASSERT((txr->hn_tx_flags & HN_TX_FLAG_ATTACHED) == 0, + ("TX ring %d already attached", idx)); + txr->hn_tx_flags |= HN_TX_FLAG_ATTACHED; + + chan->hv_chan_txr = txr; + txr->hn_chan = chan; + if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", + idx, chan->offer_msg.child_rel_id); + } + + /* Bind channel to a proper CPU */ + vmbus_channel_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); +} + +void +netvsc_subchan_callback(struct hn_softc *sc, struct hv_vmbus_channel *chan) +{ + + KASSERT(!HV_VMBUS_CHAN_ISPRIMARY(chan), + ("subchannel callback on primary channel")); + KASSERT(chan->offer_msg.offer.sub_channel_index > 0, + ("invalid channel subidx %u", + chan->offer_msg.offer.sub_channel_index)); + hn_channel_attach(sc, chan); +} + +static void hn_tx_taskq_create(void *arg __unused) { if (!hn_share_tx_taskq) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Jun 16 01:57:16 2016 (r301942) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Jun 16 02:48:18 2016 (r301943) @@ -167,6 +167,14 @@ #define RNDIS_OID_GEN_MACHINE_NAME 0x0001021A #define RNDIS_OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B +/* + * For receive side scale + */ +/* Query only */ +#define RNDIS_OID_GEN_RSS_CAPABILITIES 0x00010203 +/* Query and set */ +#define RNDIS_OID_GEN_RSS_PARAMETERS 0x00010204 + #define RNDIS_OID_GEN_XMIT_OK 0x00020101 #define RNDIS_OID_GEN_RCV_OK 0x00020102 #define RNDIS_OID_GEN_XMIT_ERROR 0x00020103 @@ -1060,6 +1068,8 @@ struct hv_vmbus_channel; int netvsc_recv(struct hv_vmbus_channel *chan, netvsc_packet *packet, rndis_tcp_ip_csum_info *csum_info); void netvsc_channel_rollup(struct hv_vmbus_channel *chan); +void netvsc_subchan_callback(struct hn_softc *sc, + struct hv_vmbus_channel *chan); void* hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Jun 16 01:57:16 2016 (r301942) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Jun 16 02:48:18 2016 (r301943) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "hv_net_vsc.h" #include "hv_rndis.h" #include "hv_rndis_filter.h" @@ -69,8 +70,8 @@ static int hv_rf_set_packet_filter(rndi static int hv_rf_init_device(rndis_device *device); static int hv_rf_open_device(rndis_device *device); static int hv_rf_close_device(rndis_device *device); -static void hv_rf_on_send_request_completion(void *context); -static void hv_rf_on_send_request_halt_completion(void *context); +static void hv_rf_on_send_request_completion(struct hv_vmbus_channel *, void *context); +static void hv_rf_on_send_request_halt_completion(struct hv_vmbus_channel *, void *context); int hv_rf_send_offload_request(struct hv_device *device, rndis_offload_params *offloads); @@ -224,6 +225,8 @@ hv_rf_send_request(rndis_device *device, { int ret; netvsc_packet *packet; + netvsc_dev *net_dev = device->net_dev; + int send_buf_section_idx; /* Set up the packet to send it */ packet = &request->pkt; @@ -238,6 +241,20 @@ hv_rf_send_request(rndis_device *device, packet->page_buffers[0].offset = (unsigned long)&request->request_msg & (PAGE_SIZE - 1); + if (packet->page_buffers[0].offset + + packet->page_buffers[0].length > PAGE_SIZE) { + packet->page_buf_count = 2; + packet->page_buffers[0].length = + PAGE_SIZE - packet->page_buffers[0].offset; + packet->page_buffers[1].pfn = + hv_get_phys_addr((char*)&request->request_msg + + packet->page_buffers[0].length) >> PAGE_SHIFT; + packet->page_buffers[1].offset = 0; + packet->page_buffers[1].length = + request->request_msg.msg_len - + packet->page_buffers[0].length; + } + packet->compl.send.send_completion_context = request; /* packet */ if (message_type != REMOTE_NDIS_HALT_MSG) { packet->compl.send.on_send_completion = @@ -247,10 +264,25 @@ hv_rf_send_request(rndis_device *device, hv_rf_on_send_request_halt_completion; } packet->compl.send.send_completion_tid = (unsigned long)device; - packet->send_buf_section_idx = - NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; + if (packet->tot_data_buf_len < net_dev->send_section_size) { + send_buf_section_idx = hv_nv_get_next_send_section(net_dev); + if (send_buf_section_idx != + NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { + char *dest = ((char *)net_dev->send_buf + + send_buf_section_idx * net_dev->send_section_size); + + memcpy(dest, &request->request_msg, request->request_msg.msg_len); + packet->send_buf_section_idx = send_buf_section_idx; + packet->send_buf_section_size = packet->tot_data_buf_len; + packet->page_buf_count = 0; + goto sendit; + } + /* Failed to allocate chimney send buffer; move on */ + } + packet->send_buf_section_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; packet->send_buf_section_size = 0; +sendit: ret = hv_nv_on_send(device->net_dev->dev->channel, packet); return (ret); @@ -528,6 +560,19 @@ hv_rf_query_device(rndis_device *device, query->info_buffer_length = 0; query->device_vc_handle = 0; + if (oid == RNDIS_OID_GEN_RSS_CAPABILITIES) { + struct rndis_recv_scale_cap *cap; + + request->request_msg.msg_len += + sizeof(struct rndis_recv_scale_cap); + query->info_buffer_length = sizeof(struct rndis_recv_scale_cap); + cap = (struct rndis_recv_scale_cap *)((unsigned long)query + + query->info_buffer_offset); + cap->hdr.type = RNDIS_OBJECT_TYPE_RSS_CAPABILITIES; + cap->hdr.rev = RNDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2; + cap->hdr.size = sizeof(struct rndis_recv_scale_cap); + } + ret = hv_rf_send_request(device, request, REMOTE_NDIS_QUERY_MSG); if (ret != 0) { /* Fixme: printf added */ @@ -582,6 +627,114 @@ hv_rf_query_device_link_status(rndis_dev RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, &device->link_status, &size)); } +static uint8_t netvsc_hash_key[HASH_KEYLEN] = { + 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, + 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, + 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, + 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, + 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa +}; + +/* + * RNDIS set vRSS parameters + */ +static int +hv_rf_set_rss_param(rndis_device *device, int num_queue) +{ + rndis_request *request; + rndis_set_request *set; + rndis_set_complete *set_complete; + rndis_recv_scale_param *rssp; + uint32_t extlen = sizeof(rndis_recv_scale_param) + + (4 * ITAB_NUM) + HASH_KEYLEN; + uint32_t *itab, status; + uint8_t *keyp; + int i, ret; + + + request = hv_rndis_request(device, REMOTE_NDIS_SET_MSG, + RNDIS_MESSAGE_SIZE(rndis_set_request) + extlen); + if (request == NULL) { + if (bootverbose) + printf("Netvsc: No memory to set vRSS parameters.\n"); + ret = -1; + goto cleanup; + } + + set = &request->request_msg.msg.set_request; + set->oid = RNDIS_OID_GEN_RSS_PARAMETERS; + set->info_buffer_length = extlen; + set->info_buffer_offset = sizeof(rndis_set_request); + set->device_vc_handle = 0; + + /* Fill out the rssp parameter structure */ + rssp = (rndis_recv_scale_param *)(set + 1); + rssp->hdr.type = RNDIS_OBJECT_TYPE_RSS_PARAMETERS; + rssp->hdr.rev = RNDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2; + rssp->hdr.size = sizeof(rndis_recv_scale_param); + rssp->flag = 0; + rssp->hashinfo = RNDIS_HASH_FUNC_TOEPLITZ | RNDIS_HASH_IPV4 | + RNDIS_HASH_TCP_IPV4 | RNDIS_HASH_IPV6 | RNDIS_HASH_TCP_IPV6; + rssp->indirect_tabsize = 4 * ITAB_NUM; + rssp->indirect_taboffset = sizeof(rndis_recv_scale_param); + rssp->hashkey_size = HASH_KEYLEN; + rssp->hashkey_offset = rssp->indirect_taboffset + + rssp->indirect_tabsize; + + /* Set indirection table entries */ + itab = (uint32_t *)(rssp + 1); + for (i = 0; i < ITAB_NUM; i++) + itab[i] = i % num_queue; + + /* Set hash key values */ + keyp = (uint8_t *)((unsigned long)rssp + rssp->hashkey_offset); + for (i = 0; i < HASH_KEYLEN; i++) + keyp[i] = netvsc_hash_key[i]; + + ret = hv_rf_send_request(device, request, REMOTE_NDIS_SET_MSG); + if (ret != 0) { + goto cleanup; + } + + /* + * Wait for the response from the host. Another thread will signal + * us when the response has arrived. In the failure case, + * sema_timedwait() returns a non-zero status after waiting 5 seconds. + */ + ret = sema_timedwait(&request->wait_sema, 5 * hz); + if (ret == 0) { + /* Response received, check status */ + set_complete = &request->response_msg.msg.set_complete; + status = set_complete->status; + if (status != RNDIS_STATUS_SUCCESS) { + /* Bad response status, return error */ + if (bootverbose) + printf("Netvsc: Failed to set vRSS " + "parameters.\n"); + ret = -2; + } else { + if (bootverbose) + printf("Netvsc: Successfully set vRSS " + "parameters.\n"); + } + } else { + /* + * We cannot deallocate the request since we may still + * receive a send completion for it. + */ + printf("Netvsc: vRSS set timeout, id = %u, ret = %d\n", + request->request_msg.msg.init_request.request_id, ret); + goto exit; + } + +cleanup: + if (request != NULL) { + hv_put_rndis_request(device, request); + } +exit: + return (ret); +} + /* * RNDIS filter set packet filter * Sends an rndis request with the new filter, then waits for a response @@ -817,12 +970,15 @@ hv_rf_close_device(rndis_device *device) */ int hv_rf_on_device_add(struct hv_device *device, void *additl_info, - int nchan __unused) + int nchan) { int ret; netvsc_dev *net_dev; rndis_device *rndis_dev; + nvsp_msg *init_pkt; rndis_offload_params offloads; + struct rndis_recv_scale_cap rsscaps; + uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; device_t dev = device->device; @@ -888,6 +1044,67 @@ hv_rf_on_device_add(struct hv_device *de dev_info->link_state = rndis_dev->link_status; + net_dev->num_channel = 1; + if (net_dev->nvsp_version < NVSP_PROTOCOL_VERSION_5 || nchan == 1) + return (0); + + memset(&rsscaps, 0, rsscaps_size); + ret = hv_rf_query_device(rndis_dev, + RNDIS_OID_GEN_RSS_CAPABILITIES, + &rsscaps, &rsscaps_size); + if ((ret != 0) || (rsscaps.num_recv_que < 2)) { + device_printf(dev, "hv_rf_query_device failed or " + "rsscaps.num_recv_que < 2 \n"); + goto out; + } + device_printf(dev, "channel, offered %u, requested %d\n", + rsscaps.num_recv_que, nchan); + if (nchan > rsscaps.num_recv_que) + nchan = rsscaps.num_recv_que; + net_dev->num_channel = nchan; + + if (net_dev->num_channel == 1) { + device_printf(dev, "net_dev->num_channel == 1 under VRSS\n"); + goto out; + } + + /* request host to create sub channels */ + init_pkt = &net_dev->channel_init_packet; + memset(init_pkt, 0, sizeof(nvsp_msg)); + + init_pkt->hdr.msg_type = nvsp_msg5_type_subchannel; + init_pkt->msgs.vers_5_msgs.subchannel_request.op = + NVSP_SUBCHANNE_ALLOCATE; + init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = + net_dev->num_channel - 1; + + ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, + HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, + HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + if (ret != 0) { + device_printf(dev, "Fail to allocate subchannel\n"); + goto out; + } + + sema_wait(&net_dev->channel_init_sema); + + if (init_pkt->msgs.vers_5_msgs.subchn_complete.status != *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Thu Jun 16 03:04:18 2016 Return-Path: Delivered-To: svn-src-stable-10@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 788DEA47192; Thu, 16 Jun 2016 03:04:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 4922A11AD; Thu, 16 Jun 2016 03:04:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G34H3b047599; Thu, 16 Jun 2016 03:04:17 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G34HKN047592; Thu, 16 Jun 2016 03:04:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160304.u5G34HKN047592@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 03:04:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301946 - in stable/10/sys/dev/hyperv: include utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 03:04:18 -0000 Author: sephe Date: Thu Jun 16 03:04:16 2016 New Revision: 301946 URL: https://svnweb.freebsd.org/changeset/base/301946 Log: MFC 297142,297143,297176,297177,297178,297221 297142 hyperv: Factor out snprinf_hv_guid() Submitted by: Ju Sun Reviewed by: Dexuan Cui , sephe MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5651 297143 hyperv/vmbus: Implement bus_child_pnpinfo_str method Submitted by: Jun Su Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5669 297176 hyperv/evttimer: Use an independent message slot so that it can work Using the same message slot as the other types of the messages has the side effect that the event timer message could be deferred to the swi threads to run (lacking of trapframe and the original code didn't even handle that, so the event timer was actually broken). As of this commit we use an independent message slot for event timer, so that we could handle all of event timer messages in the interrupt handler directly. Note, the message slot for event timer is still bind to the same interrupt vector as the other types of messages. Submitted by: Jun Su Reviewed by: sephe Discussed with: Jun Su , Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5696 297177 hyperv/vmbus: Use taskqueue_fast for non-performance critical messages This gets rid of the per-cpu SWIs. Submitted by: Jun Su Reviewed by: Dexuan Cui , sephe MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5215 297178 hyperv/vmbus: Remove NULL check for taskqueue_create_fast(M_WAITOK) Submitted by: Jun Su Reviewed by: Dexuan Cui , sephe MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5215 297221 hyperv/vmbus: Create per-cpu fast taskqueue for msg handling Using one taskqueue does not work, since the EOM MSR must be written on the msg's owner CPU. Noticed by: Jun Su Discussed with: Jun Su , Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/vmbus/hv_et.c stable/10/sys/dev/hyperv/vmbus/hv_hv.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Thu Jun 16 03:02:27 2016 (r301945) +++ stable/10/sys/dev/hyperv/include/hyperv.h Thu Jun 16 03:04:16 2016 (r301946) @@ -124,6 +124,8 @@ typedef struct hv_guid { unsigned char data[16]; } __packed hv_guid; +int snprintf_hv_guid(char *, size_t, const hv_guid *); + #define HV_NIC_GUID \ .data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, \ 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Jun 16 03:02:27 2016 (r301945) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Jun 16 03:04:16 2016 (r301946) @@ -304,28 +304,11 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru { int err_ip, err_subnet, err_gway, err_dns, err_adap; int UNUSED_FLAG = 1; - int guid_index; struct hv_device *hv_dev; /* GUID Data Structure */ hn_softc_t *sc; /* hn softc structure */ char if_name[4]; - unsigned char guid_instance[40]; - char *guid_data = NULL; char buf[39]; - struct guid_extract { - char a1[2]; - char a2[2]; - char a3[2]; - char a4[2]; - char b1[2]; - char b2[2]; - char c1[2]; - char c2[2]; - char d[4]; - char e[12]; - }; - - struct guid_extract *id; device_t *devs; int devcnt; @@ -352,17 +335,7 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru /* Trying to find GUID of Network Device */ hv_dev = sc->hn_dev_obj; - for (guid_index = 0; guid_index < 16; guid_index++) { - sprintf(&guid_instance[guid_index * 2], "%02x", - hv_dev->device_id.data[guid_index]); - } - - guid_data = (char *)guid_instance; - id = (struct guid_extract *)guid_data; - snprintf(buf, sizeof(buf), "{%.2s%.2s%.2s%.2s-%.2s%.2s-%.2s%.2s-%.4s-%s}", - id->a4, id->a3, id->a2, id->a1, - id->b2, id->b1, id->c2, id->c1, id->d, id->e); - guid_data = NULL; + snprintf_hv_guid(buf, sizeof(buf), &hv_dev->device_id); sprintf(if_name, "%s%d", "hn", device_get_unit(devs[devcnt])); if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, 39) == 0) { Modified: stable/10/sys/dev/hyperv/vmbus/hv_et.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_et.c Thu Jun 16 03:02:27 2016 (r301945) +++ stable/10/sys/dev/hyperv/vmbus/hv_et.c Thu Jun 16 03:04:16 2016 (r301946) @@ -60,7 +60,7 @@ hv_et_start(struct eventtimer *et, sbint timer_cfg.as_uint64 = 0; timer_cfg.auto_enable = 1; - timer_cfg.sintx = HV_VMBUS_MESSAGE_SINT; + timer_cfg.sintx = HV_VMBUS_TIMER_SINT; periodticks[curcpu] = sbintime2tick(periodtime); if (firsttime == 0) Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_hv.c Thu Jun 16 03:02:27 2016 (r301945) +++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c Thu Jun 16 03:04:16 2016 (r301946) @@ -370,6 +370,9 @@ hv_vmbus_synic_init(void *arg) wrmsr(HV_X64_MSR_SINT0 + HV_VMBUS_MESSAGE_SINT, shared_sint.as_uint64_t); + wrmsr(HV_X64_MSR_SINT0 + HV_VMBUS_TIMER_SINT, + shared_sint.as_uint64_t); + /* Enable the global synic bit */ sctrl.as_uint64_t = rdmsr(HV_X64_MSR_SCONTROL); sctrl.u.enable = 1; @@ -406,12 +409,23 @@ void hv_vmbus_synic_cleanup(void *arg) shared_sint.u.masked = 1; /* - * Disable the interrupt + * Disable the interrupt 0 */ wrmsr( HV_X64_MSR_SINT0 + HV_VMBUS_MESSAGE_SINT, shared_sint.as_uint64_t); + shared_sint.as_uint64_t = rdmsr( + HV_X64_MSR_SINT0 + HV_VMBUS_TIMER_SINT); + + shared_sint.u.masked = 1; + + /* + * Disable the interrupt 1 + */ + wrmsr( + HV_X64_MSR_SINT0 + HV_VMBUS_TIMER_SINT, + shared_sint.as_uint64_t); simp.as_uint64_t = rdmsr(HV_X64_MSR_SIMP); simp.u.simp_enabled = 0; simp.u.base_simp_gpa = 0; Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Thu Jun 16 03:02:27 2016 (r301945) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Thu Jun 16 03:04:16 2016 (r301946) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "hv_vmbus_priv.h" #include @@ -75,7 +76,7 @@ static char *vmbus_ids[] = { "VMBUS", NU * the hypervisor. */ static void -vmbus_msg_swintr(void *arg) +vmbus_msg_swintr(void *arg, int pending __unused) { int cpu; void* page_addr; @@ -178,12 +179,15 @@ hv_vmbus_isr(struct trapframe *frame) /* Check if there are actual msgs to be process */ page_addr = hv_vmbus_g_context.syn_ic_msg_page[cpu]; - msg = (hv_vmbus_message*) page_addr + HV_VMBUS_MESSAGE_SINT; + msg = (hv_vmbus_message*) page_addr + HV_VMBUS_TIMER_SINT; /* we call eventtimer process the message */ if (msg->header.message_type == HV_MESSAGE_TIMER_EXPIRED) { msg->header.message_type = HV_MESSAGE_TYPE_NONE; + /* call intrrupt handler of event timer */ + hv_et_intr(frame); + /* * Make sure the write to message_type (ie set to * HV_MESSAGE_TYPE_NONE) happens before we read the @@ -204,12 +208,12 @@ hv_vmbus_isr(struct trapframe *frame) */ wrmsr(HV_X64_MSR_EOM, 0); } - hv_et_intr(frame); - return (FILTER_HANDLED); } + msg = (hv_vmbus_message*) page_addr + HV_VMBUS_MESSAGE_SINT; if (msg->header.message_type != HV_MESSAGE_TYPE_NONE) { - swi_sched(hv_vmbus_g_context.msg_swintr[cpu], 0); + taskqueue_enqueue(hv_vmbus_g_context.hv_msg_tq[cpu], + &hv_vmbus_g_context.hv_msg_task[cpu]); } return (FILTER_HANDLED); @@ -287,6 +291,23 @@ vmbus_write_ivar( return (ENOENT); } +static int +vmbus_child_pnpinfo_str(device_t dev, device_t child, char *buf, size_t buflen) +{ + char guidbuf[40]; + struct hv_device *dev_ctx = device_get_ivars(child); + + strlcat(buf, "classid=", buflen); + snprintf_hv_guid(guidbuf, sizeof(guidbuf), &dev_ctx->class_id); + strlcat(buf, guidbuf, buflen); + + strlcat(buf, " deviceid=", buflen); + snprintf_hv_guid(guidbuf, sizeof(guidbuf), &dev_ctx->device_id); + strlcat(buf, guidbuf, buflen); + + return (0); +} + struct hv_device* hv_vmbus_child_device_create( hv_guid type, @@ -308,15 +329,17 @@ hv_vmbus_child_device_create( return (child_dev); } -static void -print_dev_guid(struct hv_device *dev) +int +snprintf_hv_guid(char *buf, size_t sz, const hv_guid *guid) { - int i; - unsigned char guid_name[100]; - for (i = 0; i < 32; i += 2) - sprintf(&guid_name[i], "%02x", dev->class_id.data[i / 2]); - if(bootverbose) - printf("VMBUS: Class ID: %s\n", guid_name); + int cnt; + const unsigned char *d = guid->data; + + cnt = snprintf(buf, sz, + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + d[3], d[2], d[1], d[0], d[5], d[4], d[7], d[6], + d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); + return (cnt); } int @@ -325,8 +348,11 @@ hv_vmbus_child_device_register(struct hv device_t child; int ret = 0; - print_dev_guid(child_dev); - + if (bootverbose) { + char name[40]; + snprintf_hv_guid(name, sizeof(name), &child_dev->class_id); + printf("VMBUS: Class ID: %s\n", name); + } child = device_add_child(vmbus_devp, NULL, -1); child_dev->device = child; @@ -506,9 +532,6 @@ vmbus_bus_init(void) setup_args.vector = hv_vmbus_g_context.hv_cb_vector; CPU_FOREACH(j) { - hv_vmbus_g_context.hv_msg_intr_event[j] = NULL; - hv_vmbus_g_context.msg_swintr[j] = NULL; - snprintf(buf, sizeof(buf), "cpu%d:hyperv", j); intrcnt_add(buf, &hv_vmbus_intr_cpu[j]); @@ -527,11 +550,6 @@ vmbus_bus_init(void) */ hv_vmbus_g_context.hv_event_queue[j] = taskqueue_create_fast("hyperv event", M_WAITOK, taskqueue_thread_enqueue, &hv_vmbus_g_context.hv_event_queue[j]); - if (hv_vmbus_g_context.hv_event_queue[j] == NULL) { - if (bootverbose) - printf("VMBUS: failed to setup taskqueue\n"); - goto cleanup1; - } taskqueue_start_threads(&hv_vmbus_g_context.hv_event_queue[j], 1, PI_NET, "hvevent%d", j); @@ -541,29 +559,20 @@ vmbus_bus_init(void) taskqueue_drain(hv_vmbus_g_context.hv_event_queue[j], &cpuset_task); /* - * Setup software interrupt thread and handler for msg handling. + * Setup per-cpu tasks and taskqueues to handle msg. */ - ret = swi_add(&hv_vmbus_g_context.hv_msg_intr_event[j], - "hv_msg", vmbus_msg_swintr, (void *)(long)j, SWI_CLOCK, 0, - &hv_vmbus_g_context.msg_swintr[j]); - if (ret) { - if(bootverbose) - printf("VMBUS: failed to setup msg swi for " - "cpu %d\n", j); - goto cleanup1; - } + hv_vmbus_g_context.hv_msg_tq[j] = taskqueue_create_fast( + "hyperv msg", M_WAITOK, taskqueue_thread_enqueue, + &hv_vmbus_g_context.hv_msg_tq[j]); + taskqueue_start_threads(&hv_vmbus_g_context.hv_msg_tq[j], 1, PI_NET, + "hvmsg%d", j); + TASK_INIT(&hv_vmbus_g_context.hv_msg_task[j], 0, + vmbus_msg_swintr, (void *)(long)j); - /* - * Bind the swi thread to the cpu. - */ - ret = intr_event_bind(hv_vmbus_g_context.hv_msg_intr_event[j], - j); - if (ret) { - if(bootverbose) - printf("VMBUS: failed to bind msg swi thread " - "to cpu %d\n", j); - goto cleanup1; - } + CPU_SETOF(j, &cpu_mask); + TASK_INIT(&cpuset_task, 0, vmbus_cpuset_setthread_task, &cpu_mask); + taskqueue_enqueue(hv_vmbus_g_context.hv_msg_tq[j], &cpuset_task); + taskqueue_drain(hv_vmbus_g_context.hv_msg_tq[j], &cpuset_task); /* * Prepare the per cpu msg and event pages to be called on each cpu. @@ -603,11 +612,10 @@ vmbus_bus_init(void) * remove swi and vmbus callback vector; */ CPU_FOREACH(j) { - if (hv_vmbus_g_context.hv_event_queue[j] != NULL) + if (hv_vmbus_g_context.hv_event_queue[j] != NULL) { taskqueue_free(hv_vmbus_g_context.hv_event_queue[j]); - if (hv_vmbus_g_context.msg_swintr[j] != NULL) - swi_remove(hv_vmbus_g_context.msg_swintr[j]); - hv_vmbus_g_context.hv_msg_intr_event[j] = NULL; + hv_vmbus_g_context.hv_event_queue[j] = NULL; + } } vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector); @@ -672,11 +680,10 @@ vmbus_bus_exit(void) /* remove swi */ CPU_FOREACH(i) { - if (hv_vmbus_g_context.hv_event_queue[i] != NULL) + if (hv_vmbus_g_context.hv_event_queue[i] != NULL) { taskqueue_free(hv_vmbus_g_context.hv_event_queue[i]); - if (hv_vmbus_g_context.msg_swintr[i] != NULL) - swi_remove(hv_vmbus_g_context.msg_swintr[i]); - hv_vmbus_g_context.hv_msg_intr_event[i] = NULL; + hv_vmbus_g_context.hv_event_queue[i] = NULL; + } } vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector); @@ -741,6 +748,7 @@ static device_method_t vmbus_methods[] = DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_read_ivar, vmbus_read_ivar), DEVMETHOD(bus_write_ivar, vmbus_write_ivar), + DEVMETHOD(bus_child_pnpinfo_str, vmbus_child_pnpinfo_str), { 0, 0 } }; Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Thu Jun 16 03:02:27 2016 (r301945) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Thu Jun 16 03:04:16 2016 (r301946) @@ -181,7 +181,8 @@ enum { HV_VMBUS_EVENT_PORT_ID = 2, HV_VMBUS_MONITOR_CONNECTION_ID = 3, HV_VMBUS_MONITOR_PORT_ID = 3, - HV_VMBUS_MESSAGE_SINT = 2 + HV_VMBUS_MESSAGE_SINT = 2, + HV_VMBUS_TIMER_SINT = 4, }; #define HV_PRESENT_BIT 0x80000000 @@ -204,8 +205,8 @@ typedef struct { * event and msg handling. */ struct taskqueue *hv_event_queue[MAXCPU]; - struct intr_event *hv_msg_intr_event[MAXCPU]; - void *msg_swintr[MAXCPU]; + struct taskqueue *hv_msg_tq[MAXCPU]; + struct task hv_msg_task[MAXCPU]; /* * Host use this vector to intrrupt guest for vmbus channel * event and msg. From owner-svn-src-stable-10@freebsd.org Thu Jun 16 03:16:45 2016 Return-Path: Delivered-To: svn-src-stable-10@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 019A9A473AE; Thu, 16 Jun 2016 03:16:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 D12A816FC; Thu, 16 Jun 2016 03:16:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G3GiLQ051307; Thu, 16 Jun 2016 03:16:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G3Giks051306; Thu, 16 Jun 2016 03:16:44 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160316.u5G3Giks051306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 03:16:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301947 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 03:16:45 -0000 Author: sephe Date: Thu Jun 16 03:16:43 2016 New Revision: 301947 URL: https://svnweb.freebsd.org/changeset/base/301947 Log: MFC 297180,297181,297182 297180 hyperv/hn: Reduce TCP segment aggregation limit for multiple RX rings This mainly used to improve ACK timeliness when multiple RX rings are enabled. This value gives the best performance in both Azure and Hyper-V environment, w/ both 10Ge and 40Ge using non-{INVARIANTS,WITNESS} kernel. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5691 297181 hyperv/hn: Factor out hn_set_lro_lenlim() MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5692 297182 hyperv/hn: When short of mbufs on the RX path, don't spam the console. Instead, increase the IQDROPS counter. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5693 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 03:04:16 2016 (r301946) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 03:16:43 2016 (r301947) @@ -183,6 +183,7 @@ struct hn_txdesc { #define HN_CSUM_ASSIST_WIN8 (CSUM_IP | CSUM_TCP) #define HN_CSUM_ASSIST (CSUM_IP | CSUM_UDP | CSUM_TCP) +#define HN_LRO_LENLIM_MULTIRX_DEF (12 * ETHERMTU) #define HN_LRO_LENLIM_DEF (25 * ETHERMTU) /* YYY 2*MTU is a bit rough, but should be good enough. */ #define HN_LRO_LENLIM_MIN(ifp) (2 * (ifp)->if_mtu) @@ -339,6 +340,17 @@ static void hn_xmit_txeof(struct hn_tx_r static void hn_xmit_taskfunc(void *, int); static void hn_xmit_txeof_taskfunc(void *, int); +#if __FreeBSD_version >= 1100099 +static void +hn_set_lro_lenlim(struct hn_softc *sc, int lenlim) +{ + int i; + + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) + sc->hn_rx_ring[i].hn_lro.lro_length_lim = lenlim; +} +#endif + static int hn_ifmedia_upd(struct ifnet *ifp __unused) { @@ -550,6 +562,16 @@ netvsc_attach(device_t dev) device_printf(dev, "%d TX ring, %d RX ring\n", sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); +#if __FreeBSD_version >= 1100099 + if (sc->hn_rx_ring_inuse > 1) { + /* + * Reduce TCP segment aggregation limit for multiple + * RX rings to increase ACK timeliness. + */ + hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MULTIRX_DEF); + } +#endif + if (device_info.link_state == 0) { sc->hn_carrier = 1; } @@ -1258,8 +1280,10 @@ netvsc_recv(struct hv_vmbus_channel *cha return (0); } else if (packet->tot_data_buf_len <= MHLEN) { m_new = m_gethdr(M_NOWAIT, MT_DATA); - if (m_new == NULL) + if (m_new == NULL) { + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return (0); + } memcpy(mtod(m_new, void *), packet->data, packet->tot_data_buf_len); m_new->m_pkthdr.len = m_new->m_len = packet->tot_data_buf_len; @@ -1279,7 +1303,7 @@ netvsc_recv(struct hv_vmbus_channel *cha m_new = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, size); if (m_new == NULL) { - if_printf(ifp, "alloc mbuf failed.\n"); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return (0); } @@ -1469,13 +1493,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, */ NV_LOCK(sc); if (sc->hn_rx_ring[0].hn_lro.lro_length_lim < - HN_LRO_LENLIM_MIN(ifp)) { - int i; - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { - sc->hn_rx_ring[i].hn_lro.lro_length_lim = - HN_LRO_LENLIM_MIN(ifp); - } - } + HN_LRO_LENLIM_MIN(ifp)) + hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); NV_UNLOCK(sc); #endif @@ -1808,7 +1827,7 @@ hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS { struct hn_softc *sc = arg1; unsigned int lenlim; - int error, i; + int error; lenlim = sc->hn_rx_ring[0].hn_lro.lro_length_lim; error = sysctl_handle_int(oidp, &lenlim, 0, req); @@ -1820,8 +1839,7 @@ hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS return EINVAL; NV_LOCK(sc); - for (i = 0; i < sc->hn_rx_ring_inuse; ++i) - sc->hn_rx_ring[i].hn_lro.lro_length_lim = lenlim; + hn_set_lro_lenlim(sc, lenlim); NV_UNLOCK(sc); return 0; } From owner-svn-src-stable-10@freebsd.org Thu Jun 16 03:25:27 2016 Return-Path: Delivered-To: svn-src-stable-10@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 991B3A47580; Thu, 16 Jun 2016 03:25:27 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5A7BA1B45; Thu, 16 Jun 2016 03:25:27 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G3PQTk054956; Thu, 16 Jun 2016 03:25:26 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G3PQbl054952; Thu, 16 Jun 2016 03:25:26 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160325.u5G3PQbl054952@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 03:25:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301948 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 03:25:27 -0000 Author: sephe Date: Thu Jun 16 03:25:26 2016 New Revision: 301948 URL: https://svnweb.freebsd.org/changeset/base/301948 Log: MFC 297220 hyperv/utils: Allow hint to disable individual utility Reviewed by: kib, Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5714 Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Jun 16 03:16:43 2016 (r301947) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Jun 16 03:25:26 2016 (r301948) @@ -94,6 +94,10 @@ static int hv_heartbeat_probe(device_t dev) { const char *p = vmbus_get_type(dev); + + if (resource_disabled("hvheartbeat", 0)) + return ENXIO; + if (!memcmp(p, &service_guid, sizeof(hv_guid))) { device_set_desc(dev, "Hyper-V Heartbeat Service"); return BUS_PROBE_DEFAULT; Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Jun 16 03:16:43 2016 (r301947) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Jun 16 03:25:26 2016 (r301948) @@ -863,6 +863,10 @@ static int hv_kvp_probe(device_t dev) { const char *p = vmbus_get_type(dev); + + if (resource_disabled("hvkvp", 0)) + return ENXIO; + if (!memcmp(p, &service_guid, sizeof(hv_guid))) { device_set_desc(dev, "Hyper-V KVP Service"); return BUS_PROBE_DEFAULT; Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Jun 16 03:16:43 2016 (r301947) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Jun 16 03:25:26 2016 (r301948) @@ -116,6 +116,10 @@ static int hv_shutdown_probe(device_t dev) { const char *p = vmbus_get_type(dev); + + if (resource_disabled("hvshutdown", 0)) + return ENXIO; + if (!memcmp(p, &service_guid, sizeof(hv_guid))) { device_set_desc(dev, "Hyper-V Shutdown Service"); return BUS_PROBE_DEFAULT; Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Jun 16 03:16:43 2016 (r301947) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Jun 16 03:25:26 2016 (r301948) @@ -171,6 +171,10 @@ static int hv_timesync_probe(device_t dev) { const char *p = vmbus_get_type(dev); + + if (resource_disabled("hvtimesync", 0)) + return ENXIO; + if (!memcmp(p, &service_guid, sizeof(hv_guid))) { device_set_desc(dev, "Hyper-V Time Synch Service"); return BUS_PROBE_DEFAULT; From owner-svn-src-stable-10@freebsd.org Thu Jun 16 04:21:28 2016 Return-Path: Delivered-To: svn-src-stable-10@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 79E33A5349F; Thu, 16 Jun 2016 04:21:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 47C371653; Thu, 16 Jun 2016 04:21:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G4LROR074329; Thu, 16 Jun 2016 04:21:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G4LRx2074327; Thu, 16 Jun 2016 04:21:27 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160421.u5G4LRx2074327@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 04:21:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301949 - stable/10/sys/netinet X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 04:21:28 -0000 Author: sephe Date: Thu Jun 16 04:21:27 2016 New Revision: 301949 URL: https://svnweb.freebsd.org/changeset/base/301949 Log: MFC 297265 tcp/lro: Return TCP_LRO_NO_ENTRIES if we are short of LRO entries. So that callers could react accordingly. Reviewed by: gallatin (no objection) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5695 Modified: stable/10/sys/netinet/tcp_lro.c stable/10/sys/netinet/tcp_lro.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/tcp_lro.c ============================================================================== --- stable/10/sys/netinet/tcp_lro.c Thu Jun 16 03:25:26 2016 (r301948) +++ stable/10/sys/netinet/tcp_lro.c Thu Jun 16 04:21:27 2016 (r301949) @@ -570,7 +570,7 @@ tcp_lro_rx(struct lro_ctrl *lc, struct m /* Try to find an empty slot. */ if (SLIST_EMPTY(&lc->lro_free)) - return (TCP_LRO_CANNOT); + return (TCP_LRO_NO_ENTRIES); /* Start a new segment chain. */ le = SLIST_FIRST(&lc->lro_free); Modified: stable/10/sys/netinet/tcp_lro.h ============================================================================== --- stable/10/sys/netinet/tcp_lro.h Thu Jun 16 03:25:26 2016 (r301948) +++ stable/10/sys/netinet/tcp_lro.h Thu Jun 16 04:21:27 2016 (r301949) @@ -90,6 +90,7 @@ void tcp_lro_flush_inactive(struct lro_c void tcp_lro_flush(struct lro_ctrl *, struct lro_entry *); int tcp_lro_rx(struct lro_ctrl *, struct mbuf *, uint32_t); +#define TCP_LRO_NO_ENTRIES -2 #define TCP_LRO_CANNOT -1 #define TCP_LRO_NOT_SUPPORTED 1 From owner-svn-src-stable-10@freebsd.org Thu Jun 16 04:32:12 2016 Return-Path: Delivered-To: svn-src-stable-10@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 95A1FA536C4; Thu, 16 Jun 2016 04:32:12 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 640A21CAB; Thu, 16 Jun 2016 04:32:12 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G4WBFV080498; Thu, 16 Jun 2016 04:32:11 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G4WB31080497; Thu, 16 Jun 2016 04:32:11 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160432.u5G4WB31080497@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 04:32:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301950 - stable/10/sys/dev/vt/hw/vga X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 04:32:12 -0000 Author: sephe Date: Thu Jun 16 04:32:11 2016 New Revision: 301950 URL: https://svnweb.freebsd.org/changeset/base/301950 Log: MFC 297334 vt: Use textmode when we're running on hypervisors The graphic mode is noticeably slow on hypervisors, especially on Hyper-V (1 second to each line). Submitted by: Dexuan Cui Reviewed by: kib, sephe, royger (early loader version) MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5739 Modified: stable/10/sys/dev/vt/hw/vga/vt_vga.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/vt/hw/vga/vt_vga.c ============================================================================== --- stable/10/sys/dev/vt/hw/vga/vt_vga.c Thu Jun 16 04:21:27 2016 (r301949) +++ stable/10/sys/dev/vt/hw/vga/vt_vga.c Thu Jun 16 04:32:11 2016 (r301950) @@ -1200,7 +1200,6 @@ vga_init(struct vt_device *vd) if (vd->vd_softc == NULL) vd->vd_softc = (void *)&vga_conssoftc; sc = vd->vd_softc; - textmode = 0; #if defined(__amd64__) || defined(__i386__) sc->vga_fb_tag = X86_BUS_SPACE_MEM; @@ -1217,6 +1216,13 @@ vga_init(struct vt_device *vd) bus_space_map(sc->vga_reg_tag, VGA_REG_BASE, VGA_REG_SIZE, 0, &sc->vga_reg_handle); + /* + * If "hw.vga.textmode" is not set and we're running on hypervisor, + * we use text mode by default, this is because when we're on + * hypervisor, vt(4) is usually much slower in graphics mode than + * in text mode, especially when we're on Hyper-V. + */ + textmode = vm_guest != VM_GUEST_NO; TUNABLE_INT_FETCH("hw.vga.textmode", &textmode); if (textmode) { vd->vd_flags |= VDF_TEXTMODE; From owner-svn-src-stable-10@freebsd.org Thu Jun 16 05:12:30 2016 Return-Path: Delivered-To: svn-src-stable-10@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 390B0A4704E; Thu, 16 Jun 2016 05:12:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 149C01E70; Thu, 16 Jun 2016 05:12:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G5CTkV095228; Thu, 16 Jun 2016 05:12:29 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G5CTR4095225; Thu, 16 Jun 2016 05:12:29 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160512.u5G5CTR4095225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 05:12:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301951 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 05:12:30 -0000 Author: sephe Date: Thu Jun 16 05:12:28 2016 New Revision: 301951 URL: https://svnweb.freebsd.org/changeset/base/301951 Log: MFC 297636,297800,297801,297805,297807,297808 297636 hyperv: Typo in r297634 Noticed by: hiren MFC after: 1 week Sponsored by: Microsoft OSTC 297800 hyperv/vmbus: Nuke unused function MFC after: 1 week Sponsored by: Microsoft OSTC 297801 hyperv/vmbus: Get rid of max_leaf detection; this is actually not used. It will be replaced by a new one. MFC after: 1 week Sponsored by: Microsoft OSTC 297805 hyperv: Break long line MFC after: 1 week Sponsored by: Microsoft OSTC 297807 hyperv: Print more features And add comment about the MSR features. MFC after: 1 week Sponsored by: Microsoft OSTC 297808 hyperv: Define macro for Hyper-V interface Suggested by: rpokala MFC after: 1 week Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_hv.c Thu Jun 16 04:32:11 2016 (r301950) +++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c Thu Jun 16 05:12:28 2016 (r301951) @@ -48,12 +48,16 @@ __FBSDID("$FreeBSD$"); #define HV_NANOSECONDS_PER_SEC 1000000000L +#define HYPERV_INTERFACE 0x31237648 /* HV#1 */ static u_int hv_get_timecount(struct timecounter *tc); u_int hyperv_features; u_int hyperv_recommends; +static u_int hyperv_pm_features; +static u_int hyperv_features3; + /** * Globals */ @@ -74,47 +78,6 @@ hv_get_timecount(struct timecounter *tc) } /** - * @brief Query the cpuid for presence of windows hypervisor - */ -int -hv_vmbus_query_hypervisor_presence(void) -{ - if (vm_guest != VM_GUEST_HV) - return (0); - - return (hv_high >= HV_X64_CPUID_MIN && hv_high <= HV_X64_CPUID_MAX); -} - -/** - * @brief Get version of the windows hypervisor - */ -static int -hv_vmbus_get_hypervisor_version(void) -{ - u_int regs[4]; - unsigned int maxLeaf; - unsigned int op; - - /* - * Its assumed that this is called after confirming that - * Viridian is present - * Query id and revision. - */ - op = HV_CPU_ID_FUNCTION_HV_VENDOR_AND_MAX_FUNCTION; - do_cpuid(op, regs); - - maxLeaf = regs[0]; - op = HV_CPU_ID_FUNCTION_HV_INTERFACE; - do_cpuid(op, regs); - - if (maxLeaf >= HV_CPU_ID_FUNCTION_MS_HV_VERSION) { - op = HV_CPU_ID_FUNCTION_MS_HV_VERSION; - do_cpuid(op, regs); - } - return (maxLeaf); -} - -/** * @brief Invoke the specified hypercall */ static uint64_t @@ -163,7 +126,6 @@ hv_vmbus_do_hypercall(uint64_t control, int hv_vmbus_init(void) { - int max_leaf; hv_vmbus_x64_msr_hypercall_contents hypercall_msr; void* virt_addr = 0; @@ -180,8 +142,6 @@ hv_vmbus_init(void) if (vm_guest != VM_GUEST_HV) goto cleanup; - max_leaf = hv_vmbus_get_hypervisor_version(); - /* * Write our OS info */ @@ -457,7 +417,7 @@ hyperv_identify(void) op = HV_CPU_ID_FUNCTION_HV_INTERFACE; do_cpuid(op, regs); - if (regs[0] != 0x31237648 /* HV#1 */) + if (regs[0] != HYPERV_INTERFACE) return (false); op = HV_CPU_ID_FUNCTION_MS_HV_FEATURES; @@ -470,27 +430,50 @@ hyperv_identify(void) return (false); } hyperv_features = regs[0]; + hyperv_pm_features = regs[2]; + hyperv_features3 = regs[3]; op = HV_CPU_ID_FUNCTION_MS_HV_VERSION; do_cpuid(op, regs); printf("Hyper-V Version: %d.%d.%d [SP%d]\n", regs[1] >> 16, regs[1] & 0xffff, regs[0], regs[2]); - printf(" Features: 0x%b\n", hyperv_features, + printf(" Features=0x%b\n", hyperv_features, + "\020" + "\001VPRUNTIME" /* MSR_VP_RUNTIME */ + "\002TMREFCNT" /* MSR_TIME_REF_COUNT */ + "\003SYNIC" /* MSRs for SynIC */ + "\004SYNTM" /* MSRs for SynTimer */ + "\005APIC" /* MSR_{EOI,ICR,TPR} */ + "\006HYERCALL" /* MSR_{GUEST_OS_ID,HYPERCALL} */ + "\007VPINDEX" /* MSR_VP_INDEX */ + "\010RESET" /* MSR_RESET */ + "\011STATS" /* MSR_STATS_ */ + "\012REFTSC" /* MSR_REFERENCE_TSC */ + "\013IDLE" /* MSR_GUEST_IDLE */ + "\014TMFREQ" /* MSR_{TSC,APIC}_FREQUENCY */ + "\015DEBUG"); /* MSR_SYNTH_DEBUG_ */ + printf(" PM Features=max C%u, 0x%b\n", + HV_PM_FEATURE_CSTATE(hyperv_pm_features), + (hyperv_pm_features & ~HV_PM_FEATURE_CSTATE_MASK), + "\020" + "\005C3HPET"); /* HPET is required for C3 state */ + printf(" Features3=0x%b\n", hyperv_features3, "\020" - "\001VPRUNTIME" - "\002TMREFCNT" - "\003SYNCIC" - "\004SYNCTM" - "\005APIC" - "\006HYERCALL" - "\007VPINDEX" - "\010RESET" - "\011STATS" - "\012REFTSC" - "\013IDLE" - "\014TMFREQ" - "\015DEBUG"); + "\001MWAIT" /* MWAIT */ + "\002DEBUG" /* guest debug support */ + "\003PERFMON" /* performance monitor */ + "\004PCPUDPE" /* physical CPU dynamic partition event */ + "\005XMMHC" /* hypercall input through XMM regs */ + "\006IDLE" /* guest idle support */ + "\007SLEEP" /* hypervisor sleep support */ + "\010NUMA" /* NUMA distance query support */ + "\011TMFREQ" /* timer frequency query (TSC, LAPIC) */ + "\012SYNCMC" /* inject synthetic machine checks */ + "\013CRASH" /* MSRs for guest crash */ + "\014DEBUGMSR" /* MSRs for guest debug */ + "\015NPIEP" /* NPIEP */ + "\016HVDIS"); /* disabling hypervisor */ op = HV_CPU_ID_FUNCTION_MS_HV_ENLIGHTENMENT_INFORMATION; do_cpuid(op, regs); @@ -528,4 +511,5 @@ hyperv_init(void *dummy __unused) tc_init(&hv_timecounter); } } -SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init, NULL); +SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init, + NULL); Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Thu Jun 16 04:32:11 2016 (r301950) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Thu Jun 16 05:12:28 2016 (r301951) @@ -120,7 +120,7 @@ handled: * * NOTE: * mb() is used here, since atomic_thread_fence_seq_cst() - * will become compler fence on UP kernel. + * will become compiler fence on UP kernel. */ mb(); @@ -197,7 +197,7 @@ hv_vmbus_isr(struct trapframe *frame) * * NOTE: * mb() is used here, since atomic_thread_fence_seq_cst() - * will become compler fence on UP kernel. + * will become compiler fence on UP kernel. */ mb(); Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Thu Jun 16 04:32:11 2016 (r301950) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Thu Jun 16 05:12:28 2016 (r301951) @@ -475,12 +475,23 @@ typedef enum { HV_CPU_ID_FUNCTION_MS_HV_HARDWARE_FEATURE = 0x40000006 } hv_vmbus_cpuid_function; -#define HV_FEATURE_MSR_TIME_REFCNT (1 << 1) -#define HV_FEATURE_MSR_SYNCIC (1 << 2) -#define HV_FEATURE_MSR_STIMER (1 << 3) -#define HV_FEATURE_MSR_APIC (1 << 4) -#define HV_FEATURE_MSR_HYPERCALL (1 << 5) -#define HV_FEATURE_MSR_GUEST_IDLE (1 << 10) +#define HV_FEATURE_MSR_TIME_REFCNT 0x0002 /* MSR_TIME_REF_COUNT */ +#define HV_FEATURE_MSR_SYNIC 0x0004 /* MSRs for SynIC */ +#define HV_FEATURE_MSR_SYNTIMER 0x0008 /* MSRs for SynTimer */ +#define HV_FEATURE_MSR_APIC 0x0010 /* MSR_{EOI,ICR,TPR} */ +#define HV_FEATURE_MSR_HYPERCALL 0x0020 /* MSR_{GUEST_OS_ID,HYPERCALL} */ +#define HV_FEATURE_MSR_GUEST_IDLE 0x0400 /* MSR_GUEST_IDLE */ + +#define HV_PM_FEATURE_CSTATE_MASK 0x000f +#define HV_PM_FEATURE_C3_HPET 0x0010 /* C3 requires HPET */ +#define HV_PM_FEATURE_CSTATE(f) ((f) & HV_PM_FEATURE_CSTATE_MASK) + +#define HV_FEATURE3_MWAIT 0x0001 /* MWAIT */ +#define HV_FEATURE3_XMM_HYPERCALL 0x0010 /* hypercall input through XMM regs */ +#define HV_FEATURE3_GUEST_IDLE 0x0020 /* guest idle support */ +#define HV_FEATURE3_NUMA 0x0080 /* NUMA distance query support */ +#define HV_FEATURE3_TIME_FREQ 0x0100 /* timer frequency query (TSC, LAPIC) */ +#define HV_FEATURE3_MSR_CRASH 0x0400 /* MSRs for guest crash */ /* * Define the format of the SIMP register @@ -714,7 +725,6 @@ uint16_t hv_vmbus_post_msg_via_msg_ipc( uint16_t hv_vmbus_signal_event(void *con_id); void hv_vmbus_synic_init(void *irq_arg); void hv_vmbus_synic_cleanup(void *arg); -int hv_vmbus_query_hypervisor_presence(void); struct hv_device* hv_vmbus_child_device_create( hv_guid device_type, From owner-svn-src-stable-10@freebsd.org Thu Jun 16 05:24:01 2016 Return-Path: Delivered-To: svn-src-stable-10@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 B600FA4752F; Thu, 16 Jun 2016 05:24:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 92AF625BC; Thu, 16 Jun 2016 05:24:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G5O0s4098995; Thu, 16 Jun 2016 05:24:00 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G5O0bg098992; Thu, 16 Jun 2016 05:24:00 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160524.u5G5O0bg098992@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 05:24:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301952 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 05:24:01 -0000 Author: sephe Date: Thu Jun 16 05:24:00 2016 New Revision: 301952 URL: https://svnweb.freebsd.org/changeset/base/301952 Log: MFC 297809,297810,297811 297809 hyperv/hn: Cap default # of rings to 8. 8 gives the best performance in both Azure and local Hyper-V on both 10Ge and 40Ge. More rings are still allowed by manual configuration. Reviewed by: Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5879 297810 hyperv/hn: By default enable multiple TX/RX rings, aka vRSS. Reviewed by: Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5880 297811 hyperv/hn: Remove unnecessary NULL checks Submitted by: Jun Su Reviewed by: sephe MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5905 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Jun 16 05:12:28 2016 (r301951) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Jun 16 05:24:00 2016 (r301952) @@ -741,10 +741,8 @@ cleanup: * Free the packet buffers on the netvsc device packet queue. * Release other resources. */ - if (net_dev) { - sema_destroy(&net_dev->channel_init_sema); - free(net_dev, M_NETVSC); - } + sema_destroy(&net_dev->channel_init_sema); + free(net_dev, M_NETVSC); return (NULL); } Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 05:12:28 2016 (r301951) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 05:24:00 2016 (r301952) @@ -138,6 +138,8 @@ __FBSDID("$FreeBSD$"); #define HN_LROENT_CNT_DEF 128 +#define HN_RING_CNT_DEF_MAX 8 + #define HN_RNDIS_MSG_LEN \ (sizeof(rndis_msg) + \ RNDIS_HASH_PPI_SIZE + \ @@ -282,12 +284,12 @@ static int hn_use_if_start = 0; SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN, &hn_use_if_start, 0, "Use if_start TX method"); -static int hn_chan_cnt = 1; +static int hn_chan_cnt = 0; SYSCTL_INT(_hw_hn, OID_AUTO, chan_cnt, CTLFLAG_RDTUN, &hn_chan_cnt, 0, "# of channels to use; each channel has one RX ring and one TX ring"); -static int hn_tx_ring_cnt = 1; +static int hn_tx_ring_cnt = 0; SYSCTL_INT(_hw_hn, OID_AUTO, tx_ring_cnt, CTLFLAG_RDTUN, &hn_tx_ring_cnt, 0, "# of TX rings to use"); @@ -480,8 +482,14 @@ netvsc_attach(device_t dev) * The # of RX rings to use is same as the # of channels to use. */ ring_cnt = hn_chan_cnt; - if (ring_cnt <= 0 || ring_cnt > mp_ncpus) + if (ring_cnt <= 0) { + /* Default */ + ring_cnt = mp_ncpus; + if (ring_cnt > HN_RING_CNT_DEF_MAX) + ring_cnt = HN_RING_CNT_DEF_MAX; + } else if (ring_cnt > mp_ncpus) { ring_cnt = mp_ncpus; + } tx_ring_cnt = hn_tx_ring_cnt; if (tx_ring_cnt <= 0 || tx_ring_cnt > ring_cnt) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Jun 16 05:12:28 2016 (r301951) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Jun 16 05:24:00 2016 (r301952) @@ -406,8 +406,7 @@ hv_rf_send_offload_request(struct hv_dev } cleanup: - if (request) - hv_put_rndis_request(rndis_dev, request); + hv_put_rndis_request(rndis_dev, request); return (ret); } @@ -908,10 +907,8 @@ hv_rf_halt_device(rndis_device *device) } device->state = RNDIS_DEV_UNINITIALIZED; - - if (request != NULL) { - hv_put_rndis_request(device, request); - } + + hv_put_rndis_request(device, request); return (0); } From owner-svn-src-stable-10@freebsd.org Thu Jun 16 06:26:10 2016 Return-Path: Delivered-To: svn-src-stable-10@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 A971AA69081; Thu, 16 Jun 2016 06:26:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 5FFAB1E21; Thu, 16 Jun 2016 06:26:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G6Q9LY021150; Thu, 16 Jun 2016 06:26:09 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G6Q9ac021149; Thu, 16 Jun 2016 06:26:09 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160626.u5G6Q9ac021149@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 06:26:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301953 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 06:26:10 -0000 Author: sephe Date: Thu Jun 16 06:26:09 2016 New Revision: 301953 URL: https://svnweb.freebsd.org/changeset/base/301953 Log: hyperv/hn: ifnet TSO configuration is available on 10-stable. Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 05:24:00 2016 (r301952) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 06:26:09 2016 (r301953) @@ -237,12 +237,10 @@ SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosti "Trust ip packet verification on host side, " "when csum info is missing (global setting)"); -#if __FreeBSD_version >= 1100045 /* Limit TSO burst size */ static int hn_tso_maxlen = 0; SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, &hn_tso_maxlen, 0, "TSO burst limit"); -#endif /* Limit chimney send size */ static int hn_tx_chimney_size = 0; @@ -432,9 +430,7 @@ netvsc_attach(device_t dev) int unit = device_get_unit(dev); struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; -#if __FreeBSD_version >= 1100045 int tso_maxlen; -#endif sc = device_get_softc(dev); if (sc == NULL) { @@ -584,7 +580,6 @@ netvsc_attach(device_t dev) sc->hn_carrier = 1; } -#if __FreeBSD_version >= 1100045 tso_maxlen = hn_tso_maxlen; if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) tso_maxlen = IP_MAXPACKET; @@ -593,14 +588,11 @@ netvsc_attach(device_t dev) ifp->if_hw_tsomaxsegsize = PAGE_SIZE; ifp->if_hw_tsomax = tso_maxlen - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); -#endif ether_ifattach(ifp, device_info.mac_addr); -#if __FreeBSD_version >= 1100045 if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); -#endif sc->hn_tx_chimney_max = sc->net_dev->send_section_size; hn_set_tx_chimney_size(sc, sc->hn_tx_chimney_max); From owner-svn-src-stable-10@freebsd.org Thu Jun 16 06:34:14 2016 Return-Path: Delivered-To: svn-src-stable-10@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 476F9A69493; Thu, 16 Jun 2016 06:34:14 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 098E516D7; Thu, 16 Jun 2016 06:34:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G6YDij024904; Thu, 16 Jun 2016 06:34:13 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G6YDOY024902; Thu, 16 Jun 2016 06:34:13 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160634.u5G6YDOY024902@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 06:34:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301954 - in stable/10/sys/dev/hyperv: netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 06:34:14 -0000 Author: sephe Date: Thu Jun 16 06:34:12 2016 New Revision: 301954 URL: https://svnweb.freebsd.org/changeset/base/301954 Log: MFC 298039,298042 298039 hyperv/vmbus: Put multi-channel offer logging under bootverbose Suggested by: Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC 298042 hyperv/hn: Hide ring to channel linkage message under bootverbose Suggested by: Dexuan Cui MFC after: 1 week Sponsored by: Microsoft OSTC Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 06:26:09 2016 (r301953) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Jun 16 06:34:12 2016 (r301954) @@ -2872,8 +2872,10 @@ hn_channel_attach(struct hn_softc *sc, s rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED; chan->hv_chan_rxr = rxr; - if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", - idx, chan->offer_msg.child_rel_id); + if (bootverbose) { + if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", + idx, chan->offer_msg.child_rel_id); + } if (idx < sc->hn_tx_ring_inuse) { struct hn_tx_ring *txr = &sc->hn_tx_ring[idx]; @@ -2884,8 +2886,10 @@ hn_channel_attach(struct hn_softc *sc, s chan->hv_chan_txr = txr; txr->hn_chan = chan; - if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", - idx, chan->offer_msg.child_rel_id); + if (bootverbose) { + if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", + idx, chan->offer_msg.child_rel_id); + } } /* Bind channel to a proper CPU */ Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Thu Jun 16 06:26:09 2016 (r301953) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Thu Jun 16 06:34:12 2016 (r301954) @@ -222,10 +222,14 @@ vmbus_channel_process_offer(hv_vmbus_cha sc_list_entry); mtx_unlock(&channel->sc_lock); + if (bootverbose) { + printf("VMBUS get multi-channel offer, " + "rel=%u, sub=%u\n", + new_channel->offer_msg.child_rel_id, + new_channel->offer_msg.offer.sub_channel_index); + } + /* Insert new channel into channel_anchor. */ - printf("VMBUS get multi-channel offer, rel=%u,sub=%u\n", - new_channel->offer_msg.child_rel_id, - new_channel->offer_msg.offer.sub_channel_index); mtx_lock(&hv_vmbus_g_connection.channel_lock); TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_anchor, new_channel, list_entry); From owner-svn-src-stable-10@freebsd.org Fri Jun 17 02:29:57 2016 Return-Path: Delivered-To: svn-src-stable-10@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 3BB6CA47A67; Fri, 17 Jun 2016 02:29:57 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 E53372D57; Fri, 17 Jun 2016 02:29:56 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H2TuLZ066899; Fri, 17 Jun 2016 02:29:56 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H2Tu2F066897; Fri, 17 Jun 2016 02:29:56 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201606170229.u5H2Tu2F066897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Fri, 17 Jun 2016 02:29:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301976 - in stable/10/contrib/gcclibs: include libiberty X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 02:29:57 -0000 Author: pfg Date: Fri Jun 17 02:29:55 2016 New Revision: 301976 URL: https://svnweb.freebsd.org/changeset/base/301976 Log: MFC r301291: libiberty: prevent integer overflow. Take care of very old bug leading to heap-buffer overflow by processing certain file headers via bfd binary. PR: 200888 Obtained from: OpenBSD Modified: stable/10/contrib/gcclibs/include/objalloc.h stable/10/contrib/gcclibs/libiberty/objalloc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/gcclibs/include/objalloc.h ============================================================================== --- stable/10/contrib/gcclibs/include/objalloc.h Fri Jun 17 00:00:45 2016 (r301975) +++ stable/10/contrib/gcclibs/include/objalloc.h Fri Jun 17 02:29:55 2016 (r301976) @@ -1,5 +1,5 @@ /* objalloc.h -- routines to allocate memory for objects - Copyright 1997, 2001 Free Software Foundation, Inc. + Copyright 1997, 2001-2012 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Solutions. This program is free software; you can redistribute it and/or modify it @@ -91,7 +91,7 @@ extern void *_objalloc_alloc (struct obj if (__len == 0) \ __len = 1; \ __len = (__len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); \ - (__len <= __o->current_space \ + (__len != 0 && __len <= __o->current_space \ ? (__o->current_ptr += __len, \ __o->current_space -= __len, \ (void *) (__o->current_ptr - __len)) \ Modified: stable/10/contrib/gcclibs/libiberty/objalloc.c ============================================================================== --- stable/10/contrib/gcclibs/libiberty/objalloc.c Fri Jun 17 00:00:45 2016 (r301975) +++ stable/10/contrib/gcclibs/libiberty/objalloc.c Fri Jun 17 02:29:55 2016 (r301976) @@ -1,5 +1,5 @@ /* objalloc.c -- routines to allocate memory for objects - Copyright 1997 Free Software Foundation, Inc. + Copyright 1997-2012 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Solutions. This program is free software; you can redistribute it and/or modify it @@ -112,8 +112,10 @@ objalloc_create (void) /* Allocate space from an objalloc structure. */ PTR -_objalloc_alloc (struct objalloc *o, unsigned long len) +_objalloc_alloc (struct objalloc *o, unsigned long original_len) { + unsigned long len = original_len; + /* We avoid confusion from zero sized objects by always allocating at least 1 byte. */ if (len == 0) @@ -121,6 +123,11 @@ _objalloc_alloc (struct objalloc *o, uns len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); + /* CVE-2012-3509: Check for overflow in the alignment operation above + * and then malloc argument below. */ + if (len + CHUNK_HEADER_SIZE < original_len) + return NULL; + if (len <= o->current_space) { o->current_ptr += len; From owner-svn-src-stable-10@freebsd.org Fri Jun 17 02:48:58 2016 Return-Path: Delivered-To: svn-src-stable-10@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 96B5FA77038; Fri, 17 Jun 2016 02:48:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 656211A2E; Fri, 17 Jun 2016 02:48:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H2mvbu074227; Fri, 17 Jun 2016 02:48:57 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H2mvb4074226; Fri, 17 Jun 2016 02:48:57 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201606170248.u5H2mvb4074226@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Fri, 17 Jun 2016 02:48:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301978 - stable/10/contrib/ipfilter/man X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 02:48:58 -0000 Author: cy Date: Fri Jun 17 02:48:57 2016 New Revision: 301978 URL: https://svnweb.freebsd.org/changeset/base/301978 Log: MFC r301773 & r301775: Clarify the wording to be more accurate. Modified: stable/10/contrib/ipfilter/man/ipf.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/ipfilter/man/ipf.8 ============================================================================== --- stable/10/contrib/ipfilter/man/ipf.8 Fri Jun 17 02:31:18 2016 (r301977) +++ stable/10/contrib/ipfilter/man/ipf.8 Fri Jun 17 02:48:57 2016 (r301978) @@ -35,7 +35,10 @@ which they appear when given to \fBipf\f .SH OPTIONS .TP .B \-6 -This option is required to parse IPv6 rules and to have them loaded. +IPv4 and IPv6 rules are stored in a single table and can be read from a +single file. This option is no longer required to load IPv6 rules. This +option is ignored when specified with the -F option and the -F option +will flush IPv4 rules even if this option is specified. .TP .B \-A Set the list to make changes to the active list (default). From owner-svn-src-stable-10@freebsd.org Fri Jun 17 08:54:44 2016 Return-Path: Delivered-To: svn-src-stable-10@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 B1EFEA78BF1; Fri, 17 Jun 2016 08:54:44 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 7B5462BA9; Fri, 17 Jun 2016 08:54:44 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H8shYV010906; Fri, 17 Jun 2016 08:54:43 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H8shDv010905; Fri, 17 Jun 2016 08:54:43 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170854.u5H8shDv010905@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 08:54:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301979 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 08:54:44 -0000 Author: arybchik Date: Fri Jun 17 08:54:43 2016 New Revision: 301979 URL: https://svnweb.freebsd.org/changeset/base/301979 Log: MFC r301061 sfxge(4): regenerate MCDI headers from firmwaresrc .yml Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_regs_mcdi.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_regs_mcdi.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_regs_mcdi.h Fri Jun 17 02:48:57 2016 (r301978) +++ stable/10/sys/dev/sfxge/common/efx_regs_mcdi.h Fri Jun 17 08:54:43 2016 (r301979) @@ -5115,16 +5115,20 @@ #define MC_CMD_POLL_BIST_MEM_BUS_MC 0x0 /* enum: CSR IREG bus. */ #define MC_CMD_POLL_BIST_MEM_BUS_CSR 0x1 -/* enum: RX DPCPU bus. */ +/* enum: RX0 DPCPU bus. */ #define MC_CMD_POLL_BIST_MEM_BUS_DPCPU_RX 0x2 /* enum: TX0 DPCPU bus. */ #define MC_CMD_POLL_BIST_MEM_BUS_DPCPU_TX0 0x3 /* enum: TX1 DPCPU bus. */ #define MC_CMD_POLL_BIST_MEM_BUS_DPCPU_TX1 0x4 -/* enum: RX DICPU bus. */ +/* enum: RX0 DICPU bus. */ #define MC_CMD_POLL_BIST_MEM_BUS_DICPU_RX 0x5 /* enum: TX DICPU bus. */ #define MC_CMD_POLL_BIST_MEM_BUS_DICPU_TX 0x6 +/* enum: RX1 DPCPU bus. */ +#define MC_CMD_POLL_BIST_MEM_BUS_DPCPU_RX1 0x7 +/* enum: RX1 DICPU bus. */ +#define MC_CMD_POLL_BIST_MEM_BUS_DICPU_RX1 0x8 /* Pattern written to RAM / register */ #define MC_CMD_POLL_BIST_OUT_MEM_EXPECT_OFST 16 /* Actual value read from RAM / register */ @@ -6094,6 +6098,8 @@ #define MC_CMD_NVRAM_INFO_OUT_PROTECTED_WIDTH 1 #define MC_CMD_NVRAM_INFO_OUT_TLV_LBN 1 #define MC_CMD_NVRAM_INFO_OUT_TLV_WIDTH 1 +#define MC_CMD_NVRAM_INFO_OUT_CMAC_LBN 6 +#define MC_CMD_NVRAM_INFO_OUT_CMAC_WIDTH 1 #define MC_CMD_NVRAM_INFO_OUT_A_B_LBN 7 #define MC_CMD_NVRAM_INFO_OUT_A_B_WIDTH 1 #define MC_CMD_NVRAM_INFO_OUT_PHYSDEV_OFST 16 @@ -6887,6 +6893,8 @@ * the command will fail with MC_CMD_ERR_FILTERS_PRESENT. */ #define MC_CMD_WORKAROUND_BUG26807 0x6 +/* enum: Bug 61265 work around (broken EVQ TMR writes). */ +#define MC_CMD_WORKAROUND_BUG61265 0x7 /* 0 = disable the workaround indicated by TYPE; any non-zero value = enable * the workaround */ @@ -7865,8 +7873,10 @@ #define NVRAM_PARTITION_TYPE_SPARE_1 0x1100 /* enum: Spare partition 2 */ #define NVRAM_PARTITION_TYPE_SPARE_2 0x1200 -/* enum: Spare partition 3 */ -#define NVRAM_PARTITION_TYPE_SPARE_3 0x1300 +/* enum: Manufacturing partition. Used during manufacture to pass information + * between XJTAG and Manftest. + */ +#define NVRAM_PARTITION_TYPE_MANUFACTURING 0x1300 /* enum: Spare partition 4 */ #define NVRAM_PARTITION_TYPE_SPARE_4 0x1400 /* enum: Spare partition 5 */ @@ -7901,6 +7911,8 @@ #define LICENSED_APP_ID_CAPTURE_SOLARSYSTEM 0x40 /* enum: Network Access Control */ #define LICENSED_APP_ID_NETWORK_ACCESS_CONTROL 0x80 +/* enum: TCP Direct */ +#define LICENSED_APP_ID_TCP_DIRECT 0x100 #define LICENSED_APP_ID_ID_LBN 0 #define LICENSED_APP_ID_ID_WIDTH 32 @@ -7957,6 +7969,12 @@ #define LICENSED_V3_APPS_CAPTURE_SOLARSYSTEM_WIDTH 1 #define LICENSED_V3_APPS_NETWORK_ACCESS_CONTROL_LBN 7 #define LICENSED_V3_APPS_NETWORK_ACCESS_CONTROL_WIDTH 1 +#define LICENSED_V3_APPS_TCP_DIRECT_LBN 8 +#define LICENSED_V3_APPS_TCP_DIRECT_WIDTH 1 +#define LICENSED_V3_APPS_LOW_LATENCY_LBN 9 +#define LICENSED_V3_APPS_LOW_LATENCY_WIDTH 1 +#define LICENSED_V3_APPS_SOLARCAPTURE_TAP_LBN 10 +#define LICENSED_V3_APPS_SOLARCAPTURE_TAP_WIDTH 1 #define LICENSED_V3_APPS_MASK_LBN 0 #define LICENSED_V3_APPS_MASK_WIDTH 64 @@ -7985,6 +8003,8 @@ #define LICENSED_V3_FEATURES_TX_SNIFF_WIDTH 1 #define LICENSED_V3_FEATURES_PROXY_FILTER_OPS_LBN 8 #define LICENSED_V3_FEATURES_PROXY_FILTER_OPS_WIDTH 1 +#define LICENSED_V3_FEATURES_EVENT_CUT_THROUGH_LBN 9 +#define LICENSED_V3_FEATURES_EVENT_CUT_THROUGH_WIDTH 1 #define LICENSED_V3_FEATURES_MASK_LBN 0 #define LICENSED_V3_FEATURES_MASK_WIDTH 64 @@ -8142,6 +8162,109 @@ /* Only valid if INTRFLAG was true */ #define MC_CMD_INIT_EVQ_OUT_IRQ_OFST 0 +/* MC_CMD_INIT_EVQ_V2_IN msgrequest */ +#define MC_CMD_INIT_EVQ_V2_IN_LENMIN 44 +#define MC_CMD_INIT_EVQ_V2_IN_LENMAX 548 +#define MC_CMD_INIT_EVQ_V2_IN_LEN(num) (36+8*(num)) +/* Size, in entries */ +#define MC_CMD_INIT_EVQ_V2_IN_SIZE_OFST 0 +/* Desired instance. Must be set to a specific instance, which is a function + * local queue index. + */ +#define MC_CMD_INIT_EVQ_V2_IN_INSTANCE_OFST 4 +/* The initial timer value. The load value is ignored if the timer mode is DIS. + */ +#define MC_CMD_INIT_EVQ_V2_IN_TMR_LOAD_OFST 8 +/* The reload value is ignored in one-shot modes */ +#define MC_CMD_INIT_EVQ_V2_IN_TMR_RELOAD_OFST 12 +/* tbd */ +#define MC_CMD_INIT_EVQ_V2_IN_FLAGS_OFST 16 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_INTERRUPTING_LBN 0 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_INTERRUPTING_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_RPTR_DOS_LBN 1 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_RPTR_DOS_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_INT_ARMD_LBN 2 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_INT_ARMD_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_CUT_THRU_LBN 3 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_CUT_THRU_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_RX_MERGE_LBN 4 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_RX_MERGE_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_TX_MERGE_LBN 5 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_TX_MERGE_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_USE_TIMER_LBN 6 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_USE_TIMER_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_LBN 7 +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_WIDTH 4 +/* enum: All initialisation flags specified by host. */ +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_MANUAL 0x0 +/* enum: MEDFORD only. Certain initialisation flags specified by host may be + * over-ridden by firmware based on licenses and firmware variant in order to + * provide the lowest latency achievable. See + * MC_CMD_INIT_EVQ_V2/MC_CMD_INIT_EVQ_V2_OUT/FLAGS for list of affected flags. + */ +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_LOW_LATENCY 0x1 +/* enum: MEDFORD only. Certain initialisation flags specified by host may be + * over-ridden by firmware based on licenses and firmware variant in order to + * provide the best throughput achievable. See + * MC_CMD_INIT_EVQ_V2/MC_CMD_INIT_EVQ_V2_OUT/FLAGS for list of affected flags. + */ +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_THROUGHPUT 0x2 +/* enum: MEDFORD only. Certain initialisation flags may be over-ridden by + * firmware based on licenses and firmware variant. See + * MC_CMD_INIT_EVQ_V2/MC_CMD_INIT_EVQ_V2_OUT/FLAGS for list of affected flags. + */ +#define MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_AUTO 0x3 +#define MC_CMD_INIT_EVQ_V2_IN_TMR_MODE_OFST 20 +/* enum: Disabled */ +#define MC_CMD_INIT_EVQ_V2_IN_TMR_MODE_DIS 0x0 +/* enum: Immediate */ +#define MC_CMD_INIT_EVQ_V2_IN_TMR_IMMED_START 0x1 +/* enum: Triggered */ +#define MC_CMD_INIT_EVQ_V2_IN_TMR_TRIG_START 0x2 +/* enum: Hold-off */ +#define MC_CMD_INIT_EVQ_V2_IN_TMR_INT_HLDOFF 0x3 +/* Target EVQ for wakeups if in wakeup mode. */ +#define MC_CMD_INIT_EVQ_V2_IN_TARGET_EVQ_OFST 24 +/* Target interrupt if in interrupting mode (note union with target EVQ). Use + * MC_CMD_RESOURCE_INSTANCE_ANY unless a specific one required for test + * purposes. + */ +#define MC_CMD_INIT_EVQ_V2_IN_IRQ_NUM_OFST 24 +/* Event Counter Mode. */ +#define MC_CMD_INIT_EVQ_V2_IN_COUNT_MODE_OFST 28 +/* enum: Disabled */ +#define MC_CMD_INIT_EVQ_V2_IN_COUNT_MODE_DIS 0x0 +/* enum: Disabled */ +#define MC_CMD_INIT_EVQ_V2_IN_COUNT_MODE_RX 0x1 +/* enum: Disabled */ +#define MC_CMD_INIT_EVQ_V2_IN_COUNT_MODE_TX 0x2 +/* enum: Disabled */ +#define MC_CMD_INIT_EVQ_V2_IN_COUNT_MODE_RXTX 0x3 +/* Event queue packet count threshold. */ +#define MC_CMD_INIT_EVQ_V2_IN_COUNT_THRSHLD_OFST 32 +/* 64-bit address of 4k of 4k-aligned host memory buffer */ +#define MC_CMD_INIT_EVQ_V2_IN_DMA_ADDR_OFST 36 +#define MC_CMD_INIT_EVQ_V2_IN_DMA_ADDR_LEN 8 +#define MC_CMD_INIT_EVQ_V2_IN_DMA_ADDR_LO_OFST 36 +#define MC_CMD_INIT_EVQ_V2_IN_DMA_ADDR_HI_OFST 40 +#define MC_CMD_INIT_EVQ_V2_IN_DMA_ADDR_MINNUM 1 +#define MC_CMD_INIT_EVQ_V2_IN_DMA_ADDR_MAXNUM 64 + +/* MC_CMD_INIT_EVQ_V2_OUT msgresponse */ +#define MC_CMD_INIT_EVQ_V2_OUT_LEN 8 +/* Only valid if INTRFLAG was true */ +#define MC_CMD_INIT_EVQ_V2_OUT_IRQ_OFST 0 +/* Actual configuration applied on the card */ +#define MC_CMD_INIT_EVQ_V2_OUT_FLAGS_OFST 4 +#define MC_CMD_INIT_EVQ_V2_OUT_FLAG_CUT_THRU_LBN 0 +#define MC_CMD_INIT_EVQ_V2_OUT_FLAG_CUT_THRU_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_OUT_FLAG_RX_MERGE_LBN 1 +#define MC_CMD_INIT_EVQ_V2_OUT_FLAG_RX_MERGE_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_OUT_FLAG_TX_MERGE_LBN 2 +#define MC_CMD_INIT_EVQ_V2_OUT_FLAG_TX_MERGE_WIDTH 1 +#define MC_CMD_INIT_EVQ_V2_OUT_FLAG_RXQ_FORCE_EV_MERGING_LBN 3 +#define MC_CMD_INIT_EVQ_V2_OUT_FLAG_RXQ_FORCE_EV_MERGING_WIDTH 1 + /* QUEUE_CRC_MODE structuredef */ #define QUEUE_CRC_MODE_LEN 1 #define QUEUE_CRC_MODE_MODE_LBN 0 @@ -8206,8 +8329,8 @@ #define MC_CMD_INIT_RXQ_IN_FLAG_PREFIX_WIDTH 1 #define MC_CMD_INIT_RXQ_IN_FLAG_DISABLE_SCATTER_LBN 9 #define MC_CMD_INIT_RXQ_IN_FLAG_DISABLE_SCATTER_WIDTH 1 -#define MC_CMD_INIT_RXQ_IN_FLAG_FORCE_EV_MERGING_LBN 10 -#define MC_CMD_INIT_RXQ_IN_FLAG_FORCE_EV_MERGING_WIDTH 1 +#define MC_CMD_INIT_RXQ_IN_UNUSED_LBN 10 +#define MC_CMD_INIT_RXQ_IN_UNUSED_WIDTH 1 /* Owner ID to use if in buffer mode (zero if physical) */ #define MC_CMD_INIT_RXQ_IN_OWNER_ID_OFST 20 /* The port ID associated with the v-adaptor which should contain this DMAQ. */ @@ -10427,6 +10550,12 @@ #define MC_CMD_GET_CAPABILITIES_V2_OUT_EVENT_CUT_THROUGH_WIDTH 1 #define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_CUT_THROUGH_LBN 4 #define MC_CMD_GET_CAPABILITIES_V2_OUT_RX_CUT_THROUGH_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_VFIFO_ULL_MODE_LBN 5 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_TX_VFIFO_ULL_MODE_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_MAC_STATS_40G_TX_SIZE_BINS_LBN 6 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_MAC_STATS_40G_TX_SIZE_BINS_WIDTH 1 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_INIT_EVQ_V2_LBN 7 +#define MC_CMD_GET_CAPABILITIES_V2_OUT_INIT_EVQ_V2_WIDTH 1 /* Number of FATSOv2 contexts per datapath supported by this NIC. Not present * on older firmware (check the length). */ @@ -13013,29 +13142,39 @@ #define MC_CMD_0xd4_PRIVILEGE_CTG SRIOV_CTG_GENERAL /* MC_CMD_LICENSED_V3_VALIDATE_APP_IN msgrequest */ -#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_LEN 72 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_LEN 62 +/* challenge for validation (384 bits) */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_CHALLENGE_OFST 0 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_CHALLENGE_LEN 48 /* application ID expressed as a single bit mask */ -#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_OFST 0 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_OFST 48 #define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_LEN 8 -#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_LO_OFST 0 -#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_HI_OFST 4 -/* challenge for validation */ -#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_CHALLENGE_OFST 8 -#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_CHALLENGE_LEN 64 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_LO_OFST 48 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_APP_ID_HI_OFST 52 +/* MAC address of the calling client MC_CMD_ERR_EPERM is returned if the + * calling client is not allowed to use this MAC address. + */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_MACADDR_OFST 56 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_IN_MACADDR_LEN 6 /* MC_CMD_LICENSED_V3_VALIDATE_APP_OUT msgresponse */ -#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_LEN 72 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_LEN 104 +/* validation response to challenge in the form of ECDSA signature consisting + * of two 384-bit integers, r and s, in big-endian order. The signature signs a + * SHA-384 digest of a message constructed from the concatenation of the input + * message and the remaining fields of this output message, e.g. challenge[48 + * bytes] ... expiry_time[4 bytes] ... + */ +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_RESPONSE_OFST 0 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_RESPONSE_LEN 96 /* application expiry time */ -#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_TIME_OFST 0 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_TIME_OFST 96 /* application expiry units */ -#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_UNITS_OFST 4 +#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_UNITS_OFST 100 /* enum: expiry units are accounting units */ #define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_UNIT_ACC 0x0 /* enum: expiry units are calendar days */ #define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_EXPIRY_UNIT_DAYS 0x1 -/* validation response to challenge */ -#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_RESPONSE_OFST 8 -#define MC_CMD_LICENSED_V3_VALIDATE_APP_OUT_RESPONSE_LEN 64 /***********************************/ @@ -13066,6 +13205,71 @@ /***********************************/ +/* MC_CMD_LICENSING_V3_TEMPORARY + * Perform operations to support installation of a single temporary license in + * the adapter, in addition to those found in the licensing partition. See + * SF-116124-SW for an overview of how this could be used. The license is + * stored in MC persistent data and so will survive a MC reboot, but will be + * erased when the adapter is power cycled + */ +#define MC_CMD_LICENSING_V3_TEMPORARY 0xd6 +#undef MC_CMD_0xd6_PRIVILEGE_CTG + +#define MC_CMD_0xd6_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_LICENSING_V3_TEMPORARY_IN msgrequest */ +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_LEN 4 +/* operation code */ +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_OP_OFST 0 +/* enum: install a new license, overwriting any existing temporary license. + * This is an asynchronous operation owing to the time taken to validate an + * ECDSA license + */ +#define MC_CMD_LICENSING_V3_TEMPORARY_SET 0x0 +/* enum: clear the license immediately rather than waiting for the next power + * cycle + */ +#define MC_CMD_LICENSING_V3_TEMPORARY_CLEAR 0x1 +/* enum: get the status of the asynchronous MC_CMD_LICENSING_V3_TEMPORARY_SET + * operation + */ +#define MC_CMD_LICENSING_V3_TEMPORARY_STATUS 0x2 + +/* MC_CMD_LICENSING_V3_TEMPORARY_IN_SET msgrequest */ +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_SET_LEN 164 +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_SET_OP_OFST 0 +/* ECDSA license and signature */ +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_SET_LICENSE_OFST 4 +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_SET_LICENSE_LEN 160 + +/* MC_CMD_LICENSING_V3_TEMPORARY_IN_CLEAR msgrequest */ +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_CLEAR_LEN 4 +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_CLEAR_OP_OFST 0 + +/* MC_CMD_LICENSING_V3_TEMPORARY_IN_STATUS msgrequest */ +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_STATUS_LEN 4 +#define MC_CMD_LICENSING_V3_TEMPORARY_IN_STATUS_OP_OFST 0 + +/* MC_CMD_LICENSING_V3_TEMPORARY_OUT_STATUS msgresponse */ +#define MC_CMD_LICENSING_V3_TEMPORARY_OUT_STATUS_LEN 12 +/* status code */ +#define MC_CMD_LICENSING_V3_TEMPORARY_OUT_STATUS_STATUS_OFST 0 +/* enum: finished validating and installing license */ +#define MC_CMD_LICENSING_V3_TEMPORARY_STATUS_OK 0x0 +/* enum: license validation and installation in progress */ +#define MC_CMD_LICENSING_V3_TEMPORARY_STATUS_IN_PROGRESS 0x1 +/* enum: licensing error. More specific error messages are not provided to + * avoid exposing details of the licensing system to the client + */ +#define MC_CMD_LICENSING_V3_TEMPORARY_STATUS_ERROR 0x2 +/* bitmask of licensed features */ +#define MC_CMD_LICENSING_V3_TEMPORARY_OUT_STATUS_LICENSED_FEATURES_OFST 4 +#define MC_CMD_LICENSING_V3_TEMPORARY_OUT_STATUS_LICENSED_FEATURES_LEN 8 +#define MC_CMD_LICENSING_V3_TEMPORARY_OUT_STATUS_LICENSED_FEATURES_LO_OFST 4 +#define MC_CMD_LICENSING_V3_TEMPORARY_OUT_STATUS_LICENSED_FEATURES_HI_OFST 8 + + +/***********************************/ /* MC_CMD_SET_PORT_SNIFF_CONFIG * Configure RX port sniffing for the physical port associated with the calling * function. Only a privileged function may change the port sniffing @@ -13414,6 +13618,8 @@ #define MC_CMD_GET_WORKAROUNDS_OUT_BUG42008 0x20 /* enum: Bug 26807 features present in firmware (multicast filter chaining) */ #define MC_CMD_GET_WORKAROUNDS_OUT_BUG26807 0x40 +/* enum: Bug 61265 work around (broken EVQ TMR writes). */ +#define MC_CMD_GET_WORKAROUNDS_OUT_BUG61265 0x80 /***********************************/ @@ -14342,19 +14548,15 @@ #define MC_CMD_0x118_PRIVILEGE_CTG SRIOV_CTG_ADMIN /* MC_CMD_RX_BALANCING_IN msgrequest */ -#define MC_CMD_RX_BALANCING_IN_LEN 4 +#define MC_CMD_RX_BALANCING_IN_LEN 16 /* The RX port whose upconverter table will be modified */ #define MC_CMD_RX_BALANCING_IN_PORT_OFST 0 -#define MC_CMD_RX_BALANCING_IN_PORT_LEN 1 /* The VLAN priority associated to the table index and vFIFO */ -#define MC_CMD_RX_BALANCING_IN_PRIORITY_OFST 1 -#define MC_CMD_RX_BALANCING_IN_PRIORITY_LEN 1 +#define MC_CMD_RX_BALANCING_IN_PRIORITY_OFST 4 /* The resulting bit of SRC^DST for indexing the table */ -#define MC_CMD_RX_BALANCING_IN_SRC_DST_OFST 2 -#define MC_CMD_RX_BALANCING_IN_SRC_DST_LEN 1 +#define MC_CMD_RX_BALANCING_IN_SRC_DST_OFST 8 /* The RX engine to which the vFIFO in the table entry will point to */ -#define MC_CMD_RX_BALANCING_IN_ENG_OFST 3 -#define MC_CMD_RX_BALANCING_IN_ENG_LEN 1 +#define MC_CMD_RX_BALANCING_IN_ENG_OFST 12 /* MC_CMD_RX_BALANCING_OUT msgresponse */ #define MC_CMD_RX_BALANCING_OUT_LEN 0 @@ -14368,6 +14570,9 @@ * available to host software. */ #define MC_CMD_TSA_BIND 0x119 +#undef MC_CMD_0x119_PRIVILEGE_CTG + +#define MC_CMD_0x119_PRIVILEGE_CTG SRIOV_CTG_ADMIN /* MC_CMD_TSA_BIND_IN msgrequest: Protocol operation code */ #define MC_CMD_TSA_BIND_IN_LEN 4 @@ -14431,9 +14636,11 @@ #define MC_CMD_TSA_BIND_IN_SET_KEY_DATKEY_MAXNUM 248 /* MC_CMD_TSA_BIND_IN_UNBIND msgrequest: Asks for the un-binding procedure */ -#define MC_CMD_TSA_BIND_IN_UNBIND_LEN 6 +#define MC_CMD_TSA_BIND_IN_UNBIND_LEN 10 +/* The operation requested. */ +#define MC_CMD_TSA_BIND_IN_UNBIND_OP_OFST 0 /* TSAN unique identifier for the network adapter */ -#define MC_CMD_TSA_BIND_IN_UNBIND_TSANID_OFST 0 +#define MC_CMD_TSA_BIND_IN_UNBIND_TSANID_OFST 4 #define MC_CMD_TSA_BIND_IN_UNBIND_TSANID_LEN 6 /* MC_CMD_TSA_BIND_OUT_GET_ID msgresponse */ @@ -14550,4 +14757,291 @@ #define MC_CMD_MANAGE_SECURITY_RULESET_CACHE_OUT_VERSION_MINNUM 1 #define MC_CMD_MANAGE_SECURITY_RULESET_CACHE_OUT_VERSION_MAXNUM 248 + +/***********************************/ +/* MC_CMD_NVRAM_PRIVATE_APPEND + * Append a single TLV to the MC_USAGE_TLV partition. Returns MC_CMD_ERR_EEXIST + * if the tag is already present. + */ +#define MC_CMD_NVRAM_PRIVATE_APPEND 0x11c +#undef MC_CMD_0x11c_PRIVILEGE_CTG + +#define MC_CMD_0x11c_PRIVILEGE_CTG SRIOV_CTG_ADMIN + +/* MC_CMD_NVRAM_PRIVATE_APPEND_IN msgrequest */ +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_LENMIN 9 +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_LENMAX 252 +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_LEN(num) (8+1*(num)) +/* The tag to be appended */ +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_TAG_OFST 0 +/* The length of the data */ +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_LENGTH_OFST 4 +/* The data to be contained in the TLV structure */ +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_DATA_BUFFER_OFST 8 +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_DATA_BUFFER_LEN 1 +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_DATA_BUFFER_MINNUM 1 +#define MC_CMD_NVRAM_PRIVATE_APPEND_IN_DATA_BUFFER_MAXNUM 244 + +/* MC_CMD_NVRAM_PRIVATE_APPEND_OUT msgresponse */ +#define MC_CMD_NVRAM_PRIVATE_APPEND_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_XPM_VERIFY_CONTENTS + * Verify that the contents of the XPM memory is correct (Medford only). This + * is used during manufacture to check that the XPM memory has been programmed + * correctly at ATE. + */ +#define MC_CMD_XPM_VERIFY_CONTENTS 0x11b +#undef MC_CMD_0x11b_PRIVILEGE_CTG + +#define MC_CMD_0x11b_PRIVILEGE_CTG SRIOV_CTG_ADMIN + +/* MC_CMD_XPM_VERIFY_CONTENTS_IN msgrequest */ +#define MC_CMD_XPM_VERIFY_CONTENTS_IN_LEN 4 +/* Data type to be checked */ +#define MC_CMD_XPM_VERIFY_CONTENTS_IN_DATA_TYPE_OFST 0 + +/* MC_CMD_XPM_VERIFY_CONTENTS_OUT msgresponse */ +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_LENMIN 12 +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_LENMAX 252 +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_LEN(num) (12+1*(num)) +/* Number of sectors found (test builds only) */ +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_NUM_SECTORS_OFST 0 +/* Number of bytes found (test builds only) */ +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_NUM_BYTES_OFST 4 +/* Length of signature */ +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_SIG_LENGTH_OFST 8 +/* Signature */ +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_SIGNATURE_OFST 12 +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_SIGNATURE_LEN 1 +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_SIGNATURE_MINNUM 0 +#define MC_CMD_XPM_VERIFY_CONTENTS_OUT_SIGNATURE_MAXNUM 240 + + +/***********************************/ +/* MC_CMD_SET_EVQ_TMR + * Update the timer load, timer reload and timer mode values for a given EVQ. + * The requested timer values (in TMR_LOAD_REQ_NS and TMR_RELOAD_REQ_NS) will + * be rounded up to the granularity supported by the hardware, then truncated + * to the range supported by the hardware. The resulting value after the + * rounding and truncation will be returned to the caller (in TMR_LOAD_ACT_NS + * and TMR_RELOAD_ACT_NS). + */ +#define MC_CMD_SET_EVQ_TMR 0x120 +#undef MC_CMD_0x120_PRIVILEGE_CTG + +#define MC_CMD_0x120_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_SET_EVQ_TMR_IN msgrequest */ +#define MC_CMD_SET_EVQ_TMR_IN_LEN 16 +/* Function-relative queue instance */ +#define MC_CMD_SET_EVQ_TMR_IN_INSTANCE_OFST 0 +/* Requested value for timer load (in nanoseconds) */ +#define MC_CMD_SET_EVQ_TMR_IN_TMR_LOAD_REQ_NS_OFST 4 +/* Requested value for timer reload (in nanoseconds) */ +#define MC_CMD_SET_EVQ_TMR_IN_TMR_RELOAD_REQ_NS_OFST 8 +/* Timer mode. Meanings as per EVQ_TMR_REG.TC_TIMER_VAL */ +#define MC_CMD_SET_EVQ_TMR_IN_TMR_MODE_OFST 12 +#define MC_CMD_SET_EVQ_TMR_IN_TIMER_MODE_DIS 0x0 /* enum */ +#define MC_CMD_SET_EVQ_TMR_IN_TIMER_MODE_IMMED_START 0x1 /* enum */ +#define MC_CMD_SET_EVQ_TMR_IN_TIMER_MODE_TRIG_START 0x2 /* enum */ +#define MC_CMD_SET_EVQ_TMR_IN_TIMER_MODE_INT_HLDOFF 0x3 /* enum */ + +/* MC_CMD_SET_EVQ_TMR_OUT msgresponse */ +#define MC_CMD_SET_EVQ_TMR_OUT_LEN 8 +/* Actual value for timer load (in nanoseconds) */ +#define MC_CMD_SET_EVQ_TMR_OUT_TMR_LOAD_ACT_NS_OFST 0 +/* Actual value for timer reload (in nanoseconds) */ +#define MC_CMD_SET_EVQ_TMR_OUT_TMR_RELOAD_ACT_NS_OFST 4 + + +/***********************************/ +/* MC_CMD_GET_EVQ_TMR_PROPERTIES + * Query properties about the event queue timers. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES 0x122 +#undef MC_CMD_0x122_PRIVILEGE_CTG + +#define MC_CMD_0x122_PRIVILEGE_CTG SRIOV_CTG_GENERAL + +/* MC_CMD_GET_EVQ_TMR_PROPERTIES_IN msgrequest */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_IN_LEN 0 + +/* MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT msgresponse */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_LEN 36 +/* Reserved for future use. */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_FLAGS_OFST 0 +/* For timers updated via writes to EVQ_TMR_REG, this is the time interval (in + * nanoseconds) for each increment of the timer load/reload count. The + * requested duration of a timer is this value multiplied by the timer + * load/reload count. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_TMR_REG_NS_PER_COUNT_OFST 4 +/* For timers updated via writes to EVQ_TMR_REG, this is the maximum value + * allowed for timer load/reload counts. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_TMR_REG_MAX_COUNT_OFST 8 +/* For timers updated via writes to EVQ_TMR_REG, timer load/reload counts not a + * multiple of this step size will be rounded in an implementation defined + * manner. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_TMR_REG_STEP_OFST 12 +/* Maximum timer duration (in nanoseconds) for timers updated via MCDI. Only + * meaningful if MC_CMD_SET_EVQ_TMR is implemented. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_MCDI_TMR_MAX_NS_OFST 16 +/* Timer durations requested via MCDI that are not a multiple of this step size + * will be rounded up. Only meaningful if MC_CMD_SET_EVQ_TMR is implemented. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_MCDI_TMR_STEP_NS_OFST 20 +/* For timers updated using the bug35388 workaround, this is the time interval + * (in nanoseconds) for each increment of the timer load/reload count. The + * requested duration of a timer is this value multiplied by the timer + * load/reload count. This field is only meaningful if the bug35388 workaround + * is enabled. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_BUG35388_TMR_NS_PER_COUNT_OFST 24 +/* For timers updated using the bug35388 workaround, this is the maximum value + * allowed for timer load/reload counts. This field is only meaningful if the + * bug35388 workaround is enabled. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_BUG35388_TMR_MAX_COUNT_OFST 28 +/* For timers updated using the bug35388 workaround, timer load/reload counts + * not a multiple of this step size will be rounded in an implementation + * defined manner. This field is only meaningful if the bug35388 workaround is + * enabled. + */ +#define MC_CMD_GET_EVQ_TMR_PROPERTIES_OUT_BUG35388_TMR_STEP_OFST 32 + + +/***********************************/ +/* MC_CMD_ALLOCATE_TX_VFIFO_CP + * When we use the TX_vFIFO_ULL mode, we can allocate common pools using the + * non used switch buffers. + */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP 0x11d +#undef MC_CMD_0x11d_PRIVILEGE_CTG + +#define MC_CMD_0x11d_PRIVILEGE_CTG SRIOV_CTG_ADMIN + +/* MC_CMD_ALLOCATE_TX_VFIFO_CP_IN msgrequest */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_LEN 20 +/* Desired instance. Must be set to a specific instance, which is a function + * local queue index. + */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_INSTANCE_OFST 0 +/* Will the common pool be used as TX_vFIFO_ULL (1) */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_MODE_OFST 4 +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_ENABLED 0x1 /* enum */ +/* enum: Using this interface without TX_vFIFO_ULL is not supported for now */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_DISABLED 0x0 +/* Number of buffers to reserve for the common pool */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_SIZE_OFST 8 +/* TX datapath to which the Common Pool is connected to. */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_INGRESS_OFST 12 +/* enum: Extracts information from function */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_USE_FUNCTION_VALUE -0x1 +/* Network port or RX Engine to which the common pool connects. */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_EGRESS_OFST 16 +/* enum: Extracts information from function */ +/* MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_USE_FUNCTION_VALUE -0x1 */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_PORT0 0x0 /* enum */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_PORT1 0x1 /* enum */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_PORT2 0x2 /* enum */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_PORT3 0x3 /* enum */ +/* enum: To enable Switch loopback with Rx engine 0 */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_RX_ENGINE0 0x4 +/* enum: To enable Switch loopback with Rx engine 1 */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_IN_RX_ENGINE1 0x5 + +/* MC_CMD_ALLOCATE_TX_VFIFO_CP_OUT msgresponse */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_OUT_LEN 4 +/* ID of the common pool allocated */ +#define MC_CMD_ALLOCATE_TX_VFIFO_CP_OUT_CP_ID_OFST 0 + + +/***********************************/ +/* MC_CMD_ALLOCATE_TX_VFIFO_VFIFO + * When we use the TX_vFIFO_ULL mode, we can allocate vFIFOs using the + * previously allocated common pools. + */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO 0x11e +#undef MC_CMD_0x11e_PRIVILEGE_CTG + +#define MC_CMD_0x11e_PRIVILEGE_CTG SRIOV_CTG_ADMIN + +/* MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN msgrequest */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_LEN 20 +/* Common pool previously allocated to which the new vFIFO will be associated + */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_CP_OFST 0 +/* Port or RX engine to associate the vFIFO egress */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_EGRESS_OFST 4 +/* enum: Extracts information from common pool */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_USE_CP_VALUE -0x1 +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_PORT0 0x0 /* enum */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_PORT1 0x1 /* enum */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_PORT2 0x2 /* enum */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_PORT3 0x3 /* enum */ +/* enum: To enable Switch loopback with Rx engine 0 */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_RX_ENGINE0 0x4 +/* enum: To enable Switch loopback with Rx engine 1 */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_RX_ENGINE1 0x5 +/* Minimum number of buffers that the pool must have */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_SIZE_OFST 8 +/* enum: Do not check the space available */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_NO_MINIMUM 0x0 +/* Will the vFIFO be used as TX_vFIFO_ULL */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_MODE_OFST 12 +/* Network priority of the vFIFO,if applicable */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_PRIORITY_OFST 16 +/* enum: Search for the lowest unused priority */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_IN_LOWEST_AVAILABLE -0x1 + +/* MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_OUT msgresponse */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_OUT_LEN 8 +/* Short vFIFO ID */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_OUT_VID_OFST 0 +/* Network priority of the vFIFO */ +#define MC_CMD_ALLOCATE_TX_VFIFO_VFIFO_OUT_PRIORITY_OFST 4 + + +/***********************************/ +/* MC_CMD_TEARDOWN_TX_VFIFO_VF + * This interface clears the configuration of the given vFIFO and leaves it + * ready to be re-used. + */ +#define MC_CMD_TEARDOWN_TX_VFIFO_VF 0x11f +#undef MC_CMD_0x11f_PRIVILEGE_CTG + +#define MC_CMD_0x11f_PRIVILEGE_CTG SRIOV_CTG_ADMIN + +/* MC_CMD_TEARDOWN_TX_VFIFO_VF_IN msgrequest */ +#define MC_CMD_TEARDOWN_TX_VFIFO_VF_IN_LEN 4 +/* Short vFIFO ID */ +#define MC_CMD_TEARDOWN_TX_VFIFO_VF_IN_VFIFO_OFST 0 + +/* MC_CMD_TEARDOWN_TX_VFIFO_VF_OUT msgresponse */ +#define MC_CMD_TEARDOWN_TX_VFIFO_VF_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_DEALLOCATE_TX_VFIFO_CP + * This interface clears the configuration of the given common pool and leaves + * it ready to be re-used. + */ +#define MC_CMD_DEALLOCATE_TX_VFIFO_CP 0x121 +#undef MC_CMD_0x121_PRIVILEGE_CTG + +#define MC_CMD_0x121_PRIVILEGE_CTG SRIOV_CTG_ADMIN + +/* MC_CMD_DEALLOCATE_TX_VFIFO_CP_IN msgrequest */ +#define MC_CMD_DEALLOCATE_TX_VFIFO_CP_IN_LEN 4 +/* Common pool ID given when pool allocated */ +#define MC_CMD_DEALLOCATE_TX_VFIFO_CP_IN_POOL_ID_OFST 0 + +/* MC_CMD_DEALLOCATE_TX_VFIFO_CP_OUT msgresponse */ +#define MC_CMD_DEALLOCATE_TX_VFIFO_CP_OUT_LEN 0 + #endif /* _SIENA_MC_DRIVER_PCOL_H */ From owner-svn-src-stable-10@freebsd.org Fri Jun 17 08:56:03 2016 Return-Path: Delivered-To: svn-src-stable-10@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 416B9A78CBD; Fri, 17 Jun 2016 08:56:03 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 1C5052D18; Fri, 17 Jun 2016 08:56:03 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H8u225011036; Fri, 17 Jun 2016 08:56:02 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H8u1XR011030; Fri, 17 Jun 2016 08:56:01 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170856.u5H8u1XR011030@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 08:56:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301980 - in stable/10/sys/dev/sfxge: . common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 08:56:03 -0000 Author: arybchik Date: Fri Jun 17 08:56:01 2016 New Revision: 301980 URL: https://svnweb.freebsd.org/changeset/base/301980 Log: MFC r301122 sfxge(4): set moderation in efx_ev_qcreate This simplifies setting an initial interrupt moderation value, and avoids most calls to evx_ev_qmoderate from contexts where MCDI is not allowed (MCDI is need for an EVQ timer workaround in a later patch). Submitted by: Andy Moreton Reviewed by: gnn Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/D6673 Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c stable/10/sys/dev/sfxge/common/ef10_impl.h stable/10/sys/dev/sfxge/common/efx.h stable/10/sys/dev/sfxge/common/efx_ev.c stable/10/sys/dev/sfxge/common/efx_impl.h stable/10/sys/dev/sfxge/sfxge_ev.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 08:56:01 2016 (r301980) @@ -92,8 +92,10 @@ efx_mcdi_init_evq( __in unsigned int instance, __in efsys_mem_t *esmp, __in size_t nevs, - __in uint32_t irq) + __in uint32_t irq, + __in uint32_t us) { + efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_mcdi_req_t req; uint8_t payload[ MAX(MC_CMD_INIT_EVQ_IN_LEN(EFX_EVQ_NBUFS(EFX_EVQ_MAXNEVS)), @@ -141,10 +143,26 @@ efx_mcdi_init_evq( INIT_EVQ_IN_FLAG_RX_MERGE, 1, INIT_EVQ_IN_FLAG_TX_MERGE, 1); - MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_MODE, - MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS); - MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, 0); - MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, 0); + if (us == 0) { + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_MODE, + MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, 0); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, 0); + } else { + uint32_t timer_val; + + /* Calculate the timer value in quanta */ + timer_val = us * 1000 / encp->enc_evq_timer_quantum_ns; + + /* Moderation value is base 0 so we need to deduct 1 */ + if (timer_val > 0) + timer_val--; + + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_MODE, + MC_CMD_INIT_EVQ_IN_TMR_INT_HLDOFF); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, timer_val); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, timer_val); + } MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_COUNT_MODE, MC_CMD_INIT_EVQ_IN_COUNT_MODE_DIS); @@ -246,6 +264,7 @@ ef10_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __in efx_evq_t *eep) { efx_nic_cfg_t *encp = &(enp->en_nic_cfg); @@ -266,6 +285,11 @@ ef10_ev_qcreate( goto fail2; } + if (us > encp->enc_evq_timer_max_us) { + rc = EINVAL; + goto fail3; + } + /* Set up the handler table */ eep->ee_rx = ef10_ev_rx; eep->ee_tx = ef10_ev_tx; @@ -280,11 +304,13 @@ ef10_ev_qcreate( * Interrupts may be raised for events immediately after the queue is * created. See bug58606. */ - if ((rc = efx_mcdi_init_evq(enp, index, esmp, n, irq)) != 0) - goto fail3; + if ((rc = efx_mcdi_init_evq(enp, index, esmp, n, irq, us)) != 0) + goto fail4; return (0); +fail4: + EFSYS_PROBE(fail4); fail3: EFSYS_PROBE(fail3); fail2: Modified: stable/10/sys/dev/sfxge/common/ef10_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_impl.h Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/ef10_impl.h Fri Jun 17 08:56:01 2016 (r301980) @@ -84,6 +84,7 @@ ef10_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __in efx_evq_t *eep); void Modified: stable/10/sys/dev/sfxge/common/efx.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 08:56:01 2016 (r301980) @@ -1602,6 +1602,7 @@ efx_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __deref_out efx_evq_t **eepp); extern void Modified: stable/10/sys/dev/sfxge/common/efx_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_ev.c Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/efx_ev.c Fri Jun 17 08:56:01 2016 (r301980) @@ -70,6 +70,7 @@ siena_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __in efx_evq_t *eep); static void @@ -226,6 +227,7 @@ efx_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __deref_out efx_evq_t **eepp) { const efx_ev_ops_t *eevop = enp->en_eevop; @@ -262,7 +264,7 @@ efx_ev_qcreate( enp->en_ev_qcount++; *eepp = eep; - if ((rc = eevop->eevo_qcreate(enp, index, esmp, n, id, eep)) != 0) + if ((rc = eevop->eevo_qcreate(enp, index, esmp, n, id, us, eep)) != 0) goto fail2; return (0); @@ -1257,6 +1259,7 @@ siena_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __in efx_evq_t *eep) { efx_nic_cfg_t *encp = &(enp->en_nic_cfg); @@ -1312,6 +1315,9 @@ siena_ev_qcreate( EFX_BAR_TBL_WRITEO(enp, FR_AZ_EVQ_PTR_TBL, index, &oword, B_TRUE); + /* Set initial interrupt moderation */ + siena_ev_qmoderate(eep, us); + return (0); fail4: Modified: stable/10/sys/dev/sfxge/common/efx_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_impl.h Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/efx_impl.h Fri Jun 17 08:56:01 2016 (r301980) @@ -95,7 +95,7 @@ typedef struct efx_ev_ops_s { void (*eevo_fini)(efx_nic_t *); efx_rc_t (*eevo_qcreate)(efx_nic_t *, unsigned int, efsys_mem_t *, size_t, uint32_t, - efx_evq_t *); + uint32_t, efx_evq_t *); void (*eevo_qdestroy)(efx_evq_t *); efx_rc_t (*eevo_qprime)(efx_evq_t *, unsigned int); void (*eevo_qpost)(efx_evq_t *, uint16_t); Modified: stable/10/sys/dev/sfxge/sfxge_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_ev.c Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/sfxge_ev.c Fri Jun 17 08:56:01 2016 (r301980) @@ -699,14 +699,11 @@ sfxge_ev_qstart(struct sfxge_softc *sc, /* Create the common code event queue. */ if ((rc = efx_ev_qcreate(sc->enp, index, esmp, evq->entries, - evq->buf_base_id, &evq->common)) != 0) + evq->buf_base_id, sc->ev_moderation, &evq->common)) != 0) goto fail; SFXGE_EVQ_LOCK(evq); - /* Set the default moderation */ - (void)efx_ev_qmoderate(evq->common, sc->ev_moderation); - /* Prime the event queue for interrupts */ if ((rc = efx_ev_qprime(evq->common, evq->read_ptr)) != 0) goto fail2; From owner-svn-src-stable-10@freebsd.org Fri Jun 17 08:56:49 2016 Return-Path: Delivered-To: svn-src-stable-10@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 02A0CA78D18; Fri, 17 Jun 2016 08:56:49 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C54DF2E72; Fri, 17 Jun 2016 08:56:48 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H8umqj011122; Fri, 17 Jun 2016 08:56:48 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H8umeg011121; Fri, 17 Jun 2016 08:56:48 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170856.u5H8umeg011121@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 08:56:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301981 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 08:56:49 -0000 Author: arybchik Date: Fri Jun 17 08:56:47 2016 New Revision: 301981 URL: https://svnweb.freebsd.org/changeset/base/301981 Log: MFC r301125 sfxge(4): cleanup: add missing space after if keyword Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_lic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_lic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_lic.c Fri Jun 17 08:56:01 2016 (r301980) +++ stable/10/sys/dev/sfxge/common/efx_lic.c Fri Jun 17 08:56:47 2016 (r301981) @@ -506,7 +506,7 @@ efx_lic_v1v2_find_key( _NOTE(ARGUNUSED(enp)) - if((size_t)buffer_size - offset < EFX_LICENSE_V1V2_HEADER_LENGTH) + if ((size_t)buffer_size - offset < EFX_LICENSE_V1V2_HEADER_LENGTH) goto fail1; tlv_type = __LE_TO_CPU_16(((uint16_t*)&bufferp[offset])[0]); @@ -548,7 +548,7 @@ efx_lic_v1v2_validate_key( tlv_type = __LE_TO_CPU_16(((uint16_t*)keyp)[0]); tlv_length = __LE_TO_CPU_16(((uint16_t*)keyp)[1]); - if(tlv_length > EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX) { + if (tlv_length > EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX) { goto fail2; } if (tlv_type == 0) { From owner-svn-src-stable-10@freebsd.org Fri Jun 17 08:57:54 2016 Return-Path: Delivered-To: svn-src-stable-10@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 6F980A78DA7; Fri, 17 Jun 2016 08:57:54 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 323412FD4; Fri, 17 Jun 2016 08:57:54 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H8vrnO011219; Fri, 17 Jun 2016 08:57:53 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H8vrPY011215; Fri, 17 Jun 2016 08:57:53 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170857.u5H8vrPY011215@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 08:57:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301982 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 08:57:54 -0000 Author: arybchik Date: Fri Jun 17 08:57:52 2016 New Revision: 301982 URL: https://svnweb.freebsd.org/changeset/base/301982 Log: MFC r301127 sfxge(4): cleanup: remove unused variables in common code Submitted by: Andy Moreton Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_ev.c stable/10/sys/dev/sfxge/common/efx_lic.c stable/10/sys/dev/sfxge/common/efx_mcdi.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_ev.c Fri Jun 17 08:56:47 2016 (r301981) +++ stable/10/sys/dev/sfxge/common/efx_ev.c Fri Jun 17 08:57:52 2016 (r301982) @@ -349,7 +349,6 @@ efx_ev_qprefetch( __in efx_evq_t *eep, __in unsigned int count) { - efx_nic_t *enp = eep->ee_enp; unsigned int offset; EFSYS_ASSERT3U(eep->ee_magic, ==, EFX_EVQ_MAGIC); Modified: stable/10/sys/dev/sfxge/common/efx_lic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_lic.c Fri Jun 17 08:56:47 2016 (r301981) +++ stable/10/sys/dev/sfxge/common/efx_lic.c Fri Jun 17 08:57:52 2016 (r301982) @@ -534,8 +534,6 @@ efx_lic_v1v2_validate_key( __in uint32_t length ) { - const efx_lic_ops_t *elop = enp->en_elop; - efx_rc_t rc; uint16_t tlv_type; uint16_t tlv_length; @@ -658,7 +656,6 @@ efx_lic_v1v2_delete_key( __out uint32_t *deltap ) { - efx_rc_t rc; uint32_t move_start = offset + length; uint32_t move_length = end - move_start; @@ -1158,7 +1155,6 @@ efx_lic_v3_validate_key( ) { // Check key is a valid V3 key - efx_rc_t rc; uint8_t key_type; uint8_t key_length; @@ -1396,8 +1392,6 @@ efx_lic_check_support( efx_lic_fini( __in efx_nic_t *enp) { - const efx_lic_ops_t *elop = enp->en_elop; - EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC); @@ -1573,7 +1567,6 @@ efx_lic_find_key( ) { const efx_lic_ops_t *elop = enp->en_elop; - boolean_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC); @@ -1599,8 +1592,6 @@ efx_lic_validate_key( { const efx_lic_ops_t *elop = enp->en_elop; boolean_t rc; - uint16_t tlv_type; - uint16_t tlv_length; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC); Modified: stable/10/sys/dev/sfxge/common/efx_mcdi.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_mcdi.c Fri Jun 17 08:56:47 2016 (r301981) +++ stable/10/sys/dev/sfxge/common/efx_mcdi.c Fri Jun 17 08:57:52 2016 (r301982) @@ -795,7 +795,6 @@ efx_mcdi_get_proxy_handle( __in efx_mcdi_req_t *emrp, __out uint32_t *handlep) { - efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); efx_rc_t rc; /* From owner-svn-src-stable-10@freebsd.org Fri Jun 17 08:59:10 2016 Return-Path: Delivered-To: svn-src-stable-10@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 2FD9BA78E41; Fri, 17 Jun 2016 08:59:10 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 0C87A1276; Fri, 17 Jun 2016 08:59:09 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H8x9TN011326; Fri, 17 Jun 2016 08:59:09 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H8x8mG011322; Fri, 17 Jun 2016 08:59:08 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170859.u5H8x8mG011322@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 08:59:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301983 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 08:59:10 -0000 Author: arybchik Date: Fri Jun 17 08:59:08 2016 New Revision: 301983 URL: https://svnweb.freebsd.org/changeset/base/301983 Log: MFC r301237 sfxge(4): support EVQ timer workaround via MCDI Submitted by: Andy Moreton Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/6675 Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c stable/10/sys/dev/sfxge/common/efx.h stable/10/sys/dev/sfxge/common/hunt_nic.c stable/10/sys/dev/sfxge/common/medford_nic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 08:57:52 2016 (r301982) +++ stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 08:59:08 2016 (r301983) @@ -87,6 +87,52 @@ ef10_ev_mcdi( static __checkReturn efx_rc_t +efx_mcdi_set_evq_tmr( + __in efx_nic_t *enp, + __in uint32_t instance, + __in uint32_t mode, + __in uint32_t timer_ns) +{ + efx_mcdi_req_t req; + uint8_t payload[MAX(MC_CMD_SET_EVQ_TMR_IN_LEN, + MC_CMD_SET_EVQ_TMR_OUT_LEN)]; + efx_rc_t rc; + + (void) memset(payload, 0, sizeof (payload)); + req.emr_cmd = MC_CMD_SET_EVQ_TMR; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_SET_EVQ_TMR_IN_LEN; + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_SET_EVQ_TMR_OUT_LEN; + + MCDI_IN_SET_DWORD(req, SET_EVQ_TMR_IN_INSTANCE, instance); + MCDI_IN_SET_DWORD(req, SET_EVQ_TMR_IN_TMR_LOAD_REQ_NS, timer_ns); + MCDI_IN_SET_DWORD(req, SET_EVQ_TMR_IN_TMR_RELOAD_REQ_NS, timer_ns); + MCDI_IN_SET_DWORD(req, SET_EVQ_TMR_IN_TMR_MODE, mode); + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail1; + } + + if (req.emr_out_length_used < MC_CMD_SET_EVQ_TMR_OUT_LEN) { + rc = EMSGSIZE; + goto fail2; + } + + return (0); + +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + +static __checkReturn efx_rc_t efx_mcdi_init_evq( __in efx_nic_t *enp, __in unsigned int instance, @@ -437,9 +483,19 @@ ef10_ev_qmoderate( efx_nic_t *enp = eep->ee_enp; efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_dword_t dword; - uint32_t timer_val, mode; + uint32_t timer_ns, timer_val, mode; efx_rc_t rc; + /* Check that hardware and MCDI use the same timer MODE values */ + EFX_STATIC_ASSERT(FFE_CZ_TIMER_MODE_DIS == + MC_CMD_SET_EVQ_TMR_IN_TIMER_MODE_DIS); + EFX_STATIC_ASSERT(FFE_CZ_TIMER_MODE_IMMED_START == + MC_CMD_SET_EVQ_TMR_IN_TIMER_MODE_IMMED_START); + EFX_STATIC_ASSERT(FFE_CZ_TIMER_MODE_TRIG_START == + MC_CMD_SET_EVQ_TMR_IN_TIMER_MODE_TRIG_START); + EFX_STATIC_ASSERT(FFE_CZ_TIMER_MODE_INT_HLDOFF == + MC_CMD_SET_EVQ_TMR_IN_TIMER_MODE_INT_HLDOFF); + if (us > encp->enc_evq_timer_max_us) { rc = EINVAL; goto fail1; @@ -447,37 +503,46 @@ ef10_ev_qmoderate( /* If the value is zero then disable the timer */ if (us == 0) { - timer_val = 0; + timer_ns = 0; mode = FFE_CZ_TIMER_MODE_DIS; } else { + timer_ns = us * 1000u; + mode = FFE_CZ_TIMER_MODE_INT_HLDOFF; + } + + if (encp->enc_bug61265_workaround) { + rc = efx_mcdi_set_evq_tmr(enp, eep->ee_index, mode, timer_ns); + if (rc != 0) + goto fail2; + } else { /* Calculate the timer value in quanta */ - timer_val = us * 1000 / encp->enc_evq_timer_quantum_ns; + timer_val = timer_ns / encp->enc_evq_timer_quantum_ns; /* Moderation value is base 0 so we need to deduct 1 */ if (timer_val > 0) timer_val--; - mode = FFE_CZ_TIMER_MODE_INT_HLDOFF; - } - - if (encp->enc_bug35388_workaround) { - EFX_POPULATE_DWORD_3(dword, - ERF_DD_EVQ_IND_TIMER_FLAGS, - EFE_DD_EVQ_IND_TIMER_FLAGS, - ERF_DD_EVQ_IND_TIMER_MODE, mode, - ERF_DD_EVQ_IND_TIMER_VAL, timer_val); - EFX_BAR_TBL_WRITED(enp, ER_DD_EVQ_INDIRECT, - eep->ee_index, &dword, 0); - } else { - EFX_POPULATE_DWORD_2(dword, - ERF_DZ_TC_TIMER_MODE, mode, - ERF_DZ_TC_TIMER_VAL, timer_val); - EFX_BAR_TBL_WRITED(enp, ER_DZ_EVQ_TMR_REG, - eep->ee_index, &dword, 0); + if (encp->enc_bug35388_workaround) { + EFX_POPULATE_DWORD_3(dword, + ERF_DD_EVQ_IND_TIMER_FLAGS, + EFE_DD_EVQ_IND_TIMER_FLAGS, + ERF_DD_EVQ_IND_TIMER_MODE, mode, + ERF_DD_EVQ_IND_TIMER_VAL, timer_val); + EFX_BAR_TBL_WRITED(enp, ER_DD_EVQ_INDIRECT, + eep->ee_index, &dword, 0); + } else { + EFX_POPULATE_DWORD_2(dword, + ERF_DZ_TC_TIMER_MODE, mode, + ERF_DZ_TC_TIMER_VAL, timer_val); + EFX_BAR_TBL_WRITED(enp, ER_DZ_EVQ_TMR_REG, + eep->ee_index, &dword, 0); + } } return (0); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); Modified: stable/10/sys/dev/sfxge/common/efx.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 08:57:52 2016 (r301982) +++ stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 08:59:08 2016 (r301983) @@ -1129,6 +1129,7 @@ typedef struct efx_nic_cfg_s { boolean_t enc_bug26807_workaround; boolean_t enc_bug35388_workaround; boolean_t enc_bug41750_workaround; + boolean_t enc_bug61265_workaround; boolean_t enc_rx_batching_enabled; /* Maximum number of descriptors completed in an rx event. */ uint32_t enc_rx_batch_max; Modified: stable/10/sys/dev/sfxge/common/hunt_nic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/hunt_nic.c Fri Jun 17 08:57:52 2016 (r301982) +++ stable/10/sys/dev/sfxge/common/hunt_nic.c Fri Jun 17 08:59:08 2016 (r301983) @@ -291,6 +291,8 @@ hunt_board_cfg( FRF_CZ_TC_TIMER_VAL_WIDTH) / 1000; } + encp->enc_bug61265_workaround = B_FALSE; /* Medford only */ + /* Check capabilities of running datapath firmware */ if ((rc = ef10_get_datapath_caps(enp)) != 0) goto fail12; Modified: stable/10/sys/dev/sfxge/common/medford_nic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/medford_nic.c Fri Jun 17 08:57:52 2016 (r301982) +++ stable/10/sys/dev/sfxge/common/medford_nic.c Fri Jun 17 08:59:08 2016 (r301983) @@ -227,6 +227,23 @@ medford_board_cfg( epp->ep_default_adv_cap_mask = els.els_adv_cap_mask; epp->ep_adv_cap_mask = els.els_adv_cap_mask; + /* + * Enable firmware workarounds for hardware errata. + * Expected responses are: + * - 0 (zero): + * Success: workaround enabled or disabled as requested. + * - MC_CMD_ERR_ENOSYS (reported as ENOTSUP): + * Firmware does not support the MC_CMD_WORKAROUND request. + * (assume that the workaround is not supported). + * - MC_CMD_ERR_ENOENT (reported as ENOENT): + * Firmware does not support the requested workaround. + * - MC_CMD_ERR_EPERM (reported as EACCES): + * Unprivileged function cannot enable/disable workarounds. + * + * See efx_mcdi_request_errcode() for MCDI error translations. + */ + + if (EFX_PCI_FUNCTION_IS_VF(encp)) { /* * Interrupt testing does not work for VFs. See bug50084. @@ -238,9 +255,23 @@ medford_board_cfg( /* Chained multicast is always enabled on Medford */ encp->enc_bug26807_workaround = B_TRUE; + /* + * If the bug61265 workaround is enabled, then interrupt holdoff timers + * cannot be controlled by timer table writes, so MCDI must be used + * (timer table writes can still be used for wakeup timers). + */ + rc = efx_mcdi_set_workaround(enp, MC_CMD_WORKAROUND_BUG61265, B_TRUE, + NULL); + if ((rc == 0) || (rc == EACCES)) + encp->enc_bug61265_workaround = B_TRUE; + else if ((rc == ENOTSUP) || (rc == ENOENT)) + encp->enc_bug61265_workaround = B_FALSE; + else + goto fail8; + /* Get clock frequencies (in MHz). */ if ((rc = efx_mcdi_get_clock(enp, &sysclk, &dpcpu_clk)) != 0) - goto fail8; + goto fail9; /* * The Medford timer quantum is 1536 dpcpu_clk cycles, documented for @@ -252,14 +283,14 @@ medford_board_cfg( /* Check capabilities of running datapath firmware */ if ((rc = ef10_get_datapath_caps(enp)) != 0) - goto fail9; + goto fail10; /* Alignment for receive packet DMA buffers */ encp->enc_rx_buf_align_start = 1; /* Get the RX DMA end padding alignment configuration */ if ((rc = efx_mcdi_get_rxdp_config(enp, &end_padding)) != 0) - goto fail10; + goto fail11; encp->enc_rx_buf_align_end = end_padding; /* Alignment for WPTR updates */ @@ -288,13 +319,13 @@ medford_board_cfg( * can result in time-of-check/time-of-use bugs. */ if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0) - goto fail11; + goto fail12; encp->enc_privilege_mask = mask; /* Get interrupt vector limits */ if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) { if (EFX_PCI_FUNCTION_IS_PF(encp)) - goto fail12; + goto fail13; /* Ignore error (cannot query vector limits from a VF). */ base = 0; @@ -317,12 +348,14 @@ medford_board_cfg( rc = medford_nic_get_required_pcie_bandwidth(enp, &bandwidth); if (rc != 0) - goto fail13; + goto fail14; encp->enc_required_pcie_bandwidth_mbps = bandwidth; encp->enc_max_pcie_link_gen = EFX_PCIE_LINK_SPEED_GEN3; return (0); +fail14: + EFSYS_PROBE(fail14); fail13: EFSYS_PROBE(fail13); fail12: From owner-svn-src-stable-10@freebsd.org Fri Jun 17 09:01:13 2016 Return-Path: Delivered-To: svn-src-stable-10@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 13CCCA7811A; Fri, 17 Jun 2016 09:01:13 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 E056B14B7; Fri, 17 Jun 2016 09:01:12 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H91CI2011502; Fri, 17 Jun 2016 09:01:12 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H91Bm9011496; Fri, 17 Jun 2016 09:01:11 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170901.u5H91Bm9011496@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 09:01:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301984 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 09:01:13 -0000 Author: arybchik Date: Fri Jun 17 09:01:11 2016 New Revision: 301984 URL: https://svnweb.freebsd.org/changeset/base/301984 Log: MFC r301308 sfxge(4): add helper to compute timer quantum This also adjusts the timer values used to match the Linux net driver implementation: a) non-zero time intervals should result in at least one quantum b) timer load/reload values are only zero biased for Falcon/Siena Submitted by: Andy Moreton Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/D6704 Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c stable/10/sys/dev/sfxge/common/efx.h stable/10/sys/dev/sfxge/common/efx_ev.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 08:59:08 2016 (r301983) +++ stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 09:01:11 2016 (r301984) @@ -141,7 +141,6 @@ efx_mcdi_init_evq( __in uint32_t irq, __in uint32_t us) { - efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_mcdi_req_t req; uint8_t payload[ MAX(MC_CMD_INIT_EVQ_IN_LEN(EFX_EVQ_NBUFS(EFX_EVQ_MAXNEVS)), @@ -189,25 +188,22 @@ efx_mcdi_init_evq( INIT_EVQ_IN_FLAG_RX_MERGE, 1, INIT_EVQ_IN_FLAG_TX_MERGE, 1); + /* If the value is zero then disable the timer */ if (us == 0) { MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_MODE, MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS); MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, 0); MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, 0); } else { - uint32_t timer_val; + unsigned int ticks; - /* Calculate the timer value in quanta */ - timer_val = us * 1000 / encp->enc_evq_timer_quantum_ns; - - /* Moderation value is base 0 so we need to deduct 1 */ - if (timer_val > 0) - timer_val--; + if ((rc = efx_ev_usecs_to_ticks(enp, us, &ticks)) != 0) + goto fail2; MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_MODE, MC_CMD_INIT_EVQ_IN_TMR_INT_HLDOFF); - MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, timer_val); - MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, timer_val); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, ticks); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, ticks); } MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_COUNT_MODE, @@ -230,18 +226,20 @@ efx_mcdi_init_evq( if (req.emr_rc != 0) { rc = req.emr_rc; - goto fail2; + goto fail3; } if (req.emr_out_length_used < MC_CMD_INIT_EVQ_OUT_LEN) { rc = EMSGSIZE; - goto fail3; + goto fail4; } /* NOTE: ignore the returned IRQ param as firmware does not set it. */ return (0); +fail4: + EFSYS_PROBE(fail4); fail3: EFSYS_PROBE(fail3); fail2: @@ -483,7 +481,7 @@ ef10_ev_qmoderate( efx_nic_t *enp = eep->ee_enp; efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_dword_t dword; - uint32_t timer_ns, timer_val, mode; + uint32_t mode; efx_rc_t rc; /* Check that hardware and MCDI use the same timer MODE values */ @@ -503,37 +501,35 @@ ef10_ev_qmoderate( /* If the value is zero then disable the timer */ if (us == 0) { - timer_ns = 0; mode = FFE_CZ_TIMER_MODE_DIS; } else { - timer_ns = us * 1000u; mode = FFE_CZ_TIMER_MODE_INT_HLDOFF; } if (encp->enc_bug61265_workaround) { - rc = efx_mcdi_set_evq_tmr(enp, eep->ee_index, mode, timer_ns); + uint32_t ns = us * 1000; + + rc = efx_mcdi_set_evq_tmr(enp, eep->ee_index, mode, ns); if (rc != 0) goto fail2; } else { - /* Calculate the timer value in quanta */ - timer_val = timer_ns / encp->enc_evq_timer_quantum_ns; + unsigned int ticks; - /* Moderation value is base 0 so we need to deduct 1 */ - if (timer_val > 0) - timer_val--; + if ((rc = efx_ev_usecs_to_ticks(enp, us, &ticks)) != 0) + goto fail3; if (encp->enc_bug35388_workaround) { EFX_POPULATE_DWORD_3(dword, ERF_DD_EVQ_IND_TIMER_FLAGS, EFE_DD_EVQ_IND_TIMER_FLAGS, ERF_DD_EVQ_IND_TIMER_MODE, mode, - ERF_DD_EVQ_IND_TIMER_VAL, timer_val); + ERF_DD_EVQ_IND_TIMER_VAL, ticks); EFX_BAR_TBL_WRITED(enp, ER_DD_EVQ_INDIRECT, eep->ee_index, &dword, 0); } else { EFX_POPULATE_DWORD_2(dword, ERF_DZ_TC_TIMER_MODE, mode, - ERF_DZ_TC_TIMER_VAL, timer_val); + ERF_DZ_TC_TIMER_VAL, ticks); EFX_BAR_TBL_WRITED(enp, ER_DZ_EVQ_TMR_REG, eep->ee_index, &dword, 0); } @@ -541,6 +537,8 @@ ef10_ev_qmoderate( return (0); +fail3: + EFSYS_PROBE(fail3); fail2: EFSYS_PROBE(fail2); fail1: Modified: stable/10/sys/dev/sfxge/common/efx.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 08:59:08 2016 (r301983) +++ stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 09:01:11 2016 (r301984) @@ -1773,6 +1773,12 @@ efx_ev_qpoll( __in_opt void *arg); extern __checkReturn efx_rc_t +efx_ev_usecs_to_ticks( + __in efx_nic_t *enp, + __in unsigned int usecs, + __out unsigned int *ticksp); + +extern __checkReturn efx_rc_t efx_ev_qmoderate( __in efx_evq_t *eep, __in unsigned int us); Modified: stable/10/sys/dev/sfxge/common/efx_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_ev.c Fri Jun 17 08:59:08 2016 (r301983) +++ stable/10/sys/dev/sfxge/common/efx_ev.c Fri Jun 17 09:01:11 2016 (r301984) @@ -406,6 +406,27 @@ efx_ev_qpost( } __checkReturn efx_rc_t +efx_ev_usecs_to_ticks( + __in efx_nic_t *enp, + __in unsigned int us, + __out unsigned int *ticksp) +{ + efx_nic_cfg_t *encp = &(enp->en_nic_cfg); + unsigned int ticks; + + /* Convert microseconds to a timer tick count */ + if (us == 0) + ticks = 0; + else if (us * 1000 < encp->enc_evq_timer_quantum_ns) + ticks = 1; /* Never round down to zero */ + else + ticks = us * 1000 / encp->enc_evq_timer_quantum_ns; + + *ticksp = ticks; + return (0); +} + + __checkReturn efx_rc_t efx_ev_qmoderate( __in efx_evq_t *eep, __in unsigned int us) @@ -1224,18 +1245,15 @@ siena_ev_qmoderate( FRF_CZ_TC_TIMER_MODE, FFE_CZ_TIMER_MODE_DIS, FRF_CZ_TC_TIMER_VAL, 0); } else { - uint32_t timer_val; + unsigned int ticks; - /* Calculate the timer value in quanta */ - timer_val = us * 1000 / encp->enc_evq_timer_quantum_ns; - - /* Moderation value is base 0 so we need to deduct 1 */ - if (timer_val > 0) - timer_val--; + if ((rc = efx_ev_usecs_to_ticks(enp, us, &ticks)) != 0) + goto fail2; + EFSYS_ASSERT(ticks > 0); EFX_POPULATE_DWORD_2(dword, FRF_CZ_TC_TIMER_MODE, FFE_CZ_TIMER_MODE_INT_HLDOFF, - FRF_CZ_TC_TIMER_VAL, timer_val); + FRF_CZ_TC_TIMER_VAL, ticks - 1); } locked = (eep->ee_index == 0) ? 1 : 0; @@ -1245,6 +1263,8 @@ siena_ev_qmoderate( return (0); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); From owner-svn-src-stable-10@freebsd.org Fri Jun 17 09:02:53 2016 Return-Path: Delivered-To: svn-src-stable-10@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 58A7FA78185; Fri, 17 Jun 2016 09:02:53 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 0F1CE18F3; Fri, 17 Jun 2016 09:02:52 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H92qEh014935; Fri, 17 Jun 2016 09:02:52 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H92qfl014931; Fri, 17 Jun 2016 09:02:52 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170902.u5H92qfl014931@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 09:02:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301985 - in stable/10/sys/dev/sfxge: . common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 09:02:53 -0000 Author: arybchik Date: Fri Jun 17 09:02:51 2016 New Revision: 301985 URL: https://svnweb.freebsd.org/changeset/base/301985 Log: MFC r301309 sfxge(4): always be ready to receive batched events When the low-latency firmware variant is running, it is reported as not being capable of batching RX events, but it can still do so if the FORCE_EV_MERGING flag is set on an RXQ. Therefore we need to handle batched RX events even if the capability isn't set. If this bug is fixed in the firmware such that the capability is set even when running the low-latency firmware variant, it will almost always be reported so I don't think we lose much by removing the check. Submitted by: Mark Spender Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/D6705 Modified: stable/10/sys/dev/sfxge/common/ef10_nic.c stable/10/sys/dev/sfxge/sfxge_ev.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_nic.c Fri Jun 17 09:01:11 2016 (r301984) +++ stable/10/sys/dev/sfxge/common/ef10_nic.c Fri Jun 17 09:02:51 2016 (r301985) @@ -1003,8 +1003,11 @@ ef10_get_datapath_caps( encp->enc_rx_batching_enabled = CAP_FLAG(flags, RX_BATCHING) ? B_TRUE : B_FALSE; - if (encp->enc_rx_batching_enabled) - encp->enc_rx_batch_max = 16; + /* + * Even if batching isn't reported as supported, we may still get + * batched events. + */ + encp->enc_rx_batch_max = 16; /* Check if the firmware supports disabling scatter on RXQs */ encp->enc_rx_disable_scatter_supported = Modified: stable/10/sys/dev/sfxge/sfxge_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_ev.c Fri Jun 17 09:01:11 2016 (r301984) +++ stable/10/sys/dev/sfxge/sfxge_ev.c Fri Jun 17 09:02:51 2016 (r301985) @@ -123,8 +123,7 @@ sfxge_ev_rx(void *arg, uint32_t label, u rxq->pending += delta; if (delta != 1) { - if ((!efx_nic_cfg_get(sc->enp)->enc_rx_batching_enabled) || - (delta <= 0) || + if ((delta <= 0) || (delta > efx_nic_cfg_get(sc->enp)->enc_rx_batch_max)) { evq->exception = B_TRUE; From owner-svn-src-stable-10@freebsd.org Fri Jun 17 09:04:08 2016 Return-Path: Delivered-To: svn-src-stable-10@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 26EBAA7823B; Fri, 17 Jun 2016 09:04:08 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 F29FF1B00; Fri, 17 Jun 2016 09:04:07 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H947BW015066; Fri, 17 Jun 2016 09:04:07 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H946E0015063; Fri, 17 Jun 2016 09:04:06 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170904.u5H946E0015063@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 09:04:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301986 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 09:04:08 -0000 Author: arybchik Date: Fri Jun 17 09:04:06 2016 New Revision: 301986 URL: https://svnweb.freebsd.org/changeset/base/301986 Log: MFC r301427 sfxge(4): allow firmware to auto-configure event queues on Medford On Medford, licenses are required to enable RX and event cut through and to disable RX batching. To avoid the need for the driver to make decisions based on the licensing state, the MC_CMD_INIT_EVQ has been extended to allow us to leave the decision to the firmware. If the adapter is licensed for low-latency use, the firmware will choose the optimal settings for latency, otherwise it will use the best settings for throughput. For Huntington we still need to choose the settings ourselves. Submitted by: Mark Spender Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/D6717 Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c stable/10/sys/dev/sfxge/common/ef10_nic.c stable/10/sys/dev/sfxge/common/efx.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 09:02:51 2016 (r301985) +++ stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 09:04:06 2016 (r301986) @@ -139,7 +139,8 @@ efx_mcdi_init_evq( __in efsys_mem_t *esmp, __in size_t nevs, __in uint32_t irq, - __in uint32_t us) + __in uint32_t us, + __in boolean_t low_latency) { efx_mcdi_req_t req; uint8_t payload[ @@ -149,7 +150,7 @@ efx_mcdi_init_evq( uint64_t addr; int npages; int i; - int supports_rx_batching; + int ev_cut_through; efx_rc_t rc; npages = EFX_EVQ_NBUFS(nevs); @@ -170,21 +171,19 @@ efx_mcdi_init_evq( MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_IRQ_NUM, irq); /* - * On Huntington RX and TX event batching can only be requested - * together (even if the datapath firmware doesn't actually support RX - * batching). - * Cut through is incompatible with RX batching and so enabling cut - * through disables RX batching (but it does not affect TX batching). + * On Huntington RX and TX event batching can only be requested together + * (even if the datapath firmware doesn't actually support RX + * batching). If event cut through is enabled no RX batching will occur. * - * So always enable RX and TX event batching, and enable cut through - * if RX event batching isn't supported (i.e. on low latency firmware). + * So always enable RX and TX event batching, and enable event cut + * through if we want low latency operation. */ - supports_rx_batching = enp->en_nic_cfg.enc_rx_batching_enabled ? 1 : 0; + ev_cut_through = low_latency ? 1 : 0; MCDI_IN_POPULATE_DWORD_6(req, INIT_EVQ_IN_FLAGS, INIT_EVQ_IN_FLAG_INTERRUPTING, 1, INIT_EVQ_IN_FLAG_RPTR_DOS, 0, INIT_EVQ_IN_FLAG_INT_ARMD, 0, - INIT_EVQ_IN_FLAG_CUT_THRU, !supports_rx_batching, + INIT_EVQ_IN_FLAG_CUT_THRU, ev_cut_through, INIT_EVQ_IN_FLAG_RX_MERGE, 1, INIT_EVQ_IN_FLAG_TX_MERGE, 1); @@ -250,6 +249,114 @@ fail1: return (rc); } + +static __checkReturn efx_rc_t +efx_mcdi_init_evq_v2( + __in efx_nic_t *enp, + __in unsigned int instance, + __in efsys_mem_t *esmp, + __in size_t nevs, + __in uint32_t irq, + __in uint32_t us) +{ + efx_mcdi_req_t req; + uint8_t payload[ + MAX(MC_CMD_INIT_EVQ_V2_IN_LEN(EFX_EVQ_NBUFS(EFX_EVQ_MAXNEVS)), + MC_CMD_INIT_EVQ_V2_OUT_LEN)]; + efx_qword_t *dma_addr; + uint64_t addr; + int npages; + int i; + efx_rc_t rc; + + npages = EFX_EVQ_NBUFS(nevs); + if (MC_CMD_INIT_EVQ_V2_IN_LEN(npages) > MC_CMD_INIT_EVQ_V2_IN_LENMAX) { + rc = EINVAL; + goto fail1; + } + + (void) memset(payload, 0, sizeof (payload)); + req.emr_cmd = MC_CMD_INIT_EVQ; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_INIT_EVQ_V2_IN_LEN(npages); + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_INIT_EVQ_V2_OUT_LEN; + + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_SIZE, nevs); + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_INSTANCE, instance); + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_IRQ_NUM, irq); + + MCDI_IN_POPULATE_DWORD_4(req, INIT_EVQ_V2_IN_FLAGS, + INIT_EVQ_V2_IN_FLAG_INTERRUPTING, 1, + INIT_EVQ_V2_IN_FLAG_RPTR_DOS, 0, + INIT_EVQ_V2_IN_FLAG_INT_ARMD, 0, + INIT_EVQ_V2_IN_FLAG_TYPE, MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_AUTO); + + /* If the value is zero then disable the timer */ + if (us == 0) { + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_TMR_MODE, + MC_CMD_INIT_EVQ_V2_IN_TMR_MODE_DIS); + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_TMR_LOAD, 0); + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_TMR_RELOAD, 0); + } else { + unsigned int ticks; + + if ((rc = efx_ev_usecs_to_ticks(enp, us, &ticks)) != 0) + goto fail2; + + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_TMR_MODE, + MC_CMD_INIT_EVQ_V2_IN_TMR_INT_HLDOFF); + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_TMR_LOAD, ticks); + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_TMR_RELOAD, ticks); + } + + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_COUNT_MODE, + MC_CMD_INIT_EVQ_V2_IN_COUNT_MODE_DIS); + MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_COUNT_THRSHLD, 0); + + dma_addr = MCDI_IN2(req, efx_qword_t, INIT_EVQ_V2_IN_DMA_ADDR); + addr = EFSYS_MEM_ADDR(esmp); + + for (i = 0; i < npages; i++) { + EFX_POPULATE_QWORD_2(*dma_addr, + EFX_DWORD_1, (uint32_t)(addr >> 32), + EFX_DWORD_0, (uint32_t)(addr & 0xffffffff)); + + dma_addr++; + addr += EFX_BUF_SIZE; + } + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail3; + } + + if (req.emr_out_length_used < MC_CMD_INIT_EVQ_V2_OUT_LEN) { + rc = EMSGSIZE; + goto fail4; + } + + /* NOTE: ignore the returned IRQ param as firmware does not set it. */ + + EFSYS_PROBE1(mcdi_evq_flags, uint32_t, + MCDI_OUT_DWORD(req, INIT_EVQ_V2_OUT_FLAGS)); + + return (0); + +fail4: + EFSYS_PROBE(fail4); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + static __checkReturn efx_rc_t efx_mcdi_fini_evq( __in efx_nic_t *enp, @@ -348,11 +455,41 @@ ef10_ev_qcreate( * Interrupts may be raised for events immediately after the queue is * created. See bug58606. */ - if ((rc = efx_mcdi_init_evq(enp, index, esmp, n, irq, us)) != 0) - goto fail4; + + if (encp->enc_init_evq_v2_supported) { + /* + * On Medford the low latency license is required to enable RX + * and event cut through and to disable RX batching. We let the + * firmware decide the settings to use. If the adapter has a low + * latency license, it will choose the best settings for low + * latency, otherwise it choose the best settings for + * throughput. + */ + rc = efx_mcdi_init_evq_v2(enp, index, esmp, n, irq, us); + if (rc != 0) + goto fail4; + } else { + /* + * On Huntington we need to specify the settings to use. We + * favour latency if the adapter is running low-latency firmware + * and throughput otherwise, and assume not support RX batching + * implies the adapter is running low-latency firmware. (This + * is how it's been done since Huntington GA. It doesn't make + * much sense with hindsight as the 'low-latency' firmware + * variant is also best for throughput, and does now support RX + * batching). + */ + boolean_t low_latency = encp->enc_rx_batching_enabled ? 0 : 1; + rc = efx_mcdi_init_evq(enp, index, esmp, n, irq, us, + low_latency); + if (rc != 0) + goto fail5; + } return (0); +fail5: + EFSYS_PROBE(fail5); fail4: EFSYS_PROBE(fail4); fail3: Modified: stable/10/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_nic.c Fri Jun 17 09:02:51 2016 (r301985) +++ stable/10/sys/dev/sfxge/common/ef10_nic.c Fri Jun 17 09:04:06 2016 (r301986) @@ -1025,6 +1025,13 @@ ef10_get_datapath_caps( encp->enc_enhanced_set_mac_supported = CAP_FLAG(flags, SET_MAC_ENHANCED) ? B_TRUE : B_FALSE; + /* + * Check if firmware supports version 2 of MC_CMD_INIT_EVQ, which allows + * us to let the firmware choose the settings to use on an EVQ. + */ + encp->enc_init_evq_v2_supported = + CAP_FLAG2(flags2, INIT_EVQ_V2) ? B_TRUE : B_FALSE; + #undef CAP_FLAG #undef CAP_FLAG2 Modified: stable/10/sys/dev/sfxge/common/efx.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 09:02:51 2016 (r301985) +++ stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 09:04:06 2016 (r301986) @@ -1148,6 +1148,7 @@ typedef struct efx_nic_cfg_s { boolean_t enc_rx_disable_scatter_supported; boolean_t enc_allow_set_mac_with_installed_filters; boolean_t enc_enhanced_set_mac_supported; + boolean_t enc_init_evq_v2_supported; /* External port identifier */ uint8_t enc_external_port; uint32_t enc_mcdi_max_payload_length; From owner-svn-src-stable-10@freebsd.org Fri Jun 17 09:05:27 2016 Return-Path: Delivered-To: svn-src-stable-10@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 796A1A782F1; Fri, 17 Jun 2016 09:05:27 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 4A0271D5D; Fri, 17 Jun 2016 09:05:27 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H95QOd015318; Fri, 17 Jun 2016 09:05:26 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H95QKt015317; Fri, 17 Jun 2016 09:05:26 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170905.u5H95QKt015317@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 09:05:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301987 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 09:05:27 -0000 Author: arybchik Date: Fri Jun 17 09:05:26 2016 New Revision: 301987 URL: https://svnweb.freebsd.org/changeset/base/301987 Log: MFC r301495 sfxge(4): update TX vFIFO ULL tag location to avoid merge conflict Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/ef10_tlv_layout.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_tlv_layout.h ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_tlv_layout.h Fri Jun 17 09:04:06 2016 (r301986) +++ stable/10/sys/dev/sfxge/common/ef10_tlv_layout.h Fri Jun 17 09:05:26 2016 (r301987) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2012-2015 Solarflare Communications Inc. + * Copyright (c) 2012-2016 Solarflare Communications Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -801,7 +801,7 @@ struct tlv_tx_event_merging_config { * know if the low latency mode is enabled. */ -#define TLV_TAG_TX_VFIFO_ULL_MODE (0x10220000) +#define TLV_TAG_TX_VFIFO_ULL_MODE (0x10270000) struct tlv_tx_vfifo_ull_mode { uint32_t tag; uint32_t length; From owner-svn-src-stable-10@freebsd.org Fri Jun 17 09:06:32 2016 Return-Path: Delivered-To: svn-src-stable-10@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 01B08A78362; Fri, 17 Jun 2016 09:06:32 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A9C6B1ECA; Fri, 17 Jun 2016 09:06:31 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H96UKo015433; Fri, 17 Jun 2016 09:06:30 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H96U9g015432; Fri, 17 Jun 2016 09:06:30 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170906.u5H96U9g015432@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 09:06:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301988 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 09:06:32 -0000 Author: arybchik Date: Fri Jun 17 09:06:30 2016 New Revision: 301988 URL: https://svnweb.freebsd.org/changeset/base/301988 Log: MFC r301604 sfxge(4): cleanup: add missing probes to ef10_nvram_segment_write_tlv Submitted by: Andy Moreton Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/ef10_nvram.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_nvram.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_nvram.c Fri Jun 17 09:05:26 2016 (r301987) +++ stable/10/sys/dev/sfxge/common/ef10_nvram.c Fri Jun 17 09:06:30 2016 (r301988) @@ -1658,7 +1658,7 @@ ef10_nvram_partn_write_tlv( * Read a segment from nvram at the given offset into a buffer (segment_data) * and optionally write a new tag to it. */ - static __checkReturn efx_rc_t +static __checkReturn efx_rc_t ef10_nvram_segment_write_tlv( __in efx_nic_t *enp, __in uint32_t partn, @@ -1684,20 +1684,25 @@ ef10_nvram_segment_write_tlv( */ status = ef10_nvram_read_tlv_segment(enp, partn, *partn_offsetp, *seg_datap, *src_remain_lenp); - if (status != 0) - return (EINVAL); + if (status != 0) { + rc = EINVAL; + goto fail1; + } status = ef10_nvram_buf_segment_size(*seg_datap, *src_remain_lenp, &original_segment_size); - if (status != 0) - return (EINVAL); + if (status != 0) { + rc = EINVAL; + goto fail2; + } if (write) { /* Update the contents of the segment in the buffer */ if ((rc = ef10_nvram_buf_write_tlv(*seg_datap, *dest_remain_lenp, tag, data, size, - &modified_segment_size)) != 0) - goto fail1; + &modified_segment_size)) != 0) { + goto fail3; + } *dest_remain_lenp -= modified_segment_size; *seg_datap += modified_segment_size; } else { @@ -1714,6 +1719,10 @@ ef10_nvram_segment_write_tlv( return (0); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); From owner-svn-src-stable-10@freebsd.org Fri Jun 17 09:07:28 2016 Return-Path: Delivered-To: svn-src-stable-10@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 458DAA783BF; Fri, 17 Jun 2016 09:07:28 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 154E2206D; Fri, 17 Jun 2016 09:07:28 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H97Rsv015529; Fri, 17 Jun 2016 09:07:27 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H97RF6015528; Fri, 17 Jun 2016 09:07:27 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170907.u5H97RF6015528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 09:07:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301989 - stable/10/sys/dev/sfxge X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 09:07:28 -0000 Author: arybchik Date: Fri Jun 17 09:07:27 2016 New Revision: 301989 URL: https://svnweb.freebsd.org/changeset/base/301989 Log: MFC r301607 sfxge(4): host byte order is required for IP ID in TSO descriptors Submitted by: Artem V. Andreev Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/sfxge_tx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/sfxge_tx.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_tx.c Fri Jun 17 09:06:30 2016 (r301988) +++ stable/10/sys/dev/sfxge/sfxge_tx.c Fri Jun 17 09:07:27 2016 (r301989) @@ -973,7 +973,7 @@ static void tso_start(struct sfxge_txq * tso->protocol = TSO_MBUF_PROTO(mbuf); tso->nh_off = mbuf->m_pkthdr.l2hlen; tso->tcph_off = mbuf->m_pkthdr.l3hlen; - tso->packet_id = TSO_MBUF_PACKETID(mbuf); + tso->packet_id = ntohs(TSO_MBUF_PACKETID(mbuf)); #endif #if !SFXGE_TX_PARSE_EARLY @@ -982,7 +982,7 @@ static void tso_start(struct sfxge_txq * KASSERT(tso_iph(tso)->ip_p == IPPROTO_TCP, ("TSO required on non-TCP packet")); tso->tcph_off = tso->nh_off + 4 * tso_iph(tso)->ip_hl; - tso->packet_id = tso_iph(tso)->ip_id; + tso->packet_id = ntohs(tso_iph(tso)->ip_id); } else { KASSERT(tso->protocol == htons(ETHERTYPE_IPV6), ("TSO required on non-IP packet")); From owner-svn-src-stable-10@freebsd.org Fri Jun 17 22:40:14 2016 Return-Path: Delivered-To: svn-src-stable-10@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 0618FA78915; Fri, 17 Jun 2016 22:40:14 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C2A04256E; Fri, 17 Jun 2016 22:40:13 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5HMeDl8018575; Fri, 17 Jun 2016 22:40:13 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5HMeB04018557; Fri, 17 Jun 2016 22:40:11 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201606172240.u5HMeB04018557@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Fri, 17 Jun 2016 22:40:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302001 - in stable/10: contrib/libarchive contrib/libarchive/cat contrib/libarchive/cpio contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test c... X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 22:40:14 -0000 Author: mm Date: Fri Jun 17 22:40:10 2016 New Revision: 302001 URL: https://svnweb.freebsd.org/changeset/base/302001 Log: MFC r299529,r299540,r299576,r299896: r299529,r299540: Update libarchive to 3.2.0 New features: - new bsdcat command-line utility - LZ4 compression (in src only via external utility from ports) - Warc format support - 'Raw' format writer - Zip: Support archives >4GB, entries >4GB - Zip: Support encrypting and decrypting entries - Zip: Support experimental streaming extension - Identify encrypted entries in several formats - New --clear-nochange-flags option to bsdtar tries to remove noschg and similar flags before deleting files - New --ignore-zeros option to bsdtar to handle concatenated tar archives - Use multi-threaded LZMA decompression if liblzma supports it - Expose version info for libraries used by libarchive r299576,r299896: Fix broken cpio behavior. Relnotes: yes Added: stable/10/contrib/libarchive/cat/ - copied from r299529, head/contrib/libarchive/cat/ stable/10/contrib/libarchive/cpio/test/test_extract.cpio.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/cpio/test/test_extract.cpio.lz4.uu stable/10/contrib/libarchive/cpio/test/test_extract_cpio_lz4.c - copied unchanged from r299529, head/contrib/libarchive/cpio/test/test_extract_cpio_lz4.c stable/10/contrib/libarchive/cpio/test/test_option_lz4.c - copied unchanged from r299529, head/contrib/libarchive/cpio/test/test_option_lz4.c stable/10/contrib/libarchive/cpio/test/test_option_passphrase.c - copied unchanged from r299529, head/contrib/libarchive/cpio/test/test_option_passphrase.c stable/10/contrib/libarchive/cpio/test/test_option_passphrase.zip.uu - copied unchanged from r299529, head/contrib/libarchive/cpio/test/test_option_passphrase.zip.uu stable/10/contrib/libarchive/libarchive/archive_cryptor.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_cryptor.c stable/10/contrib/libarchive/libarchive/archive_cryptor_private.h - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_cryptor_private.h stable/10/contrib/libarchive/libarchive/archive_digest.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_digest.c stable/10/contrib/libarchive/libarchive/archive_digest_private.h - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_digest_private.h stable/10/contrib/libarchive/libarchive/archive_getdate.h - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_getdate.h stable/10/contrib/libarchive/libarchive/archive_hmac.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_hmac.c stable/10/contrib/libarchive/libarchive/archive_hmac_private.h - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_hmac_private.h stable/10/contrib/libarchive/libarchive/archive_pack_dev.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_pack_dev.c stable/10/contrib/libarchive/libarchive/archive_pack_dev.h - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_pack_dev.h stable/10/contrib/libarchive/libarchive/archive_random.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_random.c stable/10/contrib/libarchive/libarchive/archive_random_private.h - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_random_private.h stable/10/contrib/libarchive/libarchive/archive_read_add_passphrase.3 - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_read_add_passphrase.3 stable/10/contrib/libarchive/libarchive/archive_read_add_passphrase.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_read_add_passphrase.c stable/10/contrib/libarchive/libarchive/archive_read_extract2.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_read_extract2.c stable/10/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_warc.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_read_support_format_warc.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_lz4.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_write_add_filter_lz4.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_filter_by_ext.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_write_set_format_filter_by_ext.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_raw.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_write_set_format_raw.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_warc.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_write_set_format_warc.c stable/10/contrib/libarchive/libarchive/archive_write_set_passphrase.3 - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_write_set_passphrase.3 stable/10/contrib/libarchive/libarchive/archive_write_set_passphrase.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_write_set_passphrase.c stable/10/contrib/libarchive/libarchive/archive_xxhash.h - copied unchanged from r299529, head/contrib/libarchive/libarchive/archive_xxhash.h stable/10/contrib/libarchive/libarchive/test/test_archive_digest.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_archive_digest.c stable/10/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c stable/10/contrib/libarchive/libarchive/test/test_archive_write_set_format_filter_by_ext.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_archive_write_set_format_filter_by_ext.c stable/10/contrib/libarchive/libarchive/test/test_archive_write_set_passphrase.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_archive_write_set_passphrase.c stable/10/contrib/libarchive/libarchive/test/test_compat_lz4.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4.c stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_1.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_1.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_2.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_2.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_3.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_3.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B4.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B4.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B4BD.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B4BD.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B4BDBX.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B4BDBX.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B5.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B5.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B5BD.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B5BD.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B6.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B6.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B6BD.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B6BD.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B7.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B7.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_lz4_B7BD.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_lz4_B7BD.tar.lz4.uu stable/10/contrib/libarchive/libarchive/test/test_compat_uudecode_large.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_uudecode_large.c stable/10/contrib/libarchive/libarchive/test/test_compat_uudecode_large.tar.Z.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_compat_uudecode_large.tar.Z.uu stable/10/contrib/libarchive/libarchive/test/test_read_filter_compress.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_filter_compress.c stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption.7z.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption.7z.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_data.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_data.c stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_header.7z.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_header.7z.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_header.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_header.c stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_partially.7z.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_partially.7z.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_partially.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_encryption_partially.c stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_malformed.7z.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_malformed.7z.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_malformed.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_malformed.c stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip_malformed2.7z.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_7zip_malformed2.7z.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_le.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_le.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_le.cpio.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_le.cpio.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_lha_bugfix_0.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_lha_bugfix_0.c stable/10/contrib/libarchive/libarchive/test/test_read_format_lha_bugfix_0.lzh.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_lha_bugfix_0.lzh.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_data.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_data.c stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_data.rar.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_data.rar.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_header.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_header.c stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_header.rar.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_header.rar.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_partially.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_partially.c stable/10/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_partially.rar.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_rar_encryption_partially.rar.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_tar_concatenated.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_tar_concatenated.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tar_concatenated.tar.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_tar_concatenated.tar.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_tar_empty_pax.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_pax.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tar_empty_pax.tar.Z.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_pax.tar.Z.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_warc.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_warc.c stable/10/contrib/libarchive/libarchive/test/test_read_format_warc.warc.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_warc.warc.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_data.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_data.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_data.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_data.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_header.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_header.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_header.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_header.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_partially.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_partially.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_partially.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_encryption_partially.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_malformed1.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_malformed1.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_msdos.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_msdos.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_msdos.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_msdos.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_nested.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_nested.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_nofiletype.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_nofiletype.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_nofiletype.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_nofiletype.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_padded1.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_padded1.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_padded2.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_padded2.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_padded3.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_padded3.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes128.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes128.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes256.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes256.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes256_large.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes256_large.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes256_stored.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes256_stored.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_zip64.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_zip64.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_zip64a.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_zip64a.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_zip64b.zip.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_format_zip_zip64b.zip.uu stable/10/contrib/libarchive/libarchive/test/test_read_too_many_filters.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_too_many_filters.c stable/10/contrib/libarchive/libarchive/test/test_read_too_many_filters.gz.uu - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_read_too_many_filters.gz.uu stable/10/contrib/libarchive/libarchive/test/test_warn_missing_hardlink_target.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_warn_missing_hardlink_target.c stable/10/contrib/libarchive/libarchive/test/test_write_filter_lz4.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_filter_lz4.c stable/10/contrib/libarchive/libarchive/test/test_write_format_raw.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_raw.c stable/10/contrib/libarchive/libarchive/test/test_write_format_raw_b64.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_raw_b64.c stable/10/contrib/libarchive/libarchive/test/test_write_format_warc.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_warc.c stable/10/contrib/libarchive/libarchive/test/test_write_format_warc_empty.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_warc_empty.c stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_compression_store.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_zip_compression_store.c stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_empty_zip64.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_zip_empty_zip64.c stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_file.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_zip_file.c stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_file_zip64.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_zip_file_zip64.c stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_large.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_zip_large.c stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c stable/10/contrib/libarchive/libarchive/test/test_write_read_format_zip.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/test/test_write_read_format_zip.c stable/10/contrib/libarchive/libarchive/xxhash.c - copied unchanged from r299529, head/contrib/libarchive/libarchive/xxhash.c stable/10/contrib/libarchive/libarchive_fe/passphrase.c - copied unchanged from r299529, head/contrib/libarchive/libarchive_fe/passphrase.c stable/10/contrib/libarchive/libarchive_fe/passphrase.h - copied unchanged from r299529, head/contrib/libarchive/libarchive_fe/passphrase.h stable/10/contrib/libarchive/tar/test/test_extract.tar.lz4.uu - copied unchanged from r299529, head/contrib/libarchive/tar/test/test_extract.tar.lz4.uu stable/10/contrib/libarchive/tar/test/test_extract_tar_lz4.c - copied unchanged from r299529, head/contrib/libarchive/tar/test/test_extract_tar_lz4.c stable/10/contrib/libarchive/tar/test/test_leading_slash.c - copied unchanged from r299529, head/contrib/libarchive/tar/test/test_leading_slash.c stable/10/contrib/libarchive/tar/test/test_leading_slash.tar.uu - copied unchanged from r299529, head/contrib/libarchive/tar/test/test_leading_slash.tar.uu stable/10/contrib/libarchive/tar/test/test_option_lz4.c - copied unchanged from r299529, head/contrib/libarchive/tar/test/test_option_lz4.c stable/10/contrib/libarchive/tar/test/test_option_passphrase.c - copied unchanged from r299529, head/contrib/libarchive/tar/test/test_option_passphrase.c stable/10/contrib/libarchive/tar/test/test_option_passphrase.zip.uu - copied unchanged from r299529, head/contrib/libarchive/tar/test/test_option_passphrase.zip.uu stable/10/usr.bin/bsdcat/ - copied from r299529, head/usr.bin/bsdcat/ Deleted: stable/10/contrib/libarchive/libarchive/archive_crypto.c stable/10/contrib/libarchive/libarchive/archive_crypto_private.h stable/10/contrib/libarchive/libarchive/test/test_archive_crypto.c stable/10/contrib/libarchive/libarchive/test/test_write_format_zip_no_compression.c stable/10/contrib/libarchive/libarchive/test/test_write_zip_set_compression_store.c Modified: stable/10/contrib/libarchive/COPYING stable/10/contrib/libarchive/FREEBSD-Xlist stable/10/contrib/libarchive/FREEBSD-upgrade stable/10/contrib/libarchive/NEWS stable/10/contrib/libarchive/README stable/10/contrib/libarchive/cpio/bsdcpio.1 stable/10/contrib/libarchive/cpio/cmdline.c stable/10/contrib/libarchive/cpio/cpio.c stable/10/contrib/libarchive/cpio/cpio.h stable/10/contrib/libarchive/cpio/cpio_platform.h stable/10/contrib/libarchive/cpio/test/main.c stable/10/contrib/libarchive/cpio/test/test.h stable/10/contrib/libarchive/cpio/test/test_basic.c stable/10/contrib/libarchive/cpio/test/test_extract_cpio_lzo.c stable/10/contrib/libarchive/cpio/test/test_option_c.c stable/10/contrib/libarchive/cpio/test/test_option_version.c stable/10/contrib/libarchive/libarchive/archive.h stable/10/contrib/libarchive/libarchive/archive_endian.h stable/10/contrib/libarchive/libarchive/archive_entry.3 stable/10/contrib/libarchive/libarchive/archive_entry.c stable/10/contrib/libarchive/libarchive/archive_entry.h stable/10/contrib/libarchive/libarchive/archive_entry_acl.3 stable/10/contrib/libarchive/libarchive/archive_entry_copy_stat.c stable/10/contrib/libarchive/libarchive/archive_entry_paths.3 stable/10/contrib/libarchive/libarchive/archive_entry_perms.3 stable/10/contrib/libarchive/libarchive/archive_entry_private.h stable/10/contrib/libarchive/libarchive/archive_entry_sparse.c stable/10/contrib/libarchive/libarchive/archive_entry_stat.3 stable/10/contrib/libarchive/libarchive/archive_entry_time.3 stable/10/contrib/libarchive/libarchive/archive_entry_xattr.c stable/10/contrib/libarchive/libarchive/archive_getdate.c stable/10/contrib/libarchive/libarchive/archive_match.c stable/10/contrib/libarchive/libarchive/archive_options.c stable/10/contrib/libarchive/libarchive/archive_pathmatch.c stable/10/contrib/libarchive/libarchive/archive_platform.h stable/10/contrib/libarchive/libarchive/archive_private.h stable/10/contrib/libarchive/libarchive/archive_read.3 stable/10/contrib/libarchive/libarchive/archive_read.c stable/10/contrib/libarchive/libarchive/archive_read_append_filter.c stable/10/contrib/libarchive/libarchive/archive_read_data.3 stable/10/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c stable/10/contrib/libarchive/libarchive/archive_read_disk_posix.c stable/10/contrib/libarchive/libarchive/archive_read_disk_private.h stable/10/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c stable/10/contrib/libarchive/libarchive/archive_read_extract.c stable/10/contrib/libarchive/libarchive/archive_read_filter.3 stable/10/contrib/libarchive/libarchive/archive_read_open.3 stable/10/contrib/libarchive/libarchive/archive_read_open_fd.c stable/10/contrib/libarchive/libarchive/archive_read_open_file.c stable/10/contrib/libarchive/libarchive/archive_read_open_filename.c stable/10/contrib/libarchive/libarchive/archive_read_open_memory.c stable/10/contrib/libarchive/libarchive/archive_read_private.h stable/10/contrib/libarchive/libarchive/archive_read_set_options.3 stable/10/contrib/libarchive/libarchive/archive_read_set_options.c stable/10/contrib/libarchive/libarchive/archive_read_support_filter_all.c stable/10/contrib/libarchive/libarchive/archive_read_support_filter_compress.c stable/10/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c stable/10/contrib/libarchive/libarchive/archive_read_support_filter_uu.c stable/10/contrib/libarchive/libarchive/archive_read_support_filter_xz.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_all.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_ar.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_cab.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_cpio.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_empty.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_lha.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_rar.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_raw.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_tar.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_xar.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_zip.c stable/10/contrib/libarchive/libarchive/archive_string.c stable/10/contrib/libarchive/libarchive/archive_util.c stable/10/contrib/libarchive/libarchive/archive_virtual.c stable/10/contrib/libarchive/libarchive/archive_write.3 stable/10/contrib/libarchive/libarchive/archive_write.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_by_name.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_bzip2.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_grzip.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_gzip.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_lrzip.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_lzop.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_program.c stable/10/contrib/libarchive/libarchive/archive_write_add_filter_xz.c stable/10/contrib/libarchive/libarchive/archive_write_data.3 stable/10/contrib/libarchive/libarchive/archive_write_disk.3 stable/10/contrib/libarchive/libarchive/archive_write_disk_acl.c stable/10/contrib/libarchive/libarchive/archive_write_disk_posix.c stable/10/contrib/libarchive/libarchive/archive_write_disk_set_standard_lookup.c stable/10/contrib/libarchive/libarchive/archive_write_filter.3 stable/10/contrib/libarchive/libarchive/archive_write_finish_entry.3 stable/10/contrib/libarchive/libarchive/archive_write_format.3 stable/10/contrib/libarchive/libarchive/archive_write_open.3 stable/10/contrib/libarchive/libarchive/archive_write_open_filename.c stable/10/contrib/libarchive/libarchive/archive_write_private.h stable/10/contrib/libarchive/libarchive/archive_write_set_format.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_7zip.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_by_name.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_mtree.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_pax.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_shar.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_xar.c stable/10/contrib/libarchive/libarchive/archive_write_set_format_zip.c stable/10/contrib/libarchive/libarchive/archive_write_set_options.3 stable/10/contrib/libarchive/libarchive/libarchive-formats.5 stable/10/contrib/libarchive/libarchive/libarchive.3 stable/10/contrib/libarchive/libarchive/libarchive_internals.3 stable/10/contrib/libarchive/libarchive/tar.5 stable/10/contrib/libarchive/libarchive/test/README stable/10/contrib/libarchive/libarchive/test/main.c stable/10/contrib/libarchive/libarchive/test/read_open_memory.c stable/10/contrib/libarchive/libarchive/test/test.h stable/10/contrib/libarchive/libarchive/test/test_archive_getdate.c stable/10/contrib/libarchive/libarchive/test/test_archive_match_time.c stable/10/contrib/libarchive/libarchive/test/test_archive_pathmatch.c stable/10/contrib/libarchive/libarchive/test/test_archive_string.c stable/10/contrib/libarchive/libarchive/test/test_archive_write_add_filter_by_name.c stable/10/contrib/libarchive/libarchive/test/test_archive_write_set_format_by_name.c stable/10/contrib/libarchive/libarchive/test/test_compat_mac.c stable/10/contrib/libarchive/libarchive/test/test_compat_pax_libarchive_2x.c stable/10/contrib/libarchive/libarchive/test/test_compat_zip.c stable/10/contrib/libarchive/libarchive/test/test_fuzz.c stable/10/contrib/libarchive/libarchive/test/test_gnutar_filename_encoding.c stable/10/contrib/libarchive/libarchive/test/test_pax_filename_encoding.c stable/10/contrib/libarchive/libarchive/test/test_read_data_large.c stable/10/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c stable/10/contrib/libarchive/libarchive/test/test_read_format_7zip.c stable/10/contrib/libarchive/libarchive/test/test_read_format_ar.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cab.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cab_filename.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_Z.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_be.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_bz2.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_gz.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_lzip.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_lzma.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_bin_xz.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_filename.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_odc.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c stable/10/contrib/libarchive/libarchive/test/test_read_format_cpio_svr4c_Z.c stable/10/contrib/libarchive/libarchive/test/test_read_format_empty.c stable/10/contrib/libarchive/libarchive/test/test_read_format_gtar_filename.c stable/10/contrib/libarchive/libarchive/test/test_read_format_gtar_gz.c stable/10/contrib/libarchive/libarchive/test/test_read_format_gtar_lzma.c stable/10/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse.c stable/10/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse_skip_entry.c stable/10/contrib/libarchive/libarchive/test/test_read_format_iso_Z.c stable/10/contrib/libarchive/libarchive/test/test_read_format_iso_multi_extent.c stable/10/contrib/libarchive/libarchive/test/test_read_format_iso_xorriso.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isojoliet_bz2.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isojoliet_long.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isojoliet_rr.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isojoliet_versioned.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isorr_ce.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isorr_new_bz2.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isorr_rr_moved.c stable/10/contrib/libarchive/libarchive/test/test_read_format_isozisofs_bz2.c stable/10/contrib/libarchive/libarchive/test/test_read_format_lha.c stable/10/contrib/libarchive/libarchive/test/test_read_format_lha_filename.c stable/10/contrib/libarchive/libarchive/test/test_read_format_mtree.c stable/10/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu stable/10/contrib/libarchive/libarchive/test/test_read_format_pax_bz2.c stable/10/contrib/libarchive/libarchive/test/test_read_format_rar.c stable/10/contrib/libarchive/libarchive/test/test_read_format_raw.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tar.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tar_empty_filename.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tar_filename.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tbz.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tgz.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tlz.c stable/10/contrib/libarchive/libarchive/test/test_read_format_txz.c stable/10/contrib/libarchive/libarchive/test/test_read_format_tz.c stable/10/contrib/libarchive/libarchive/test/test_read_format_ustar_filename.c stable/10/contrib/libarchive/libarchive/test/test_read_format_xar.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c stable/10/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c stable/10/contrib/libarchive/libarchive/test/test_read_truncated.c stable/10/contrib/libarchive/libarchive/test/test_sparse_basic.c stable/10/contrib/libarchive/libarchive/test/test_ustar_filename_encoding.c stable/10/contrib/libarchive/libarchive/test/test_write_disk_appledouble.c stable/10/contrib/libarchive/libarchive/test/test_write_disk_hfs_compression.c stable/10/contrib/libarchive/libarchive/test/test_write_disk_mac_metadata.c stable/10/contrib/libarchive/libarchive/test/test_write_disk_no_hfs_compression.c stable/10/contrib/libarchive/libarchive/test/test_write_disk_perms.c stable/10/contrib/libarchive/libarchive/test/test_write_disk_secure.c stable/10/contrib/libarchive/libarchive/test/test_write_filter_lzop.c stable/10/contrib/libarchive/libarchive/test/test_write_filter_program.c stable/10/contrib/libarchive/libarchive/test/test_write_format_ar.c stable/10/contrib/libarchive/libarchive/test/test_write_format_cpio_newc.c stable/10/contrib/libarchive/libarchive/test/test_write_format_gnutar.c stable/10/contrib/libarchive/libarchive/test/test_write_format_iso9660.c stable/10/contrib/libarchive/libarchive/test/test_write_format_iso9660_boot.c stable/10/contrib/libarchive/libarchive/test/test_write_format_mtree.c stable/10/contrib/libarchive/libarchive/test/test_write_format_pax.c stable/10/contrib/libarchive/libarchive/test/test_write_format_tar.c stable/10/contrib/libarchive/libarchive/test/test_write_format_tar_sparse.c stable/10/contrib/libarchive/libarchive/test/test_write_format_zip.c stable/10/contrib/libarchive/libarchive/test/test_zip_filename_encoding.c stable/10/contrib/libarchive/libarchive_fe/err.c stable/10/contrib/libarchive/libarchive_fe/err.h stable/10/contrib/libarchive/tar/bsdtar.1 stable/10/contrib/libarchive/tar/bsdtar.c stable/10/contrib/libarchive/tar/bsdtar.h stable/10/contrib/libarchive/tar/bsdtar_platform.h stable/10/contrib/libarchive/tar/cmdline.c stable/10/contrib/libarchive/tar/creation_set.c stable/10/contrib/libarchive/tar/read.c stable/10/contrib/libarchive/tar/subst.c stable/10/contrib/libarchive/tar/test/main.c stable/10/contrib/libarchive/tar/test/test.h stable/10/contrib/libarchive/tar/test/test_option_X_upper.c stable/10/contrib/libarchive/tar/test/test_option_b.c stable/10/contrib/libarchive/tar/test/test_option_s.c stable/10/contrib/libarchive/tar/test/test_version.c stable/10/contrib/libarchive/tar/util.c stable/10/contrib/libarchive/tar/write.c stable/10/etc/mtree/BSD.tests.dist stable/10/lib/libarchive/Makefile stable/10/lib/libarchive/config_freebsd.h stable/10/lib/libarchive/tests/Makefile stable/10/usr.bin/Makefile stable/10/usr.bin/ar/Makefile stable/10/usr.bin/bsdcat/Makefile stable/10/usr.bin/bsdcat/tests/Makefile stable/10/usr.bin/cpio/Makefile stable/10/usr.bin/cpio/tests/Makefile stable/10/usr.bin/tar/Makefile stable/10/usr.bin/tar/tests/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/libarchive/COPYING ============================================================================== --- stable/10/contrib/libarchive/COPYING Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/COPYING Fri Jun 17 22:40:10 2016 (r302001) @@ -17,12 +17,11 @@ the actual statements in the files are c files for details: libarchive/archive_entry.c libarchive/archive_read_support_filter_compress.c - libarchive/archive_write_set_filter_compress.c + libarchive/archive_write_add_filter_compress.c libarchive/mtree.5 - tar/matching.c * The following source files are in the public domain: - tar/getdate.c + libarchive/archive_getdate.c * The build files---including Makefiles, configure scripts, and auxiliary scripts used as part of the compile process---have Modified: stable/10/contrib/libarchive/FREEBSD-Xlist ============================================================================== --- stable/10/contrib/libarchive/FREEBSD-Xlist Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/FREEBSD-Xlist Fri Jun 17 22:40:10 2016 (r302001) @@ -1,11 +1,15 @@ .git .gitattributes .gitignore +.travis.yml CMakeLists.txt +CONTRIBUTING.md CTestConfig.cmake INSTALL Makefile.am build +cat/CMakeLists.txt +cat/test/CMakeLists.txt configure.ac contrib cpio/CMakeLists.txt Modified: stable/10/contrib/libarchive/FREEBSD-upgrade ============================================================================== --- stable/10/contrib/libarchive/FREEBSD-upgrade Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/FREEBSD-upgrade Fri Jun 17 22:40:10 2016 (r302001) @@ -4,13 +4,14 @@ libarchive The source code is pulled with git: - git clone -b release git://github.com/libarchive/libarchive.git + git clone git://github.com/libarchive/libarchive.git For the contrib directory files and directories were pruned by: sh -c 'for F in `cat FREEBSD-Xlist | grep -v FreeBSD`; do rm -rf ./$F ; done' -You may check if there are any new files that we don't need. +You may check if there are any new files that we don't need and add them to +FREEBSD-Xlist. The instructions for importing new release and merging to HEAD can be found at FreeBSD wiki: Modified: stable/10/contrib/libarchive/NEWS ============================================================================== --- stable/10/contrib/libarchive/NEWS Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/NEWS Fri Jun 17 22:40:10 2016 (r302001) @@ -1,3 +1,35 @@ +Apr 09, 2016: libarchive 3.1.901a released + Another test release in preparation for 3.2.0 + +Feb 13, 2016: libarchive 3.1.900a released + This is a test release in preparation for 3.2.0 + +Oct 21, 2015: Preliminary port to OSF + +Apr 11, 2015: libarchive's issue tracker is now hosted at GitHub. + https://github.com/libarchive/libarchive/issues + +Early 2015: Many fixes to crash and overflow bugs thanks to Hanno Boeck + +Oct 13, 2014: Zip encryption and decryption support + +Aug 13, 2014: Add support for lz4 compression. + +Jun 10, 2014: Add warc format support + +May 3, 2014: Add experimental Zip streaming extension + +Apr 6, 2014: Add bsdcat command-line tool + +Jan 12, 2014: Add Zip64 support + +Dec 1, 2013: Rewrite Zip write logic + +Jul 1, 2013: Add ability to detect encrypted entries for many formats + (This does not add the ability to *decrypt* those entries, however) + +Feb 23, 2013: "raw" write support added + Feb 09, 2013: libarchive 3.1.2 released Jan 28, 2013: libarchive's new website moved to http://www.libarchive.org. Modified: stable/10/contrib/libarchive/README ============================================================================== --- stable/10/contrib/libarchive/README Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/README Fri Jun 17 22:40:10 2016 (r302001) @@ -5,7 +5,7 @@ Questions? Issues? libarchive development, including documentation, and links to the libarchive mailing lists. * To report an issue, use the issue tracker at - http://code.google.com/p/libarchive/issues/list + https://github.com/libarchive/libarchive/issues * To submit an enhancement to libarchive, please submit a pull request via GitHub. https://github.com/libarchive/libarchive/pulls @@ -13,9 +13,11 @@ Questions? Issues? This distribution bundle includes the following components: * libarchive: a library for reading and writing streaming archives * tar: the 'bsdtar' program is a full-featured 'tar' - replacement built on libarchive + implementation built on libarchive * cpio: the 'bsdcpio' program is a different interface to essentially the same functionality + * cat: the 'bsdcat' program is a simple replacement tool for + zcat, bzcat, xzcat, and such * examples: Some small example programs that you may find useful. * examples/minitar: a compact sample demonstrating use of libarchive. * contrib: Various items sent to me by third parties; @@ -39,6 +41,7 @@ The following files in the top-level dir Guide to Documentation installed by this system: * bsdtar.1 explains the use of the bsdtar program * bsdcpio.1 explains the use of the bsdcpio program + * bsdcat.1 explains the use of the bsdcat program * libarchive.3 gives an overview of the library as a whole * archive_read.3, archive_write.3, archive_write_disk.3, and archive_read_disk.3 provide detailed calling sequences for the read @@ -84,6 +87,8 @@ The library also detects and handles any * bzip2 compression * compress/LZW compression * lzma, lzip, and xz compression + * lz4 compression + * lzop compression The library can create archives in any of the following formats: * POSIX ustar @@ -91,6 +96,7 @@ The library can create archives in any o * "restricted" pax format, which will create ustar archives except for entries that require pax extensions (for long filenames, ACLs, etc). * Old GNU tar format + * Old V7 tar format * POSIX octet-oriented cpio * SVR4 "newc" cpio * shar archives @@ -107,6 +113,8 @@ When creating archives, the result can b * bzip2 compression * compress/LZW compression * lzma, lzip, and xz compression + * lz4 compression + * lzop compression Notes about the library architecture: @@ -123,12 +131,12 @@ Notes about the library architecture: * I've attempted to minimize static link pollution. If you don't explicitly invoke a particular feature (such as support for a - particular compression or format), it won't get pulled in. - In particular, if you don't explicitly enable a particular - compression or decompression support, you won't need to link - against the corresponding compression or decompression libraries. - This also reduces the size of statically-linked binaries in - environments where that matters. + particular compression or format), it won't get pulled in to + statically-linked programs. In particular, if you don't explicitly + enable a particular compression or decompression support, you won't + need to link against the corresponding compression or decompression + libraries. This also reduces the size of statically-linked + binaries in environments where that matters. * On read, the library accepts whatever blocks you hand it. Your read callback is free to pass the library a byte at a time Modified: stable/10/contrib/libarchive/cpio/bsdcpio.1 ============================================================================== --- stable/10/contrib/libarchive/cpio/bsdcpio.1 Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/bsdcpio.1 Fri Jun 17 22:40:10 2016 (r302001) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 7, 2012 +.Dd September 16, 2014 .Dt CPIO 1 .Os .Sh NAME @@ -32,17 +32,17 @@ .Nd copy files to and from archives .Sh SYNOPSIS .Nm -.Brq Fl i +.Fl i .Op Ar options .Op Ar pattern ... .Op Ar < archive .Nm -.Brq Fl o +.Fl o .Op Ar options .Ar < name-list .Op Ar > archive .Nm -.Brq Fl p +.Fl p .Op Ar options .Ar dest-dir .Ar < name-list @@ -182,6 +182,11 @@ instead of copying. Compress the resulting archive with .Xr lrzip 1 . In input mode, this option is ignored. +.It Fl Fl lz4 +(o mode only) +Compress the archive with lz4-compatible compression before writing it. +In input mode, this option is ignored; lz4 compression is recognized +automatically on input. .It Fl Fl lzma (o mode only) Compress the file with lzma-compatible compression before writing it. @@ -192,6 +197,15 @@ automatically on input. Compress the resulting archive with .Xr lzop 1 . In input mode, this option is ignored. +.It Fl Fl passphrase Ar passphrase +The +.Pa passphrase +is used to extract or create an encrypted archive. +Currently, zip is only a format that +.Nm +can handle encrypted archives. +You shouldn't use this option unless you realize how insecure +use of this option is. .It Fl m , Fl Fl preserve-modification-time (i and p modes) Set file modification time on created files to match Modified: stable/10/contrib/libarchive/cpio/cmdline.c ============================================================================== --- stable/10/contrib/libarchive/cpio/cmdline.c Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/cmdline.c Fri Jun 17 22:40:10 2016 (r302001) @@ -73,6 +73,7 @@ static const struct option { { "link", 0, 'l' }, { "list", 0, 't' }, { "lrzip", 0, OPTION_LRZIP }, + { "lz4", 0, OPTION_LZ4 }, { "lzma", 0, OPTION_LZMA }, { "lzop", 0, OPTION_LZOP }, { "make-directories", 0, 'd' }, @@ -80,6 +81,7 @@ static const struct option { { "null", 0, '0' }, { "numeric-uid-gid", 0, 'n' }, { "owner", 1, 'R' }, + { "passphrase", 1, OPTION_PASSPHRASE }, { "pass-through", 0, 'p' }, { "preserve-modification-time", 0, 'm' }, { "preserve-owner", 0, OPTION_PRESERVE_OWNER }, Modified: stable/10/contrib/libarchive/cpio/cpio.c ============================================================================== --- stable/10/contrib/libarchive/cpio/cpio.c Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/cpio.c Fri Jun 17 22:40:10 2016 (r302001) @@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$"); #include "cpio.h" #include "err.h" #include "line_reader.h" +#include "passphrase.h" /* Fixed size of uname/gname caches. */ #define name_cache_size 101 @@ -123,6 +124,8 @@ static int restore_time(struct cpio *, s const char *, int fd); static void usage(void); static void version(void); +static const char * passphrase_callback(struct archive *, void *); +static void passphrase_free(char *); int main(int argc, char *argv[]) @@ -149,20 +152,9 @@ main(int argc, char *argv[]) } #endif - /* Need lafe_progname before calling lafe_warnc. */ - if (*argv == NULL) - lafe_progname = "bsdcpio"; - else { -#if defined(_WIN32) && !defined(__CYGWIN__) - lafe_progname = strrchr(*argv, '\\'); - if (strrchr(*argv, '/') > lafe_progname) -#endif - lafe_progname = strrchr(*argv, '/'); - if (lafe_progname != NULL) - lafe_progname++; - else - lafe_progname = *argv; - } + /* Set lafe_progname before calling lafe_warnc. */ + lafe_setprogname(*argv, "bsdcpio"); + #if HAVE_SETLOCALE if (setlocale(LC_ALL, "") == NULL) lafe_warnc(0, "Failed to set default locale"); @@ -274,6 +266,7 @@ main(int argc, char *argv[]) cpio->option_link = 1; break; case OPTION_LRZIP: + case OPTION_LZ4: case OPTION_LZMA: /* GNU tar, others */ case OPTION_LZOP: /* GNU tar, others */ cpio->compress = opt; @@ -304,6 +297,9 @@ main(int argc, char *argv[]) cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT; cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS; break; + case OPTION_PASSPHRASE: + cpio->passphrase = cpio->argument; + break; case OPTION_PRESERVE_OWNER: cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER; break; @@ -432,6 +428,7 @@ main(int argc, char *argv[]) free_cache(cpio->gname_cache); free_cache(cpio->uname_cache); free(cpio->destdir); + passphrase_free(cpio->ppbuff); return (cpio->return_value); } @@ -440,7 +437,7 @@ usage(void) { const char *p; - p = lafe_progname; + p = lafe_getprogname(); fprintf(stderr, "Brief Usage:\n"); fprintf(stderr, " List: %s -it < archive\n", p); @@ -478,7 +475,7 @@ long_help(void) const char *prog; const char *p; - prog = lafe_progname; + prog = lafe_getprogname(); fflush(stderr); @@ -503,7 +500,7 @@ version(void) { fprintf(stdout,"bsdcpio %s -- %s\n", BSDCPIO_VERSION_STRING, - archive_version_string()); + archive_version_details()); exit(0); } @@ -540,6 +537,9 @@ mode_out(struct cpio *cpio) case OPTION_LRZIP: r = archive_write_add_filter_lrzip(cpio->archive); break; + case OPTION_LZ4: + r = archive_write_add_filter_lz4(cpio->archive); + break; case OPTION_LZMA: r = archive_write_add_filter_lzma(cpio->archive); break; @@ -581,6 +581,14 @@ mode_out(struct cpio *cpio) cpio->linkresolver = archive_entry_linkresolver_new(); archive_entry_linkresolver_set_strategy(cpio->linkresolver, archive_format(cpio->archive)); + if (cpio->passphrase != NULL) + r = archive_write_set_passphrase(cpio->archive, + cpio->passphrase); + else + r = archive_write_set_passphrase_callback(cpio->archive, cpio, + &passphrase_callback); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(cpio->archive)); /* * The main loop: Copy each file into the output archive. @@ -947,6 +955,13 @@ mode_in(struct cpio *cpio) lafe_errc(1, 0, "Couldn't allocate archive object"); archive_read_support_filter_all(a); archive_read_support_format_all(a); + if (cpio->passphrase != NULL) + r = archive_read_add_passphrase(a, cpio->passphrase); + else + r = archive_read_set_passphrase_callback(a, cpio, + &passphrase_callback); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(a)); if (archive_read_open_filename(a, cpio->filename, cpio->bytes_per_block)) @@ -1050,6 +1065,13 @@ mode_list(struct cpio *cpio) lafe_errc(1, 0, "Couldn't allocate archive object"); archive_read_support_filter_all(a); archive_read_support_format_all(a); + if (cpio->passphrase != NULL) + r = archive_read_add_passphrase(a, cpio->passphrase); + else + r = archive_read_set_passphrase_callback(a, cpio, + &passphrase_callback); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(a)); if (archive_read_open_filename(a, cpio->filename, cpio->bytes_per_block)) @@ -1239,8 +1261,10 @@ cpio_rename(const char *name) if (t == NULL) return (name); to = fopen("CONOUT$", "w"); - if (to == NULL) + if (to == NULL) { + fclose(t); return (name); + } fprintf(to, "%s (Enter/./(new name))? ", name); fclose(to); #else @@ -1420,3 +1444,28 @@ cpio_i64toa(int64_t n0) *--p = '-'; return p; } + +#define PPBUFF_SIZE 1024 +static const char * +passphrase_callback(struct archive *a, void *_client_data) +{ + struct cpio *cpio = (struct cpio *)_client_data; + (void)a; /* UNUSED */ + + if (cpio->ppbuff == NULL) { + cpio->ppbuff = malloc(PPBUFF_SIZE); + if (cpio->ppbuff == NULL) + lafe_errc(1, errno, "Out of memory"); + } + return lafe_readpassphrase("Enter passphrase:", + cpio->ppbuff, PPBUFF_SIZE); +} + +static void +passphrase_free(char *ppbuff) +{ + if (ppbuff != NULL) { + memset(ppbuff, 0, PPBUFF_SIZE); + free(ppbuff); + } +} Modified: stable/10/contrib/libarchive/cpio/cpio.h ============================================================================== --- stable/10/contrib/libarchive/cpio/cpio.h Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/cpio.h Fri Jun 17 22:40:10 2016 (r302001) @@ -71,6 +71,7 @@ struct cpio { int gid_override; char *gname_override; int day_first; /* true if locale prefers day/mon */ + const char *passphrase; /* If >= 0, then close this when done. */ int fd; @@ -90,6 +91,7 @@ struct cpio { struct archive *matching; char *buff; size_t buff_size; + char *ppbuff; }; const char *owner_parse(const char *, int *, int *); @@ -101,8 +103,10 @@ enum { OPTION_GRZIP, OPTION_INSECURE, OPTION_LRZIP, + OPTION_LZ4, OPTION_LZMA, OPTION_LZOP, + OPTION_PASSPHRASE, OPTION_NO_PRESERVE_OWNER, OPTION_PRESERVE_OWNER, OPTION_QUIET, Modified: stable/10/contrib/libarchive/cpio/cpio_platform.h ============================================================================== --- stable/10/contrib/libarchive/cpio/cpio_platform.h Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/cpio_platform.h Fri Jun 17 22:40:10 2016 (r302001) @@ -42,6 +42,10 @@ #include "config.h" #endif +#if defined(_WIN32) && !defined(__CYGWIN__) +#include "cpio_windows.h" +#endif + /* Get a real definition for __FBSDID if we can */ #if HAVE_SYS_CDEFS_H #include @@ -70,8 +74,4 @@ #define __LA_DEAD #endif -#if defined(_WIN32) && !defined(__CYGWIN__) -#include "cpio_windows.h" -#endif - #endif /* !CPIO_PLATFORM_H_INCLUDED */ Modified: stable/10/contrib/libarchive/cpio/test/main.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/main.c Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/test/main.c Fri Jun 17 22:40:10 2016 (r302001) @@ -130,6 +130,16 @@ __FBSDID("$FreeBSD$"); # include #endif +/* Path to working directory for current test */ +const char *testworkdir; +#ifdef PROGRAM +/* Pathname of exe to be tested. */ +const char *testprogfile; +/* Name of exe to use in printf-formatted command strings. */ +/* On Windows, this includes leading/trailing quotes. */ +const char *testprog; +#endif + #if defined(_WIN32) && !defined(__CYGWIN__) static void *GetFunctionKernel32(const char *); static int my_CreateSymbolicLinkA(const char *, const char *, int); @@ -194,7 +204,7 @@ my_GetFileInformationByName(const char * } #endif -#if defined(HAVE__CrtSetReportMode) +#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__) static void invalid_parameter_handler(const wchar_t * expression, const wchar_t * function, const wchar_t * file, @@ -565,10 +575,10 @@ static void strdump(const char *e, const while (*p != '\0') { unsigned int c = 0xff & *p++; switch (c) { - case '\a': printf("\a"); break; - case '\b': printf("\b"); break; - case '\n': printf("\n"); break; - case '\r': printf("\r"); break; + case '\a': logprintf("\\a"); break; + case '\b': logprintf("\\b"); break; + case '\n': logprintf("\\n"); break; + case '\r': logprintf("\\r"); break; default: if (c >= 32 && c < 127) logprintf("%c", c); @@ -771,6 +781,34 @@ assertion_equal_mem(const char *file, in return (0); } +/* Verify that a block of memory is filled with the specified byte. */ +int +assertion_memory_filled_with(const char *file, int line, + const void *_v1, const char *vd, + size_t l, const char *ld, + char b, const char *bd, void *extra) +{ + const char *v1 = (const char *)_v1; + size_t c = 0; + size_t i; + (void)ld; /* UNUSED */ + + assertion_count(file, line); + + for (i = 0; i < l; ++i) { + if (v1[i] == b) { + ++c; + } + } + if (c == l) + return (1); + + failure_start(file, line, "%s (size %d) not filled with %s", vd, (int)l, bd); + logprintf(" Only %d bytes were correct\n", (int)c); + failure_finish(extra); + return (0); +} + /* Verify that the named file exists and is empty. */ int assertion_empty_file(const char *filename, int line, const char *f1) @@ -1036,6 +1074,7 @@ assertion_file_contains_lines_any_order( if (expected == NULL) { failure_start(pathname, line, "Can't allocate memory"); failure_finish(NULL); + free(expected); return (0); } for (i = 0; lines[i] != NULL; ++i) { @@ -1060,7 +1099,8 @@ assertion_file_contains_lines_any_order( free(expected); return (0); } - for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) { + for (j = 0, p = buff; p < buff + buff_size; + p += 1 + strlen(p)) { if (*p != '\0') { actual[j] = p; ++j; @@ -1912,6 +1952,18 @@ canGzip(void) * Can this platform run the lrzip program? */ int +canRunCommand(const char *cmd) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("%s %s", cmd, redirectArgs) == 0) + value = 1; + } + return (value); +} + +int canLrzip(void) { static int tested = 0, value = 0; @@ -1924,6 +1976,21 @@ canLrzip(void) } /* + * Can this platform run the lz4 program? + */ +int +canLz4(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("lz4 -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + +/* * Can this platform run the lzip program? */ int @@ -2135,8 +2202,31 @@ slurpfile(size_t * sizep, const char *fm return (p); } +/* + * Slurp a file into memory for ease of comparison and testing. + * Returns size of file in 'sizep' if non-NULL, null-terminates + * data in memory for ease of use. + */ +void +dumpfile(const char *filename, void *data, size_t len) +{ + ssize_t bytes_written; + FILE *f; + + f = fopen(filename, "wb"); + if (f == NULL) { + logprintf("Can't open file %s for writing\n", filename); + return; + } + bytes_written = fwrite(data, 1, len, f); + if (bytes_written < (ssize_t)len) + logprintf("Can't write file %s\n", filename); + fclose(f); +} + /* Read a uuencoded file from the reference directory, decode, and * write the result into the current directory. */ +#define VALID_UUDECODE(c) (c >= 32 && c <= 96) #define UUDECODE(c) (((c) - 0x20) & 0x3f) void extract_reference_file(const char *name) @@ -2160,7 +2250,6 @@ extract_reference_file(const char *name) break; } /* Now, decode the rest and write it. */ - /* Not a lot of error checking here; the input better be right. */ out = fopen(name, "wb"); while (fgets(buff, sizeof(buff), in) != NULL) { char *p = buff; @@ -2174,17 +2263,21 @@ extract_reference_file(const char *name) int n = 0; /* Write out 1-3 bytes from that. */ if (bytes > 0) { + assert(VALID_UUDECODE(p[0])); + assert(VALID_UUDECODE(p[1])); n = UUDECODE(*p++) << 18; n |= UUDECODE(*p++) << 12; fputc(n >> 16, out); --bytes; } if (bytes > 0) { + assert(VALID_UUDECODE(p[0])); n |= UUDECODE(*p++) << 6; fputc((n >> 8) & 0xFF, out); --bytes; } if (bytes > 0) { + assert(VALID_UUDECODE(p[0])); n |= UUDECODE(*p++); fputc(n & 0xFF, out); --bytes; @@ -2195,6 +2288,32 @@ extract_reference_file(const char *name) fclose(in); } +void +copy_reference_file(const char *name) +{ + char buff[1024]; + FILE *in, *out; + size_t rbytes; + + sprintf(buff, "%s/%s", refdir, name); + in = fopen(buff, "rb"); + failure("Couldn't open reference file %s", buff); + assert(in != NULL); + if (in == NULL) + return; + /* Now, decode the rest and write it. */ + /* Not a lot of error checking here; the input better be right. */ + out = fopen(name, "wb"); + while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) { + if (fwrite(buff, 1, rbytes, out) != rbytes) { + logprintf("Error: fwrite\n"); + break; + } + } + fclose(out); + fclose(in); +} + int is_LargeInode(const char *file) { @@ -2216,6 +2335,14 @@ is_LargeInode(const char *file) return (ino > 0xffffffff); #endif } + +void +extract_reference_files(const char **names) +{ + while (names && *names) + extract_reference_file(*names++); +} + /* * * TEST management @@ -2245,7 +2372,7 @@ struct test_list_t tests[] = { * Summarize repeated failures in the just-completed test. */ static void -test_summarize(int failed) +test_summarize(int failed, int skips_num) { unsigned int i; @@ -2255,7 +2382,7 @@ test_summarize(int failed) fflush(stdout); break; case VERBOSITY_PASSFAIL: - printf(failed ? "FAIL\n" : "ok\n"); + printf(failed ? "FAIL\n" : skips_num ? "ok (S)\n" : "ok\n"); break; } @@ -2280,13 +2407,14 @@ test_run(int i, const char *tmpdir) char workdir[1024]; char logfilename[64]; int failures_before = failures; + int skips_before = skips; int oldumask; switch (verbosity) { case VERBOSITY_SUMMARY_ONLY: /* No per-test reports at all */ break; case VERBOSITY_PASSFAIL: /* rest of line will include ok/FAIL marker */ - printf("%3d: %-50s", i, tests[i].name); + printf("%3d: %-64s", i, tests[i].name); fflush(stdout); break; default: /* Title of test, details will follow */ @@ -2336,7 +2464,7 @@ test_run(int i, const char *tmpdir) } /* Report per-test summaries. */ tests[i].failures = failures - failures_before; - test_summarize(tests[i].failures); + test_summarize(tests[i].failures, skips - skips_before); /* Close the per-test log file. */ fclose(logfile); logfile = NULL; @@ -2479,6 +2607,7 @@ get_refdir(const char *d) failure: printf("Unable to locate known reference file %s\n", KNOWNREF); printf(" Checked following directories:\n%s\n", tried); + printf("Use -r option to specify full path to reference directory\n"); #if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG) DebugBreak(); #endif @@ -2515,7 +2644,7 @@ main(int argc, char **argv) while (pwd[strlen(pwd) - 1] == '\n') pwd[strlen(pwd) - 1] = '\0'; -#if defined(HAVE__CrtSetReportMode) +#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__) /* To stop to run the default invalid parameter handler. */ _set_invalid_parameter_handler(invalid_parameter_handler); /* Disable annoying assertion message box. */ @@ -2562,7 +2691,7 @@ main(int argc, char **argv) exit(1); } memmove(testprogdir + strlen(pwd) + 1, testprogdir, - strlen(testprogdir)); + strlen(testprogdir) + 1); memcpy(testprogdir, pwd, strlen(pwd)); testprogdir[strlen(pwd)] = '/'; } Modified: stable/10/contrib/libarchive/cpio/test/test.h ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test.h Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/test/test.h Fri Jun 17 22:40:10 2016 (r302001) @@ -66,6 +66,7 @@ #include #include #include +#include #include #ifdef HAVE_UNISTD_H #include @@ -84,12 +85,14 @@ /* Windows (including Visual Studio and MinGW but not Cygwin) */ #if defined(_WIN32) && !defined(__CYGWIN__) #if !defined(__BORLANDC__) +#undef chdir +#define chdir _chdir #define strdup _strdup #endif #endif /* Visual Studio */ -#ifdef _MSC_VER +#if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf sprintf_s #endif @@ -142,6 +145,9 @@ /* As above, but raw blocks of bytes. */ #define assertEqualMem(v1, v2, l) \ assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL) +/* Assert that memory is full of a specified byte */ +#define assertMemoryFilledWith(v1, l, b) \ + assertion_memory_filled_with(__FILE__, __LINE__, (v1), #v1, (l), #l, (b), #b, NULL) /* Assert two files are the same. */ #define assertEqualFile(f1, f2) \ assertion_equal_file(__FILE__, __LINE__, (f1), (f2)) @@ -225,6 +231,7 @@ int assertion_empty_file(const char *, i int assertion_equal_file(const char *, int, const char *, const char *); int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *); int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *); +int assertion_memory_filled_with(const char *, int, const void *, const char *, size_t, const char *, char, const char *, void *); int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int); int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *); int assertion_file_atime(const char *, int, const char *, long, long); @@ -275,9 +282,15 @@ int canGrzip(void); /* Return true if this platform can run the "gzip" program. */ int canGzip(void); +/* Return true if this platform can run the specified command. */ +int canRunCommand(const char *); + /* Return true if this platform can run the "lrzip" program. */ int canLrzip(void); +/* Return true if this platform can run the "lz4" program. */ +int canLz4(void); + /* Return true if this platform can run the "lzip" program. */ int canLzip(void); @@ -300,21 +313,31 @@ int is_LargeInode(const char *); /* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */ char *slurpfile(size_t *, const char *fmt, ...); +/* Dump block of bytes to a file. */ +void dumpfile(const char *filename, void *, size_t); + /* Extracts named reference file to the current directory. */ void extract_reference_file(const char *); +/* Copies named reference file to the current directory. */ +void copy_reference_file(const char *); + +/* Extracts a list of files to the current directory. + * List must be NULL terminated. + */ +void extract_reference_files(const char **); /* Path to working directory for current test */ -const char *testworkdir; +extern const char *testworkdir; /* * Special interfaces for program test harness. */ /* Pathname of exe to be tested. */ -const char *testprogfile; +extern const char *testprogfile; /* Name of exe to use in printf-formatted command strings. */ /* On Windows, this includes leading/trailing quotes. */ -const char *testprog; +extern const char *testprog; #ifdef USE_DMALLOC #include Modified: stable/10/contrib/libarchive/cpio/test/test_basic.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test_basic.c Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/test/test_basic.c Fri Jun 17 22:40:10 2016 (r302001) @@ -72,7 +72,7 @@ basic_cpio(const char *target, return; /* Use the cpio program to create an archive. */ - r = systemf("%s -o %s < filelist >%s/archive 2>%s/pack.err", + r = systemf("%s -R 1000:1000 -o %s < filelist >%s/archive 2>%s/pack.err", testprog, pack_options, target, target); failure("Error invoking %s -o %s", testprog, pack_options); assertEqualInt(r, 0); Copied: stable/10/contrib/libarchive/cpio/test/test_extract.cpio.lz4.uu (from r299529, head/contrib/libarchive/cpio/test/test_extract.cpio.lz4.uu) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/cpio/test/test_extract.cpio.lz4.uu Fri Jun 17 22:40:10 2016 (r302001, copy of r299529, head/contrib/libarchive/cpio/test/test_extract.cpio.lz4.uu) @@ -0,0 +1,7 @@ +begin 644 test_extract.cpio.lz4 +M!")-&&1PN9$````A,#<"`&`P-#`P,3`!`&`Q,3`P-C8/`#0W-3`&```)``$& +M`,$P,3(P,S(W-#`R,S01`!$V!@```@#Q!3(S9FEL93$`8V]N=&5N=',@;V8@ +M$@`A+@IC``AE`!\R90`4$#2#``YE`!TR90`6,F4`#P(`#@+H``P"`"test.out 2>test.err", testprog, reffile); + if (f == 0 || canLz4()) { + assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertTextFileContents("1 block\n", "test.err"); + } else { + skipping("It seems lz4 is not supported on this platform"); + } +} Modified: stable/10/contrib/libarchive/cpio/test/test_extract_cpio_lzo.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test_extract_cpio_lzo.c Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/test/test_extract_cpio_lzo.c Fri Jun 17 22:40:10 2016 (r302001) @@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_extract_cpio_lzo) { - const char *reffile = "test_extract.cpio.lrz"; + const char *reffile = "test_extract.cpio.lzo"; int f; extract_reference_file(reffile); Modified: stable/10/contrib/libarchive/cpio/test/test_option_c.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test_option_c.c Fri Jun 17 19:41:30 2016 (r302000) +++ stable/10/contrib/libarchive/cpio/test/test_option_c.c Fri Jun 17 22:40:10 2016 (r302001) @@ -65,18 +65,14 @@ DEFINE_TEST(test_option_c) { FILE *filelist; int r; - int uid = -1; - int dev, ino, gid; + int uid = 1000; + int dev, ino, gid = 1000; time_t t, now; char *p, *e; size_t s; assertUmask(0); -#if !defined(_WIN32) - uid = getuid(); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-10@freebsd.org Sat Jun 18 01:23:39 2016 Return-Path: Delivered-To: svn-src-stable-10@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 C4315A77B6B; Sat, 18 Jun 2016 01:23:39 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 9554513D7; Sat, 18 Jun 2016 01:23:39 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5I1Nc57090641; Sat, 18 Jun 2016 01:23:38 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5I1Ncur090640; Sat, 18 Jun 2016 01:23:38 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201606180123.u5I1Ncur090640@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 18 Jun 2016 01:23:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302002 - stable/10/sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2016 01:23:39 -0000 Author: emaste Date: Sat Jun 18 01:23:38 2016 New Revision: 302002 URL: https://svnweb.freebsd.org/changeset/base/302002 Log: MFC r300231: elf_common.h: add section header flag and dynamic types SHF_COMPRESSED section contains compressed data DT_TLSDESC_PLT Location of PLT entry for TLS descriptor resolver calls DT_TLSDESC_GOT Location of GOT entry used by resolver PLT entry Modified: stable/10/sys/sys/elf_common.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sys/elf_common.h ============================================================================== --- stable/10/sys/sys/elf_common.h Fri Jun 17 22:40:10 2016 (r302001) +++ stable/10/sys/sys/elf_common.h Sat Jun 18 01:23:38 2016 (r302002) @@ -472,6 +472,7 @@ typedef struct { #define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */ #define SHF_GROUP 0x200 /* Member of section group. */ #define SHF_TLS 0x400 /* Section contains TLS data. */ +#define SHF_COMPRESSED 0x800 /* Section contains compressed data. */ #define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */ #define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */ @@ -607,6 +608,8 @@ typedef struct { */ #define DT_ADDRRNGLO 0x6ffffe00 #define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */ +#define DT_TLSDESC_PLT 0x6ffffef6 /* loc. of PLT for tlsdesc resolver */ +#define DT_TLSDESC_GOT 0x6ffffef7 /* loc. of GOT for tlsdesc resolver */ #define DT_GNU_CONFLICT 0x6ffffef8 /* address of conflict section */ #define DT_GNU_LIBLIST 0x6ffffef9 /* address of library list */ #define DT_CONFIG 0x6ffffefa /* configuration information */ From owner-svn-src-stable-10@freebsd.org Sat Jun 18 12:44:15 2016 Return-Path: Delivered-To: svn-src-stable-10@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 DAFBCA7849F; Sat, 18 Jun 2016 12:44:15 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 A7BA914D1; Sat, 18 Jun 2016 12:44:15 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5ICiESE043900; Sat, 18 Jun 2016 12:44:14 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5ICiEHX043899; Sat, 18 Jun 2016 12:44:14 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201606181244.u5ICiEHX043899@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Sat, 18 Jun 2016 12:44:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302006 - stable/10/sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2016 12:44:16 -0000 Author: ed Date: Sat Jun 18 12:44:14 2016 New Revision: 302006 URL: https://svnweb.freebsd.org/changeset/base/302006 Log: MFC r301406: Don't test for INKERNEL to check whether we're in kernel space. It turns out that actually defines a macro under this name, even when we're not in kernelspace. This causes us to suppress some macro definitions that are used by userspace apps. PR: 210026 Reported by: jbeich@ Modified: stable/10/sys/sys/soundcard.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sys/soundcard.h ============================================================================== --- stable/10/sys/sys/soundcard.h Sat Jun 18 12:42:49 2016 (r302005) +++ stable/10/sys/sys/soundcard.h Sat Jun 18 12:44:14 2016 (r302006) @@ -1261,7 +1261,7 @@ typedef struct mixer_info { */ #define LOCL_STARTAUDIO 1 -#if (!defined(_KERNEL) && !defined(INKERNEL)) || defined(USE_SEQ_MACROS) +#if !defined(_KERNEL) || defined(USE_SEQ_MACROS) /* * Some convenience macros to simplify programming of the * /dev/sequencer interface From owner-svn-src-stable-10@freebsd.org Sat Jun 18 12:46:51 2016 Return-Path: Delivered-To: svn-src-stable-10@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 44C3CA78718; Sat, 18 Jun 2016 12:46:51 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 16AC91A04; Sat, 18 Jun 2016 12:46:51 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5ICko0v044090; Sat, 18 Jun 2016 12:46:50 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5ICkoA8044089; Sat, 18 Jun 2016 12:46:50 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201606181246.u5ICkoA8044089@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Sat, 18 Jun 2016 12:46:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302008 - stable/10/include X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2016 12:46:51 -0000 Author: ed Date: Sat Jun 18 12:46:50 2016 New Revision: 302008 URL: https://svnweb.freebsd.org/changeset/base/302008 Log: MFC r300998: Add missing va_list to . It looks like va_list should always be defined when XSI is enabled. It moved over to the POSIX base in the 2008 edition. Modified: stable/10/include/wchar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/include/wchar.h ============================================================================== --- stable/10/include/wchar.h Sat Jun 18 12:44:22 2016 (r302007) +++ stable/10/include/wchar.h Sat Jun 18 12:46:50 2016 (r302008) @@ -76,6 +76,13 @@ typedef __size_t size_t; #define _SIZE_T_DECLARED #endif +#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE +#ifndef _VA_LIST_DECLARED +typedef __va_list va_list; +#define _VA_LIST_DECLARED +#endif +#endif + #ifndef __cplusplus #ifndef _WCHAR_T_DECLARED typedef ___wchar_t wchar_t; From owner-svn-src-stable-10@freebsd.org Sat Jun 18 13:41:01 2016 Return-Path: Delivered-To: svn-src-stable-10@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 8241CA7817D; Sat, 18 Jun 2016 13:41:01 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 359462EB7; Sat, 18 Jun 2016 13:41:01 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5IDf0HG062467; Sat, 18 Jun 2016 13:41:00 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5IDf0P1062466; Sat, 18 Jun 2016 13:41:00 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201606181341.u5IDf0P1062466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sat, 18 Jun 2016 13:41:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302009 - stable/10 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2016 13:41:01 -0000 Author: jilles Date: Sat Jun 18 13:41:00 2016 New Revision: 302009 URL: https://svnweb.freebsd.org/changeset/base/302009 Log: Add mergeinfo missed in r300954. Modified: Directory Properties: stable/10/ (props changed) From owner-svn-src-stable-10@freebsd.org Sat Jun 18 13:42:34 2016 Return-Path: Delivered-To: svn-src-stable-10@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 F126BA78405; Sat, 18 Jun 2016 13:42:34 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 CBDF31326; Sat, 18 Jun 2016 13:42:34 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5IDgYH6065891; Sat, 18 Jun 2016 13:42:34 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5IDgXMO065886; Sat, 18 Jun 2016 13:42:33 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201606181342.u5IDgXMO065886@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sat, 18 Jun 2016 13:42:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302010 - in stable/10: lib/libthr share/man/man3 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2016 13:42:35 -0000 Author: jilles Date: Sat Jun 18 13:42:33 2016 New Revision: 302010 URL: https://svnweb.freebsd.org/changeset/base/302010 Log: MFC r300970: Remove non-history libkse references and fix typo "PTHREAD_PROCESSES_PRIVATE". Modified: stable/10/lib/libthr/libthr.3 stable/10/share/man/man3/pthread_barrier_destroy.3 stable/10/share/man/man3/pthread_barrierattr.3 stable/10/share/man/man3/pthread_condattr.3 stable/10/share/man/man3/pthread_spin_init.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libthr/libthr.3 ============================================================================== --- stable/10/lib/libthr/libthr.3 Sat Jun 18 13:41:00 2016 (r302009) +++ stable/10/lib/libthr/libthr.3 Sat Jun 18 13:42:33 2016 (r302010) @@ -47,9 +47,7 @@ library provides a 1:1 implementation of library interfaces for application threading. It has been optimized for use by applications expecting system scope thread -semantics, and can provide significant performance improvements -compared to -.Lb libkse . +semantics. .Pp The library is tightly integrated with the run-time link editor .Xr ld-elf.so.1 1 Modified: stable/10/share/man/man3/pthread_barrier_destroy.3 ============================================================================== --- stable/10/share/man/man3/pthread_barrier_destroy.3 Sat Jun 18 13:41:00 2016 (r302009) +++ stable/10/share/man/man3/pthread_barrier_destroy.3 Sat Jun 18 13:42:33 2016 (r302010) @@ -75,9 +75,7 @@ argument to .Fn pthread_barrier_init . Once the threads have been released the barrier will be reset. .Sh IMPLEMENTATION NOTES -In both -.Lb libkse -and +In .Lb libthr the .Dv PTHREAD_BARRIER_SERIAL_THREAD Modified: stable/10/share/man/man3/pthread_barrierattr.3 ============================================================================== --- stable/10/share/man/man3/pthread_barrierattr.3 Sat Jun 18 13:41:00 2016 (r302009) +++ stable/10/share/man/man3/pthread_barrierattr.3 Sat Jun 18 13:42:33 2016 (r302010) @@ -137,11 +137,9 @@ barriers does not fully conform to .St -p1003.2 because the process-shared attribute is ignored in -.Lb libthr , -and in -.Lb libkse ; +.Lb libthr ; if any value other than -.Dv PTHREAD_PROCESSES_PRIVATE +.Dv PTHREAD_PROCESS_PRIVATE is specified in a call to .Fn pthread_barrierattr_setpshared , it will return Modified: stable/10/share/man/man3/pthread_condattr.3 ============================================================================== --- stable/10/share/man/man3/pthread_condattr.3 Sat Jun 18 13:41:00 2016 (r302009) +++ stable/10/share/man/man3/pthread_condattr.3 Sat Jun 18 13:42:33 2016 (r302010) @@ -167,7 +167,7 @@ does not fully conform to .St -p1003.2 because the process-shared attribute is ignored; if any value other than -.Dv PTHREAD_PROCESSES_PRIVATE +.Dv PTHREAD_PROCESS_PRIVATE is specified in a call to .Fn pthread_condattr_setpshared , it will return Modified: stable/10/share/man/man3/pthread_spin_init.3 ============================================================================== --- stable/10/share/man/man3/pthread_spin_init.3 Sat Jun 18 13:41:00 2016 (r302009) +++ stable/10/share/man/man3/pthread_spin_init.3 Sat Jun 18 13:42:33 2016 (r302010) @@ -129,10 +129,8 @@ does not fully conform to because the .Fa pshared argument is ignored in -.Lb libthr , -and in -.Lb libkse +.Lb libthr ; if any value other than -.Dv PTHREAD_PROCESSES_PRIVATE +.Dv PTHREAD_PROCESS_PRIVATE is specified, it returns .Er EINVAL . From owner-svn-src-stable-10@freebsd.org Sat Jun 18 13:44:11 2016 Return-Path: Delivered-To: svn-src-stable-10@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 AD4FEA78479; Sat, 18 Jun 2016 13:44:11 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 61EC114E8; Sat, 18 Jun 2016 13:44:11 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5IDiAvP066045; Sat, 18 Jun 2016 13:44:10 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5IDiAIW066042; Sat, 18 Jun 2016 13:44:10 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201606181344.u5IDiAIW066042@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sat, 18 Jun 2016 13:44:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302011 - stable/10/share/man/man3 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2016 13:44:11 -0000 Author: jilles Date: Sat Jun 18 13:44:10 2016 New Revision: 302011 URL: https://svnweb.freebsd.org/changeset/base/302011 Log: MFC r301076: Fix typo ESRC -> ESRCH in pthread man pages. Modified: stable/10/share/man/man3/pthread_attr_get_np.3 stable/10/share/man/man3/pthread_resume_np.3 stable/10/share/man/man3/pthread_suspend_np.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man3/pthread_attr_get_np.3 ============================================================================== --- stable/10/share/man/man3/pthread_attr_get_np.3 Sat Jun 18 13:42:33 2016 (r302010) +++ stable/10/share/man/man3/pthread_attr_get_np.3 Sat Jun 18 13:44:10 2016 (r302011) @@ -93,7 +93,7 @@ function will fail if: .Bl -tag -width Er .It Bq Er EINVAL Invalid value for one of given parameters. -.It Bq Er ESRC +.It Bq Er ESRCH No thread could be found corresponding to that specified by the given thread ID. .El Modified: stable/10/share/man/man3/pthread_resume_np.3 ============================================================================== --- stable/10/share/man/man3/pthread_resume_np.3 Sat Jun 18 13:42:33 2016 (r302010) +++ stable/10/share/man/man3/pthread_resume_np.3 Sat Jun 18 13:44:10 2016 (r302011) @@ -57,7 +57,7 @@ function will fail if: The value specified by the .Fa tid argument is invalid. -.It Bq Er ESRC +.It Bq Er ESRCH No thread could be found corresponding to the thread ID specified by the .Fa tid argument. Modified: stable/10/share/man/man3/pthread_suspend_np.3 ============================================================================== --- stable/10/share/man/man3/pthread_suspend_np.3 Sat Jun 18 13:42:33 2016 (r302010) +++ stable/10/share/man/man3/pthread_suspend_np.3 Sat Jun 18 13:44:10 2016 (r302011) @@ -63,7 +63,7 @@ An attempt was made to suspend the curre The value specified by the .Fa tid argument is invalid. -.It Bq Er ESRC +.It Bq Er ESRCH No thread could be found corresponding to the thread ID specified by the .Fa tid argument.