From owner-svn-soc-all@freebsd.org Sun Aug 2 10:54:11 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B929B9B0F5C for ; Sun, 2 Aug 2015 10:54:11 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7E4BBF8 for ; Sun, 2 Aug 2015 10:54:11 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72AsBXS079800 for ; Sun, 2 Aug 2015 10:54:11 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72AsAhJ079797 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 10:54:10 GMT (envelope-from kczekirda@FreeBSD.org) Date: Sun, 2 Aug 2015 10:54:10 GMT Message-Id: <201508021054.t72AsAhJ079797@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289097 - in soc2015/kczekirda/www: . static tpl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 10:54:11 -0000 Author: kczekirda Date: Sun Aug 2 10:54:09 2015 New Revision: 289097 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289097 Log: iPXE menu and node management Added: soc2015/kczekirda/www/bottle.py soc2015/kczekirda/www/menu.py (contents, props changed) soc2015/kczekirda/www/mfsbsd_cluster.iso (contents, props changed) soc2015/kczekirda/www/static/ soc2015/kczekirda/www/static/cluster.ipxe soc2015/kczekirda/www/static/menu.ipxe soc2015/kczekirda/www/static/style.css soc2015/kczekirda/www/tpl/ soc2015/kczekirda/www/tpl/add_node.tpl soc2015/kczekirda/www/tpl/delete_node.tpl soc2015/kczekirda/www/tpl/edit_node.tpl soc2015/kczekirda/www/tpl/main.tpl Modified: soc2015/kczekirda/www/menu.ipxe Added: soc2015/kczekirda/www/bottle.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/kczekirda/www/bottle.py Sun Aug 2 10:54:09 2015 (r289097) @@ -0,0 +1,3892 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Bottle is a fast and simple micro-framework for small web applications. It +offers request dispatching (Routes) with url parameter support, templates, +a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and +template engines - all in a single file and with no dependencies other than the +Python Standard Library. + +Homepage and documentation: http://bottlepy.org/ + +Copyright (c) 2014, Marcel Hellkamp. +License: MIT (see LICENSE for details) +""" + +from __future__ import with_statement + +__author__ = 'Marcel Hellkamp' +__version__ = '0.13-dev' +__license__ = 'MIT' + +# The gevent and eventlet server adapters need to patch some modules before +# they are imported. This is why we parse the commandline parameters here but +# handle them later +if __name__ == '__main__': + from optparse import OptionParser + _cmd_parser = OptionParser( + usage="usage: %prog [options] package.module:app") + _opt = _cmd_parser.add_option + _opt("--version", action="store_true", help="show version number.") + _opt("-b", "--bind", metavar="ADDRESS", help="bind socket to ADDRESS.") + _opt("-s", "--server", default='wsgiref', help="use SERVER as backend.") + _opt("-p", "--plugin", + action="append", + help="install additional plugin/s.") + _opt("--debug", action="store_true", help="start server in debug mode.") + _opt("--reload", action="store_true", help="auto-reload on file changes.") + _cmd_options, _cmd_args = _cmd_parser.parse_args() + if _cmd_options.server: + if _cmd_options.server.startswith('gevent'): + import gevent.monkey + gevent.monkey.patch_all() + elif _cmd_options.server.startswith('eventlet'): + import eventlet + eventlet.monkey_patch() + +import base64, cgi, email.utils, functools, hmac, imp, itertools, mimetypes,\ + os, re, sys, tempfile, threading, time, warnings + +from types import FunctionType +from datetime import date as datedate, datetime, timedelta +from tempfile import TemporaryFile +from traceback import format_exc, print_exc +from inspect import getargspec +from unicodedata import normalize + +try: + from simplejson import dumps as json_dumps, loads as json_lds +except ImportError: # pragma: no cover + try: + from json import dumps as json_dumps, loads as json_lds + except ImportError: + try: + from django.utils.simplejson import dumps as json_dumps, loads as json_lds + except ImportError: + + def json_dumps(data): + raise ImportError( + "JSON support requires Python 2.6 or simplejson.") + + json_lds = json_dumps + +# We now try to fix 2.5/2.6/3.1/3.2 incompatibilities. +# It ain't pretty but it works... Sorry for the mess. + +py = sys.version_info +py3k = py >= (3, 0, 0) +py25 = py < (2, 6, 0) +py31 = (3, 1, 0) <= py < (3, 2, 0) + +# Workaround for the missing "as" keyword in py3k. +def _e(): + return sys.exc_info()[1] + +# Workaround for the "print is a keyword/function" Python 2/3 dilemma +# and a fallback for mod_wsgi (resticts stdout/err attribute access) +try: + _stdout, _stderr = sys.stdout.write, sys.stderr.write +except IOError: + _stdout = lambda x: sys.stdout.write(x) + _stderr = lambda x: sys.stderr.write(x) + +# Lots of stdlib and builtin differences. +if py3k: + import http.client as httplib + import _thread as thread + from urllib.parse import urljoin, SplitResult as UrlSplitResult + from urllib.parse import urlencode, quote as urlquote, unquote as urlunquote + urlunquote = functools.partial(urlunquote, encoding='latin1') + from http.cookies import SimpleCookie + from collections import MutableMapping as DictMixin + import pickle + from io import BytesIO + from configparser import ConfigParser + basestring = str + unicode = str + json_loads = lambda s: json_lds(touni(s)) + callable = lambda x: hasattr(x, '__call__') + imap = map + + def _raise(*a): + raise a[0](a[1]).with_traceback(a[2]) +else: # 2.x + import httplib + import thread + from urlparse import urljoin, SplitResult as UrlSplitResult + from urllib import urlencode, quote as urlquote, unquote as urlunquote + from Cookie import SimpleCookie + from itertools import imap + import cPickle as pickle + from StringIO import StringIO as BytesIO + from ConfigParser import SafeConfigParser as ConfigParser + if py25: + msg = "Python 2.5 support may be dropped in future versions of Bottle." + warnings.warn(msg, DeprecationWarning) + from UserDict import DictMixin + + def next(it): + return it.next() + + bytes = str + else: # 2.6, 2.7 + from collections import MutableMapping as DictMixin + unicode = unicode + json_loads = json_lds + eval(compile('def _raise(*a): raise a[0], a[1], a[2]', '', 'exec')) + + +# Some helpers for string/byte handling +def tob(s, enc='utf8'): + return s.encode(enc) if isinstance(s, unicode) else bytes(s) + + +def touni(s, enc='utf8', err='strict'): + if isinstance(s, bytes): + return s.decode(enc, err) + else: + return unicode(s or ("" if s is None else s)) + + +tonat = touni if py3k else tob + +# 3.2 fixes cgi.FieldStorage to accept bytes (which makes a lot of sense). +# 3.1 needs a workaround. +if py31: + from io import TextIOWrapper + + class NCTextIOWrapper(TextIOWrapper): + def close(self): + pass # Keep wrapped buffer open. + + +# A bug in functools causes it to break if the wrapper is an instance method +def update_wrapper(wrapper, wrapped, *a, **ka): + try: + functools.update_wrapper(wrapper, wrapped, *a, **ka) + except AttributeError: + pass + +# These helpers are used at module level and need to be defined first. +# And yes, I know PEP-8, but sometimes a lower-case classname makes more sense. + + +def depr(message, strict=False): + warnings.warn(message, DeprecationWarning, stacklevel=3) + + +def makelist(data): # This is just too handy + if isinstance(data, (tuple, list, set, dict)): + return list(data) + elif data: + return [data] + else: + return [] + + +class DictProperty(object): + """ Property that maps to a key in a local dict-like attribute. """ + + def __init__(self, attr, key=None, read_only=False): + self.attr, self.key, self.read_only = attr, key, read_only + + def __call__(self, func): + functools.update_wrapper(self, func, updated=[]) + self.getter, self.key = func, self.key or func.__name__ + return self + + def __get__(self, obj, cls): + if obj is None: return self + key, storage = self.key, getattr(obj, self.attr) + if key not in storage: storage[key] = self.getter(obj) + return storage[key] + + def __set__(self, obj, value): + if self.read_only: raise AttributeError("Read-Only property.") + getattr(obj, self.attr)[self.key] = value + + def __delete__(self, obj): + if self.read_only: raise AttributeError("Read-Only property.") + del getattr(obj, self.attr)[self.key] + + +class cached_property(object): + """ A property that is only computed once per instance and then replaces + itself with an ordinary attribute. Deleting the attribute resets the + property. """ + + def __init__(self, func): + self.__doc__ = getattr(func, '__doc__') + self.func = func + + def __get__(self, obj, cls): + if obj is None: return self + value = obj.__dict__[self.func.__name__] = self.func(obj) + return value + + +class lazy_attribute(object): + """ A property that caches itself to the class object. """ + + def __init__(self, func): + functools.update_wrapper(self, func, updated=[]) + self.getter = func + + def __get__(self, obj, cls): + value = self.getter(cls) + setattr(cls, self.__name__, value) + return value + +############################################################################### +# Exceptions and Events ######################################################## +############################################################################### + + +class BottleException(Exception): + """ A base class for exceptions used by bottle. """ + pass + +############################################################################### +# Routing ###################################################################### +############################################################################### + + +class RouteError(BottleException): + """ This is a base class for all routing related exceptions """ + + +class RouteReset(BottleException): + """ If raised by a plugin or request handler, the route is reset and all + plugins are re-applied. """ + + +class RouterUnknownModeError(RouteError): + + pass + + +class RouteSyntaxError(RouteError): + """ The route parser found something not supported by this router. """ + + +class RouteBuildError(RouteError): + """ The route could not be built. """ + + +def _re_flatten(p): + """ Turn all capturing groups in a regular expression pattern into + non-capturing groups. """ + if '(' not in p: + return p + return re.sub(r'(\\*)(\(\?P<[^>]+>|\((?!\?))', lambda m: m.group(0) if + len(m.group(1)) % 2 else m.group(1) + '(?:', p) + + +class Router(object): + """ A Router is an ordered collection of route->target pairs. It is used to + efficiently match WSGI requests against a number of routes and return + the first target that satisfies the request. The target may be anything, + usually a string, ID or callable object. A route consists of a path-rule + and a HTTP method. + + The path-rule is either a static path (e.g. `/contact`) or a dynamic + path that contains wildcards (e.g. `/wiki/`). The wildcard syntax + and details on the matching order are described in docs:`routing`. + """ + + default_pattern = '[^/]+' + default_filter = 're' + + #: The current CPython regexp implementation does not allow more + #: than 99 matching groups per regular expression. + _MAX_GROUPS_PER_PATTERN = 99 + + def __init__(self, strict=False): + self.rules = [] # All rules in order + self._groups = {} # index of regexes to find them in dyna_routes + self.builder = {} # Data structure for the url builder + self.static = {} # Search structure for static routes + self.dyna_routes = {} + self.dyna_regexes = {} # Search structure for dynamic routes + #: If true, static routes are no longer checked first. + self.strict_order = strict + self.filters = { + 're': lambda conf: (_re_flatten(conf or self.default_pattern), + None, None), + 'int': lambda conf: (r'-?\d+', int, lambda x: str(int(x))), + 'float': lambda conf: (r'-?[\d.]+', float, lambda x: str(float(x))), + 'path': lambda conf: (r'.+?', None, None) + } + + def add_filter(self, name, func): + """ Add a filter. The provided function is called with the configuration + string as parameter and must return a (regexp, to_python, to_url) tuple. + The first element is a string, the last two are callables or None. """ + self.filters[name] = func + + rule_syntax = re.compile('(\\\\*)' + '(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)' + '|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)' + '(?::((?:\\\\.|[^\\\\>]+)+)?)?)?>))') + + def _itertokens(self, rule): + offset, prefix = 0, '' + for match in self.rule_syntax.finditer(rule): + prefix += rule[offset:match.start()] + g = match.groups() + if len(g[0]) % 2: # Escaped wildcard + prefix += match.group(0)[len(g[0]):] + offset = match.end() + continue + if prefix: + yield prefix, None, None + name, filtr, conf = g[4:7] if g[2] is None else g[1:4] + yield name, filtr or 'default', conf or None + offset, prefix = match.end(), '' + if offset <= len(rule) or prefix: + yield prefix + rule[offset:], None, None + + def add(self, rule, method, target, name=None): + """ Add a new rule or replace the target for an existing rule. """ + anons = 0 # Number of anonymous wildcards found + keys = [] # Names of keys + pattern = '' # Regular expression pattern with named groups + filters = [] # Lists of wildcard input filters + builder = [] # Data structure for the URL builder + is_static = True + + for key, mode, conf in self._itertokens(rule): + if mode: + is_static = False + if mode == 'default': mode = self.default_filter + mask, in_filter, out_filter = self.filters[mode](conf) + if not key: + pattern += '(?:%s)' % mask + key = 'anon%d' % anons + anons += 1 + else: + pattern += '(?P<%s>%s)' % (key, mask) + keys.append(key) + if in_filter: filters.append((key, in_filter)) + builder.append((key, out_filter or str)) + elif key: + pattern += re.escape(key) + builder.append((None, key)) + + self.builder[rule] = builder + if name: self.builder[name] = builder + + if is_static and not self.strict_order: + self.static.setdefault(method, {}) + self.static[method][self.build(rule)] = (target, None) + return + + try: + re_pattern = re.compile('^(%s)$' % pattern) + re_match = re_pattern.match + except re.error: + raise RouteSyntaxError("Could not add Route: %s (%s)" % + (rule, _e())) + + if filters: + + def getargs(path): + url_args = re_match(path).groupdict() + for name, wildcard_filter in filters: + try: + url_args[name] = wildcard_filter(url_args[name]) + except ValueError: + raise HTTPError(400, 'Path has wrong format.') + return url_args + elif re_pattern.groupindex: + + def getargs(path): + return re_match(path).groupdict() + else: + getargs = None + + flatpat = _re_flatten(pattern) + whole_rule = (rule, flatpat, target, getargs) + + if (flatpat, method) in self._groups: + if DEBUG: + msg = 'Route <%s %s> overwrites a previously defined route' + warnings.warn(msg % (method, rule), RuntimeWarning) + self.dyna_routes[method][ + self._groups[flatpat, method]] = whole_rule + else: + self.dyna_routes.setdefault(method, []).append(whole_rule) + self._groups[flatpat, method] = len(self.dyna_routes[method]) - 1 + + self._compile(method) + + def _compile(self, method): + all_rules = self.dyna_routes[method] + comborules = self.dyna_regexes[method] = [] + maxgroups = self._MAX_GROUPS_PER_PATTERN + for x in range(0, len(all_rules), maxgroups): + some = all_rules[x:x + maxgroups] + combined = (flatpat for (_, flatpat, _, _) in some) + combined = '|'.join('(^%s$)' % flatpat for flatpat in combined) + combined = re.compile(combined).match + rules = [(target, getargs) for (_, _, target, getargs) in some] + comborules.append((combined, rules)) + + def build(self, _name, *anons, **query): + """ Build an URL by filling the wildcards in a rule. """ + builder = self.builder.get(_name) + if not builder: + raise RouteBuildError("No route with that name.", _name) + try: + for i, value in enumerate(anons): + query['anon%d' % i] = value + url = ''.join([f(query.pop(n)) if n else f for (n, f) in builder]) + return url if not query else url + '?' + urlencode(query) + except KeyError: + raise RouteBuildError('Missing URL argument: %r' % _e().args[0]) + + def match(self, environ): + """ Return a (target, url_args) tuple or raise HTTPError(400/404/405). """ + verb = environ['REQUEST_METHOD'].upper() + path = environ['PATH_INFO'] or '/' + + if verb == 'HEAD': + methods = ['PROXY', verb, 'GET', 'ANY'] + else: + methods = ['PROXY', verb, 'ANY'] + + for method in methods: + if method in self.static and path in self.static[method]: + target, getargs = self.static[method][path] + return target, getargs(path) if getargs else {} + elif method in self.dyna_regexes: + for combined, rules in self.dyna_regexes[method]: + match = combined(path) + if match: + target, getargs = rules[match.lastindex - 1] + return target, getargs(path) if getargs else {} + + # No matching route found. Collect alternative methods for 405 response + allowed = set([]) + nocheck = set(methods) + for method in set(self.static) - nocheck: + if path in self.static[method]: + allowed.add(verb) + for method in set(self.dyna_regexes) - allowed - nocheck: + for combined, rules in self.dyna_regexes[method]: + match = combined(path) + if match: + allowed.add(method) + if allowed: + allow_header = ",".join(sorted(allowed)) + raise HTTPError(405, "Method not allowed.", Allow=allow_header) + + # No matching route and no alternative method found. We give up + raise HTTPError(404, "Not found: " + repr(path)) + + +class Route(object): + """ This class wraps a route callback along with route specific metadata and + configuration and applies Plugins on demand. It is also responsible for + turing an URL path rule into a regular expression usable by the Router. + """ + + def __init__(self, app, rule, method, callback, + name=None, + plugins=None, + skiplist=None, **config): + #: The application this route is installed to. + self.app = app + #: The path-rule string (e.g. ``/wiki/``). + self.rule = rule + #: The HTTP method as a string (e.g. ``GET``). + self.method = method + #: The original callback with no plugins applied. Useful for introspection. + self.callback = callback + #: The name of the route (if specified) or ``None``. + self.name = name or None + #: A list of route-specific plugins (see :meth:`Bottle.route`). + self.plugins = plugins or [] + #: A list of plugins to not apply to this route (see :meth:`Bottle.route`). + self.skiplist = skiplist or [] + #: Additional keyword arguments passed to the :meth:`Bottle.route` + #: decorator are stored in this dictionary. Used for route-specific + #: plugin configuration and meta-data. + self.config = ConfigDict().load_dict(config) + + @cached_property + def call(self): + """ The route callback with all plugins applied. This property is + created on demand and then cached to speed up subsequent requests.""" + return self._make_callback() + + def reset(self): + """ Forget any cached values. The next time :attr:`call` is accessed, + all plugins are re-applied. """ + self.__dict__.pop('call', None) + + def prepare(self): + """ Do all on-demand work immediately (useful for debugging).""" + self.call + + def all_plugins(self): + """ Yield all Plugins affecting this route. """ + unique = set() + for p in reversed(self.app.plugins + self.plugins): + if True in self.skiplist: break + name = getattr(p, 'name', False) + if name and (name in self.skiplist or name in unique): continue + if p in self.skiplist or type(p) in self.skiplist: continue + if name: unique.add(name) + yield p + + def _make_callback(self): + callback = self.callback + for plugin in self.all_plugins(): + try: + if hasattr(plugin, 'apply'): + callback = plugin.apply(callback, self) + else: + callback = plugin(callback) + except RouteReset: # Try again with changed configuration. + return self._make_callback() + if not callback is self.callback: + update_wrapper(callback, self.callback) + return callback + + def get_undecorated_callback(self): + """ Return the callback. If the callback is a decorated function, try to + recover the original function. """ + func = self.callback + func = getattr(func, '__func__' if py3k else 'im_func', func) + closure_attr = '__closure__' if py3k else 'func_closure' + while hasattr(func, closure_attr) and getattr(func, closure_attr): + attributes = getattr(func, closure_attr) + func = attributes[0].cell_contents + + # in case of decorators with multiple arguments + if not isinstance(func, FunctionType): + # pick first FunctionType instance from multiple arguments + func = filter(lambda x: isinstance(x, FunctionType), + map(lambda x: x.cell_contents, attributes)) + func = list(func)[0] # py3 support + return func + + def get_callback_args(self): + """ Return a list of argument names the callback (most likely) accepts + as keyword arguments. If the callback is a decorated function, try + to recover the original function before inspection. """ + return getargspec(self.get_undecorated_callback())[0] + + def get_config(self, key, default=None): + """ Lookup a config field and return its value, first checking the + route.config, then route.app.config.""" + for conf in (self.config, self.app.config): + if key in conf: return conf[key] + return default + + def __repr__(self): + cb = self.get_undecorated_callback() + return '<%s %r %r>' % (self.method, self.rule, cb) + +############################################################################### +# Application Object ########################################################### +############################################################################### + + +class Bottle(object): + """ Each Bottle object represents a single, distinct web application and + consists of routes, callbacks, plugins, resources and configuration. + Instances are callable WSGI applications. + + :param catchall: If true (default), handle all exceptions. Turn off to + let debugging middleware handle exceptions. + """ + + def __init__(self, catchall=True, autojson=True): + + #: A :class:`ConfigDict` for app specific configuration. + self.config = ConfigDict() + self.config._on_change = functools.partial(self.trigger_hook, 'config') + self.config.meta_set('autojson', 'validate', bool) + self.config.meta_set('catchall', 'validate', bool) + self.config['catchall'] = catchall + self.config['autojson'] = autojson + + #: A :class:`ResourceManager` for application files + self.resources = ResourceManager() + + self.routes = [] # List of installed :class:`Route` instances. + self.router = Router() # Maps requests to :class:`Route` instances. + self.error_handler = {} + + # Core plugins + self.plugins = [] # List of installed plugins. + if self.config['autojson']: + self.install(JSONPlugin()) + self.install(TemplatePlugin()) + + #: If true, most exceptions are caught and returned as :exc:`HTTPError` + catchall = DictProperty('config', 'catchall') + + __hook_names = 'before_request', 'after_request', 'app_reset', 'config' + __hook_reversed = 'after_request' + + @cached_property + def _hooks(self): + return dict((name, []) for name in self.__hook_names) + + def add_hook(self, name, func): + """ Attach a callback to a hook. Three hooks are currently implemented: + + before_request + Executed once before each request. The request context is + available, but no routing has happened yet. + after_request + Executed once after each request regardless of its outcome. + app_reset + Called whenever :meth:`Bottle.reset` is called. + """ + if name in self.__hook_reversed: + self._hooks[name].insert(0, func) + else: + self._hooks[name].append(func) + + def remove_hook(self, name, func): + """ Remove a callback from a hook. """ + if name in self._hooks and func in self._hooks[name]: + self._hooks[name].remove(func) + return True + + def trigger_hook(self, __name, *args, **kwargs): + """ Trigger a hook and return a list of results. """ + return [hook(*args, **kwargs) for hook in self._hooks[__name][:]] + + def hook(self, name): + """ Return a decorator that attaches a callback to a hook. See + :meth:`add_hook` for details.""" + + def decorator(func): + self.add_hook(name, func) + return func + + return decorator + + def mount(self, prefix, app, **options): + """ Mount an application (:class:`Bottle` or plain WSGI) to a specific + URL prefix. Example:: + + root_app.mount('/admin/', admin_app) + + :param prefix: path prefix or `mount-point`. If it ends in a slash, + that slash is mandatory. + :param app: an instance of :class:`Bottle` or a WSGI application. + + All other parameters are passed to the underlying :meth:`route` call. + """ + + segments = [p for p in prefix.split('/') if p] + if not segments: raise ValueError('Empty path prefix.') + path_depth = len(segments) + + def mountpoint_wrapper(): + try: + request.path_shift(path_depth) + rs = HTTPResponse([]) + + def start_response(status, headerlist, exc_info=None): + if exc_info: + _raise(*exc_info) + rs.status = status + for name, value in headerlist: + rs.add_header(name, value) + return rs.body.append + + body = app(request.environ, start_response) + rs.body = itertools.chain(rs.body, body) if rs.body else body + return rs + finally: + request.path_shift(-path_depth) + + options.setdefault('skip', True) + options.setdefault('method', 'PROXY') + options.setdefault('mountpoint', {'prefix': prefix, 'target': app}) + options['callback'] = mountpoint_wrapper + + self.route('/%s/<:re:.*>' % '/'.join(segments), **options) + if not prefix.endswith('/'): + self.route('/' + '/'.join(segments), **options) + + def merge(self, routes): + """ Merge the routes of another :class:`Bottle` application or a list of + :class:`Route` objects into this application. The routes keep their + 'owner', meaning that the :data:`Route.app` attribute is not + changed. """ + if isinstance(routes, Bottle): + routes = routes.routes + for route in routes: + self.add_route(route) + + def install(self, plugin): + """ Add a plugin to the list of plugins and prepare it for being + applied to all routes of this application. A plugin may be a simple + decorator or an object that implements the :class:`Plugin` API. + """ + if hasattr(plugin, 'setup'): plugin.setup(self) + if not callable(plugin) and not hasattr(plugin, 'apply'): + raise TypeError("Plugins must be callable or implement .apply()") + self.plugins.append(plugin) + self.reset() + return plugin + + def uninstall(self, plugin): + """ Uninstall plugins. Pass an instance to remove a specific plugin, a type + object to remove all plugins that match that type, a string to remove + all plugins with a matching ``name`` attribute or ``True`` to remove all + plugins. Return the list of removed plugins. """ + removed, remove = [], plugin + for i, plugin in list(enumerate(self.plugins))[::-1]: + if remove is True or remove is plugin or remove is type(plugin) \ + or getattr(plugin, 'name', True) == remove: + removed.append(plugin) + del self.plugins[i] + if hasattr(plugin, 'close'): plugin.close() + if removed: self.reset() + return removed + + def reset(self, route=None): + """ Reset all routes (force plugins to be re-applied) and clear all + caches. If an ID or route object is given, only that specific route + is affected. """ + if route is None: routes = self.routes + elif isinstance(route, Route): routes = [route] + else: routes = [self.routes[route]] + for route in routes: + route.reset() + if DEBUG: + for route in routes: + route.prepare() + self.trigger_hook('app_reset') + + def close(self): + """ Close the application and all installed plugins. """ + for plugin in self.plugins: + if hasattr(plugin, 'close'): plugin.close() + + def run(self, **kwargs): + """ Calls :func:`run` with the same parameters. """ + run(self, **kwargs) + + def match(self, environ): + """ Search for a matching route and return a (:class:`Route` , urlargs) + tuple. The second value is a dictionary with parameters extracted + from the URL. Raise :exc:`HTTPError` (404/405) on a non-match.""" + return self.router.match(environ) + + def get_url(self, routename, **kargs): + """ Return a string that matches a named route """ + scriptname = request.environ.get('SCRIPT_NAME', '').strip('/') + '/' + location = self.router.build(routename, **kargs).lstrip('/') + return urljoin(urljoin('/', scriptname), location) + + def add_route(self, route): + """ Add a route object, but do not change the :data:`Route.app` + attribute.""" + self.routes.append(route) + self.router.add(route.rule, route.method, route, name=route.name) + if DEBUG: route.prepare() + + def route(self, + path=None, + method='GET', + callback=None, + name=None, + apply=None, + skip=None, **config): + """ A decorator to bind a function to a request URL. Example:: + + @app.route('/hello/') + def hello(name): + return 'Hello %s' % name + + The ```` part is a wildcard. See :class:`Router` for syntax + details. + + :param path: Request path or a list of paths to listen to. If no + path is specified, it is automatically generated from the + signature of the function. + :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of + methods to listen to. (default: `GET`) + :param callback: An optional shortcut to avoid the decorator + syntax. ``route(..., callback=func)`` equals ``route(...)(func)`` + :param name: The name for this route. (default: None) + :param apply: A decorator or plugin or a list of plugins. These are + applied to the route callback in addition to installed plugins. + :param skip: A list of plugins, plugin classes or names. Matching + plugins are not installed to this route. ``True`` skips all. + + Any additional keyword arguments are stored as route-specific + configuration and passed to plugins (see :meth:`Plugin.apply`). + """ + if callable(path): path, callback = None, path + plugins = makelist(apply) + skiplist = makelist(skip) + + def decorator(callback): + if isinstance(callback, basestring): callback = load(callback) + for rule in makelist(path) or yieldroutes(callback): + for verb in makelist(method): + verb = verb.upper() + route = Route(self, rule, verb, callback, + name=name, + plugins=plugins, + skiplist=skiplist, **config) + self.add_route(route) + return callback + + return decorator(callback) if callback else decorator + + def get(self, path=None, method='GET', **options): + """ Equals :meth:`route`. """ + return self.route(path, method, **options) + + def post(self, path=None, method='POST', **options): + """ Equals :meth:`route` with a ``POST`` method parameter. """ + return self.route(path, method, **options) + + def put(self, path=None, method='PUT', **options): + """ Equals :meth:`route` with a ``PUT`` method parameter. """ + return self.route(path, method, **options) + + def delete(self, path=None, method='DELETE', **options): + """ Equals :meth:`route` with a ``DELETE`` method parameter. """ + return self.route(path, method, **options) + + def patch(self, path=None, method='PATCH', **options): + """ Equals :meth:`route` with a ``PATCH`` method parameter. """ + return self.route(path, method, **options) + + def error(self, code=500): + """ Decorator: Register an output handler for a HTTP error code""" + + def wrapper(handler): + self.error_handler[int(code)] = handler + return handler + + return wrapper + + def default_error_handler(self, res): + return tob(template(ERROR_PAGE_TEMPLATE, e=res)) + + def _handle(self, environ): + path = environ['bottle.raw_path'] = environ['PATH_INFO'] + if py3k: + try: + environ['PATH_INFO'] = path.encode('latin1').decode('utf8') + except UnicodeError: + return HTTPError(400, 'Invalid path string. Expected UTF-8') + + try: + environ['bottle.app'] = self + request.bind(environ) + response.bind() + try: + self.trigger_hook('before_request') + route, args = self.router.match(environ) + environ['route.handle'] = route + environ['bottle.route'] = route + environ['route.url_args'] = args + return route.call(**args) + finally: + self.trigger_hook('after_request') + except HTTPResponse: + return _e() + except RouteReset: + route.reset() + return self._handle(environ) + except (KeyboardInterrupt, SystemExit, MemoryError): + raise + except Exception: + if not self.catchall: raise + stacktrace = format_exc() + environ['wsgi.errors'].write(stacktrace) + return HTTPError(500, "Internal Server Error", _e(), stacktrace) + + def _cast(self, out, peek=None): + """ Try to convert the parameter into something WSGI compatible and set + correct HTTP headers when possible. + Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, + iterable of strings and iterable of unicodes + """ + + # Empty output is done here + if not out: + if 'Content-Length' not in response: + response['Content-Length'] = 0 + return [] + # Join lists of byte or unicode strings. Mixed lists are NOT supported + if isinstance(out, (tuple, list))\ + and isinstance(out[0], (bytes, unicode)): + out = out[0][0:0].join(out) # b'abc'[0:0] -> b'' + # Encode unicode strings + if isinstance(out, unicode): + out = out.encode(response.charset) + # Byte Strings are just returned + if isinstance(out, bytes): + if 'Content-Length' not in response: + response['Content-Length'] = len(out) + return [out] + # HTTPError or HTTPException (recursive, because they may wrap anything) + # TODO: Handle these explicitly in handle() or make them iterable. + if isinstance(out, HTTPError): + out.apply(response) + out = self.error_handler.get(out.status_code, + self.default_error_handler)(out) + return self._cast(out) + if isinstance(out, HTTPResponse): + out.apply(response) + return self._cast(out.body) + + # File-like objects. + if hasattr(out, 'read'): + if 'wsgi.file_wrapper' in request.environ: + return request.environ['wsgi.file_wrapper'](out) + elif hasattr(out, 'close') or not hasattr(out, '__iter__'): + return WSGIFileWrapper(out) + + # Handle Iterables. We peek into them to detect their inner type. + try: + iout = iter(out) + first = next(iout) + while not first: + first = next(iout) + except StopIteration: + return self._cast('') + except HTTPResponse: + first = _e() + except (KeyboardInterrupt, SystemExit, MemoryError): + raise + except: + if not self.catchall: raise + first = HTTPError(500, 'Unhandled exception', _e(), format_exc()) + + # These are the inner types allowed in iterator or generator objects. + if isinstance(first, HTTPResponse): + return self._cast(first) + elif isinstance(first, bytes): + new_iter = itertools.chain([first], iout) + elif isinstance(first, unicode): + encoder = lambda x: x.encode(response.charset) + new_iter = imap(encoder, itertools.chain([first], iout)) + else: + msg = 'Unsupported response type: %s' % type(first) + return self._cast(HTTPError(500, msg)) + if hasattr(out, 'close'): + new_iter = _closeiter(new_iter, out.close) + return new_iter + + def wsgi(self, environ, start_response): + """ The bottle WSGI-interface. """ + try: + out = self._cast(self._handle(environ)) + # rfc2616 section 4.3 + if response._status_code in (100, 101, 204, 304)\ + or environ['REQUEST_METHOD'] == 'HEAD': + if hasattr(out, 'close'): out.close() + out = [] + start_response(response._status_line, response.headerlist) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@freebsd.org Sun Aug 2 16:24:13 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 029739B1E10 for ; Sun, 2 Aug 2015 16:24:13 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E7545C32 for ; Sun, 2 Aug 2015 16:24:12 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72GOCgm068543 for ; Sun, 2 Aug 2015 16:24:12 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72GOCfi068539 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 16:24:12 GMT (envelope-from iateaca@FreeBSD.org) Date: Sun, 2 Aug 2015 16:24:12 GMT Message-Id: <201508021624.t72GOCfi068539@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iateaca@FreeBSD.org using -f From: iateaca@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289111 - soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 16:24:13 -0000 Author: iateaca Date: Sun Aug 2 16:24:11 2015 New Revision: 289111 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289111 Log: handle the received multicast traffic Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c ============================================================================== --- soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sun Aug 2 14:56:30 2015 (r289110) +++ soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sun Aug 2 16:24:11 2015 (r289111) @@ -281,6 +281,9 @@ DPRINTF("Receive Packet: from tap interface of %zd bytes", read_len); + /* clear the Receiver Status Register */ + ne2000_set_reg_by_offset(sc, NE2000_P0_RO, ED_P0_RSR, 0x00); + if (!ne2000_ether_frame_is_valid(sc)) { DPRINTF("Drop the packet since the ether frame did not match"); return 0; @@ -291,6 +294,9 @@ return 0; } + ne2000_set_field_by_offset(sc, NE2000_P0_RO, ED_P0_RSR, + ED_RSR_PRX, ED_RSR_PRX); + size = read_len < ETHER_MIN_FRAME_LEN ? ETHER_MIN_FRAME_LEN : read_len; /* psize is the number of pages used by the frame and ne2000 header */ @@ -313,9 +319,6 @@ DPRINTF("Receive Packet: size: %d psize: %d next_curr: %d index: %d", size, psize, next_curr, index); - ne2000_set_field_by_offset(sc, NE2000_P0_RO, ED_P0_RSR, - 0xff, ED_RSR_PRX); - ed_hdr = (struct ed_ring *)(sc->ram + index); ed_hdr->rsr = ne2000_get_reg_by_offset(sc, NE2000_P0_RO, ED_P0_RSR); ed_hdr->next_packet = next_curr; @@ -424,6 +427,9 @@ static int ne2000_ether_frame_is_valid(struct pci_ne2000_softc *sc) { + uint8_t key = 0; + uint8_t mar_offset = 0; + uint8_t mar_reg = 0; uint8_t rcr = 0; uint8_t broadcast_addr[] = {[0 ... (ETHER_ADDR_LEN - 1)] = 0xff}; @@ -445,8 +451,25 @@ /* is valid if the destination MAC is the broadcast address */ if (rcr & ED_RCR_AB) { - if (memcmp(sc->rcv_buf, broadcast_addr, ETHER_ADDR_LEN) == 0) + if (memcmp(sc->rcv_buf, broadcast_addr, ETHER_ADDR_LEN) == 0) { + ne2000_set_field_by_offset(sc, NE2000_P0_RO, ED_P0_RSR, + ED_RSR_PHY, ED_RSR_PHY); return 1; + } + } + + /* is valid if the destination MAC represents a multicast address group */ + if ((rcr & ED_RCR_AM) && (sc->rcv_buf[0] & 0x01)) { + key = ne2000_ether_crc32_be(sc->rcv_buf, ETHER_ADDR_LEN) >> 26; + + mar_offset = ED_P1_MAR0 + (key >> 3); + mar_reg = ne2000_get_reg_by_offset(sc, NE2000_P1, mar_offset); + + if (mar_reg & (1 << (key & 7))) { + ne2000_set_field_by_offset(sc, NE2000_P0_RO, ED_P0_RSR, + ED_RSR_PHY, ED_RSR_PHY); + return 1; + } } return 0; @@ -837,16 +860,29 @@ ne2000_emul_reg_page1(struct pci_ne2000_softc *sc, uint8_t offset, uint8_t value) { + int err; uint8_t pstart = 0; uint8_t pstop = 0; - if (offset == ED_P1_CR) - return ne2000_emul_reg_page0(sc, offset, value); - else if (offset == ED_P1_CURR) { + switch (offset) { + case ED_P1_CR: + err = ne2000_emul_reg_page0(sc, offset, value); + assert(err == 0); + break; + case ED_P1_PAR0 ... ED_P1_PAR5: + DPRINTF("PAR[%d]: 0x%x", offset - ED_P1_PAR0, value); + break; + case ED_P1_CURR: DPRINTF("Current Page Register: %d", value); pstart = ne2000_get_reg_by_offset(sc, NE2000_P0, ED_P0_PSTART); pstop = ne2000_get_reg_by_offset(sc, NE2000_P0, ED_P0_PSTOP); assert(value >= pstart && value < pstop); + break; + case ED_P1_MAR0 ... ED_P1_MAR7: + DPRINTF("MAR[%d]: 0x%x", offset - ED_P1_MAR0, value); + break; + default: + assert(0); } return 0; From owner-svn-soc-all@freebsd.org Sun Aug 2 22:51:22 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC9B69B19C6 for ; Sun, 2 Aug 2015 22:51:22 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D132077 for ; Sun, 2 Aug 2015 22:51:22 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72MpMUD065149 for ; Sun, 2 Aug 2015 22:51:22 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72MpKJM064690 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 22:51:20 GMT (envelope-from roam@FreeBSD.org) Date: Sun, 2 Aug 2015 22:51:20 GMT Message-Id: <201508022251.t72MpKJM064690@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289120 - in soc2015/roam/ports: . net net/sixxs-aiccu net/sixxs-aiccu/files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 22:51:23 -0000 Author: roam Date: Sun Aug 2 22:51:20 2015 New Revision: 289120 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289120 Log: Import the FreeBSD port of sixxs-aiccu-20070115_4. Obtained from: The FreeBSD Ports Collection ObQuote: "Where do we go from here?" Added: soc2015/roam/ports/ soc2015/roam/ports/net/ soc2015/roam/ports/net/sixxs-aiccu/ soc2015/roam/ports/net/sixxs-aiccu/Makefile soc2015/roam/ports/net/sixxs-aiccu/distinfo soc2015/roam/ports/net/sixxs-aiccu/files/ soc2015/roam/ports/net/sixxs-aiccu/files/sixxs-aiccu.in soc2015/roam/ports/net/sixxs-aiccu/pkg-descr soc2015/roam/ports/net/sixxs-aiccu/pkg-plist Added: soc2015/roam/ports/net/sixxs-aiccu/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/sixxs-aiccu/Makefile Sun Aug 2 22:51:20 2015 (r289120) @@ -0,0 +1,65 @@ +# Created by: Meno Abels +# $FreeBSD$ + +PORTNAME= aiccu +PORTVERSION= 20070115 +PORTREVISION= 4 +CATEGORIES= net ipv6 +MASTER_SITES= http://www.sixxs.net/archive/sixxs/aiccu/unix/ +PKGNAMEPREFIX= sixxs- +DISTNAME= aiccu_20070115 + +MAINTAINER= ports@FreeBSD.org +COMMENT= SixXS IPv6 TIC+ tunnel broker heartbeat client + +LICENSE= BSD3CLAUSE +LICENSE_FILE= ${WRKSRC}/doc/LICENSE + +USE_RC_SUBR= sixxs-aiccu +USES= gmake + +CFLAGS+= -D_REENTRANT -I${LOCALBASE}/include +LDFLAGS+= -lpthread -L${LOCALBASE}/lib +MAKE_ARGS+= CC="${CC}" LDFLAGS="${LDFLAGS}" +WRKSRC= ${WRKDIR}/aiccu +BUILD_WRKSRC= ${WRKDIR}/aiccu/unix-console +PORTDOCS= README + +OPTIONS_DEFINE= GNUTLS LOG_DAEMON DOCS +GNUTLS_DESC= Use gnutls to secure TIC supporting starttls +LOG_DAEMON_DESC=Log to LOG_DAEMON instead to LOG_LOCAL7 + +OPTIONS_DEFAULT+= GNUTLS + +.include + +.if ${PORT_OPTIONS:MGNUTLS} +LIB_DEPENDS+= libgnutls-openssl.so:${PORTSDIR}/security/gnutls +CFLAGS+= -DAICCU_GNUTLS +LDFLAGS+= -lgnutls +.endif + +post-patch: + @${REINPLACE_CMD} \ + -e 's:verbose true:verbose false:' \ + -e 's:daemonize false:daemonize true:' \ + -e 's:automatic false:automatic true:' \ + -e 's:tunnel_id T2995:#tunnel_id TXXXX:' \ + -e 's:ipv4_interface eth0:ipv4_interface sis0:' \ + -e 's:ipv6_interface sixxs:ipv6_interface gif0:' \ + ${WRKSRC}/doc/aiccu.conf + +.if ${PORT_OPTIONS:MLOG_DAEMON} +do-configure: + @${REINPLACE_CMD} \ + -e 's:LOG_LOCAL7:LOG_DAEMON:' \ + ${WRKSRC}/common/common.c +.endif + +do-install: + ${INSTALL_PROGRAM} ${WRKSRC}/unix-console/aiccu ${STAGEDIR}${PREFIX}/sbin/sixxs-aiccu + ${MKDIR} ${STAGEDIR}${DOCSDIR} + ${INSTALL_DATA} ${WRKSRC}/doc/README ${STAGEDIR}${DOCSDIR} + ${INSTALL_DATA} ${WRKSRC}/doc/aiccu.conf ${STAGEDIR}${PREFIX}/etc/aiccu.conf.sample + +.include Added: soc2015/roam/ports/net/sixxs-aiccu/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/sixxs-aiccu/distinfo Sun Aug 2 22:51:20 2015 (r289120) @@ -0,0 +1,2 @@ +SHA256 (aiccu_20070115.tar.gz) = 2260f426c13471169ccff8cb4a3908dc5f79fda18ddb6a55363e7824e6c4c760 +SIZE (aiccu_20070115.tar.gz) = 70056 Added: soc2015/roam/ports/net/sixxs-aiccu/files/sixxs-aiccu.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/sixxs-aiccu/files/sixxs-aiccu.in Sun Aug 2 22:51:20 2015 (r289120) @@ -0,0 +1,40 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: sixxs-aiccu +# REQUIRE: NETWORKING ldconfig + +# +# Add the following lines to /etc/rc.conf to enable sixxs-aiccu: +# +#sixxs_aiccu_enable="YES" +# + +. /etc/rc.subr + +name="sixxs_aiccu" +rcvar="sixxs_aiccu_enable" + +command="%%PREFIX%%/sbin/sixxs-aiccu" + +load_rc_config ${name} + +# set default +: ${sixxs_aiccu_enable="NO"} +: ${sixxs_aiccu_config="%%PREFIX%%/etc/aiccu.conf"} + +command_args="${sixxs_aiccu_config}" +required_files="${sixxs_aiccu_config}" +start_cmd="${command} start $command_args" +stop_cmd="${command} stop $command_args" +brokers_cmd="${command} brokers" +tunnels_cmd="${command} tunnels $command_args" +test_cmd="${command} test $command_args" +autotest_cmd="${command} autotest $command_args" +license_cmd="${command} license" +version_cmd="${command} version" +extra_commands="brokers tunnels test autotest license version" + +run_rc_command "$1" Added: soc2015/roam/ports/net/sixxs-aiccu/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/sixxs-aiccu/pkg-descr Sun Aug 2 22:51:20 2015 (r289120) @@ -0,0 +1,4 @@ +This is the TIC+ heartbeart client for the public dynamic-IPv4 +IPv6 tunnel beta test from the SixXS tunnel service provider. + +WWW: http://www.sixxs.net/tools/aiccu/ Added: soc2015/roam/ports/net/sixxs-aiccu/pkg-plist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/sixxs-aiccu/pkg-plist Sun Aug 2 22:51:20 2015 (r289120) @@ -0,0 +1,2 @@ +@sample etc/aiccu.conf.sample +sbin/sixxs-aiccu From owner-svn-soc-all@freebsd.org Sun Aug 2 22:51:29 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57E7A9B19D8 for ; Sun, 2 Aug 2015 22:51:29 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3DB4A9D for ; Sun, 2 Aug 2015 22:51:29 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72MpTVG065699 for ; Sun, 2 Aug 2015 22:51:29 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72MpRbQ065691 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 22:51:27 GMT (envelope-from roam@FreeBSD.org) Date: Sun, 2 Aug 2015 22:51:27 GMT Message-Id: <201508022251.t72MpRbQ065691@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289121 - in soc2015/roam/ports/devel: . p5-Method-Signatures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 22:51:29 -0000 Author: roam Date: Sun Aug 2 22:51:26 2015 New Revision: 289121 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289121 Log: Add an initial port of Method-Signatures. Added: soc2015/roam/ports/devel/ soc2015/roam/ports/devel/p5-Method-Signatures/ soc2015/roam/ports/devel/p5-Method-Signatures/Makefile soc2015/roam/ports/devel/p5-Method-Signatures/distinfo soc2015/roam/ports/devel/p5-Method-Signatures/pkg-descr soc2015/roam/ports/devel/p5-Method-Signatures/pkg-plist Added: soc2015/roam/ports/devel/p5-Method-Signatures/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/devel/p5-Method-Signatures/Makefile Sun Aug 2 22:51:26 2015 (r289121) @@ -0,0 +1,27 @@ +# Created by: Peter Pentchev +# $FreeBSD$ + +PORTNAME= Method-Signatures +PORTVERSION= 20141021 +CATEGORIES= devel perl5 +MASTER_SITES= CPAN +MASTER_SITE_SUBDIR= CPAN:BAREFOOT +PKGNAMEPREFIX= p5- + +MAINTAINER= roam@FreeBSD.org +COMMENT= Perl5 module for method and function declarations + +USES= perl5 +USE_PERL5= modbuild + +BUILD_DEPENDS= p5-Test-Exception>=0.29:${PORTSDIR}/devel/p5-Test-Exception \ + p5-Test-Warn>=0.10:${PORTSDIR}/devel/p5-Test-Warn +RUN_DEPENDS= p5-Any-Moose>=0.11:${PORTSDIR}/devel/p5-Any-Moose \ + p5-Const-Fast>=0.006:${PORTSDIR}/devel/p5-Const-Fast \ + p5-Devel-Declare>=0.006002:${PORTSDIR}/devel/p5-Devel-Declare \ + p5-Lexical-SealRequireHints>=0.007:${PORTSDIR}/devel/p5-Lexical-SealRequireHints \ + p5-Mouse>=0.64:${PORTSDIR}/devel/p5-Mouse \ + p5-PPI>=1.203:${PORTSDIR}/textproc/p5-PPI \ + p5-Sub-Name>=0.03:${PORTSDIR}/devel/p5-Sub-Name + +.include Added: soc2015/roam/ports/devel/p5-Method-Signatures/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/devel/p5-Method-Signatures/distinfo Sun Aug 2 22:51:26 2015 (r289121) @@ -0,0 +1,2 @@ +SHA256 (Method-Signatures-20141021.tar.gz) = da0d7d2780dab163a97ed2c27c7292993d58e87ef79b5331b3838d37407e28bf +SIZE (Method-Signatures-20141021.tar.gz) = 70038 Added: soc2015/roam/ports/devel/p5-Method-Signatures/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/devel/p5-Method-Signatures/pkg-descr Sun Aug 2 22:51:26 2015 (r289121) @@ -0,0 +1,3 @@ +FIXME FIXME FIXME WRITE ME UP + +WWW: http://metacpan.org/dist/MooseX-Role-JSONObject Added: soc2015/roam/ports/devel/p5-Method-Signatures/pkg-plist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/devel/p5-Method-Signatures/pkg-plist Sun Aug 2 22:51:26 2015 (r289121) @@ -0,0 +1,8 @@ +%%SITE_PERL%%/Method/Signatures.pm +%%SITE_PERL%%/Method/Signatures/Modifiers.pm +%%SITE_PERL%%/Method/Signatures/Parameter.pm +%%SITE_PERL%%/Method/Signatures/Signature.pm +%%SITE_PERL%%/Method/Signatures/Types.pm +%%SITE_PERL%%/Method/Signatures/Utils.pm +%%PERL5_MAN3%%/Method::Signatures.3.gz +%%PERL5_MAN3%%/Method::Signatures::Modifiers.3.gz From owner-svn-soc-all@freebsd.org Sun Aug 2 22:51:35 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FC849B19EE for ; Sun, 2 Aug 2015 22:51:35 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7604CD2 for ; Sun, 2 Aug 2015 22:51:35 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72MpZb6065741 for ; Sun, 2 Aug 2015 22:51:35 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72MpXsP065733 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 22:51:33 GMT (envelope-from roam@FreeBSD.org) Date: Sun, 2 Aug 2015 22:51:33 GMT Message-Id: <201508022251.t72MpXsP065733@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289122 - soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 22:51:35 -0000 Author: roam Date: Sun Aug 2 22:51:33 2015 New Revision: 289122 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289122 Log: Add an initial port of MooseX-Role-JSONObject. Added: soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/ soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/Makefile soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/distinfo soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/pkg-descr soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/pkg-plist Added: soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/Makefile Sun Aug 2 22:51:33 2015 (r289122) @@ -0,0 +1,22 @@ +# Created by: Peter Pentchev +# $FreeBSD$ + +PORTNAME= MooseX-Role-JSONObject +PORTVERSION= 0.1.0 +DISTVERSIONPREFIX= v +CATEGORIES= devel perl5 +MASTER_SITES= CPAN +#MASTER_SITES= http://www.freebsd.org/~roam/net/sixxs/ +PKGNAMEPREFIX= p5- + +MAINTAINER= roam@FreeBSD.org +COMMENT= Perl5 module to store and retrieve objects as JSON hashes + +USES= perl5 +USE_PERL5= modbuildtiny + +BUILD_DEPENDS= p5-Moose>=2:${PORTSDIR}/devel/p5-Moose \ + p5-Method-Signatures>=20141021:${PORTSDIR}/devel/p5-Method-Signatures +RUN_DEPENDS= ${BUILD_DEPENDS} + +.include Added: soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/distinfo Sun Aug 2 22:51:33 2015 (r289122) @@ -0,0 +1,2 @@ +SHA256 (MooseX-Role-JSONObject-v0.1.0.tar.gz) = 4b8839d3e23b8669a89ddbca7de4a77d21a8e23e8a540323ebd5a88cdc8cbc0b +SIZE (MooseX-Role-JSONObject-v0.1.0.tar.gz) = 12548 Added: soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/pkg-descr Sun Aug 2 22:51:33 2015 (r289122) @@ -0,0 +1,3 @@ +FIXME FIXME FIXME WRITE ME UP + +WWW: http://metacpan.org/dist/MooseX-Role-JSONObject Added: soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/pkg-plist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/devel/p5-MooseX-Role-JSONObject/pkg-plist Sun Aug 2 22:51:33 2015 (r289122) @@ -0,0 +1,6 @@ +%%SITE_PERL%%/MooseX/Role/JSONObject.pm +%%SITE_PERL%%/MooseX/Role/JSONObject/Meta/Trait.pm +%%SITE_PERL%%/MooseX/Role/JSONObject/Util.pm +%%PERL5_MAN3%%/MooseX::Role::JSONObject.3.gz +%%PERL5_MAN3%%/MooseX::Role::JSONObject::Meta::Trait.3.gz +%%PERL5_MAN3%%/MooseX::Role::JSONObject::Util.3.gz From owner-svn-soc-all@freebsd.org Sun Aug 2 22:51:41 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A73259B1A06 for ; Sun, 2 Aug 2015 22:51:41 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9852DF1 for ; Sun, 2 Aug 2015 22:51:41 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72MpfAA065796 for ; Sun, 2 Aug 2015 22:51:41 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72MpdQx065768 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 22:51:39 GMT (envelope-from roam@FreeBSD.org) Date: Sun, 2 Aug 2015 22:51:39 GMT Message-Id: <201508022251.t72MpdQx065768@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289123 - soc2015/roam/ports/net/p5-Net-SixXS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 22:51:41 -0000 Author: roam Date: Sun Aug 2 22:51:39 2015 New Revision: 289123 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289123 Log: Add an initial port of Net-SixXS. Added: soc2015/roam/ports/net/p5-Net-SixXS/ soc2015/roam/ports/net/p5-Net-SixXS/Makefile soc2015/roam/ports/net/p5-Net-SixXS/distinfo soc2015/roam/ports/net/p5-Net-SixXS/pkg-descr soc2015/roam/ports/net/p5-Net-SixXS/pkg-plist Added: soc2015/roam/ports/net/p5-Net-SixXS/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/p5-Net-SixXS/Makefile Sun Aug 2 22:51:39 2015 (r289123) @@ -0,0 +1,22 @@ +# Created by: Peter Pentchev +# $FreeBSD$ + +PORTNAME= Net-SixXS +PORTVERSION= 0.1.0 +DISTVERSIONPREFIX= v +CATEGORIES= net ipv6 perl5 +#MASTER_SITES= CPAN +MASTER_SITES= http://www.freebsd.org/~roam/net/sixxs/ +PKGNAMEPREFIX= p5- + +MAINTAINER= roam@FreeBSD.org +COMMENT= Perl5 module to interface with the SixXS services + +USES= perl5 +USE_PERL5= modbuildtiny + +BUILD_DEPENDS= p5-Moose>=2:${PORTSDIR}/devel/p5-Moose \ + p5-MooseX-Role-JSONObject>=0:${PORTSDIR}/devel/p5-MooseX-Role-JSONObject +RUN_DEPENDS= ${BUILD_DEPENDS} + +.include Added: soc2015/roam/ports/net/p5-Net-SixXS/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/p5-Net-SixXS/distinfo Sun Aug 2 22:51:39 2015 (r289123) @@ -0,0 +1,2 @@ +SHA256 (Net-SixXS-v0.1.0.tar.gz) = 67ff42ba996c6a1c2d5dbcad7dc4de94616dbf28d998a48a5aa7d61630e5cab2 +SIZE (Net-SixXS-v0.1.0.tar.gz) = 19552 Added: soc2015/roam/ports/net/p5-Net-SixXS/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/p5-Net-SixXS/pkg-descr Sun Aug 2 22:51:39 2015 (r289123) @@ -0,0 +1,5 @@ +This module implements a Perl interface to the SixXS TIC protocol for +configuring IPv6-in-IPv4 tunnels using the "Anything-In-Anything" +(AYIYA) protocol. + +WWW: http://metacpan.org/dist/Net-SixXS Added: soc2015/roam/ports/net/p5-Net-SixXS/pkg-plist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/p5-Net-SixXS/pkg-plist Sun Aug 2 22:51:39 2015 (r289123) @@ -0,0 +1,22 @@ +bin/sixxs-tic-server +bin/sixxs-tic-tunnels +%%SITE_PERL%%/Net/SixXS.pm +%%SITE_PERL%%/Net/SixXS/Data/Tunnel.pm +%%SITE_PERL%%/Net/SixXS/Diag.pm +%%SITE_PERL%%/Net/SixXS/Diag/MainDebug.pm +%%SITE_PERL%%/Net/SixXS/Diag/None.pm +%%SITE_PERL%%/Net/SixXS/TIC/Client.pm +%%SITE_PERL%%/Net/SixXS/TIC/Server.pm +%%SITE_PERL%%/Net/SixXS/TIC/Server/AnyEvent.pm +%%SITE_PERL%%/Net/SixXS/TIC/Server/Inetd.pm +%%PERL5_MAN3%%/Net::SixXS.3.gz +%%PERL5_MAN3%%/Net::SixXS::Data::Tunnel.3.gz +%%PERL5_MAN3%%/Net::SixXS::Diag.3.gz +%%PERL5_MAN3%%/Net::SixXS::Diag::MainDebug.3.gz +%%PERL5_MAN3%%/Net::SixXS::Diag::None.3.gz +%%PERL5_MAN3%%/Net::SixXS::TIC::Client.3.gz +%%PERL5_MAN3%%/Net::SixXS::TIC::Server.3.gz +%%PERL5_MAN3%%/Net::SixXS::TIC::Server::AnyEvent.3.gz +%%PERL5_MAN3%%/Net::SixXS::TIC::Server::Inetd.3.gz +man/man1/sixxs-tic-server.1.gz +man/man1/sixxs-tic-tunnels.1.gz From owner-svn-soc-all@freebsd.org Sun Aug 2 22:51:45 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A98E49B1A18 for ; Sun, 2 Aug 2015 22:51:45 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B10410C for ; Sun, 2 Aug 2015 22:51:45 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72Mpj8C066157 for ; Sun, 2 Aug 2015 22:51:45 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72MpjLJ065833 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 22:51:45 GMT (envelope-from roam@FreeBSD.org) Date: Sun, 2 Aug 2015 22:51:45 GMT Message-Id: <201508022251.t72MpjLJ065833@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289124 - soc2015/roam/ng_ayiya MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 22:51:45 -0000 Author: roam Date: Sun Aug 2 22:51:44 2015 New Revision: 289124 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289124 Log: Adapt to N::S::Data::Tunnel's switch to JSONObject. ObQuote: "I'll be one step behind you" Modified: soc2015/roam/ng_ayiya/scaffold.pl Modified: soc2015/roam/ng_ayiya/scaffold.pl ============================================================================== --- soc2015/roam/ng_ayiya/scaffold.pl Sun Aug 2 22:51:39 2015 (r289123) +++ soc2015/roam/ng_ayiya/scaffold.pl Sun Aug 2 22:51:44 2015 (r289124) @@ -472,7 +472,7 @@ die "No tunnel $tunnel defined in $fname\n"; } } - return Net::SixXS::Data::Tunnel->from_hash(\%cfg); + return Net::SixXS::Data::Tunnel->from_json(\%cfg); } sub cmd_ayiya($ @) From owner-svn-soc-all@freebsd.org Sun Aug 2 22:51:48 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7082C9B1A2B for ; Sun, 2 Aug 2015 22:51:48 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 62127129 for ; Sun, 2 Aug 2015 22:51:48 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72Mpmj1066407 for ; Sun, 2 Aug 2015 22:51:48 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72Mplh3066402 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 22:51:47 GMT (envelope-from roam@FreeBSD.org) Date: Sun, 2 Aug 2015 22:51:47 GMT Message-Id: <201508022251.t72Mplh3066402@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289125 - soc2015/roam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 22:51:48 -0000 Author: roam Date: Sun Aug 2 22:51:47 2015 New Revision: 289125 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289125 Log: Add the 'dist' and 'distclean' top-level targets. ObQuote: "Wrap it up, I'll take it" Modified: soc2015/roam/Makefile Modified: soc2015/roam/Makefile ============================================================================== --- soc2015/roam/Makefile Sun Aug 2 22:51:44 2015 (r289124) +++ soc2015/roam/Makefile Sun Aug 2 22:51:47 2015 (r289125) @@ -26,6 +26,18 @@ .include +NAME= ng_ayiya +VERSION= 0.1.0.dev210 + +DISTNAME= ${NAME}-${VERSION} +DISTDIR= ${DISTNAME} +S= ${.CURDIR} +D= ${.CURDIR}/${DISTDIR} + +CP?= cp -pf +RM?= rm -rf +MKDIR?= mkdir -p + down: cd ${.CURDIR}/ng_ayiya && ${MAKE} down @@ -40,3 +52,17 @@ clitest-quiet: tic cd ${.CURDIR}/ayiya_resp && ${MAKE} clitest-quiet + +dist: + ${RM} $D/ + ${MKDIR} $D + cd $S && git ls-files | fgrep -ve / | while read f; do ${CP} $S/$$f $D/$$f; done + cd $S && git ls-files ${SUBDIR} | xargs -n1 dirname | sort -u | while read d; do ${MKDIR} $D/$$d; done + cd $S && git ls-files ${SUBDIR} | while read f; do ${CP} $S/$$f $D/$$f; done + cd $S && tar zcf ${DISTNAME}.tar.gz ${DISTDIR}/ + cd $S && tar jcf ${DISTNAME}.tar.bz2 ${DISTDIR}/ + cd $S && tar Jcf ${DISTNAME}.tar.xz ${DISTDIR}/ + +distclean: + ${RM} $D/ + cd $S && ${MAKE} cleandir && ${MAKE} cleandir From owner-svn-soc-all@freebsd.org Sun Aug 2 22:51:54 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F4D09B1A40 for ; Sun, 2 Aug 2015 22:51:54 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70764151 for ; Sun, 2 Aug 2015 22:51:54 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72MpsHp066447 for ; Sun, 2 Aug 2015 22:51:54 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72Mpq79066427 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 22:51:52 GMT (envelope-from roam@FreeBSD.org) Date: Sun, 2 Aug 2015 22:51:52 GMT Message-Id: <201508022251.t72Mpq79066427@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289126 - soc2015/roam/ports/net/ng_ayiya MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 22:51:54 -0000 Author: roam Date: Sun Aug 2 22:51:51 2015 New Revision: 289126 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289126 Log: Add an initial port of ng_ayiya. Added: soc2015/roam/ports/net/ng_ayiya/ soc2015/roam/ports/net/ng_ayiya/Makefile soc2015/roam/ports/net/ng_ayiya/distinfo soc2015/roam/ports/net/ng_ayiya/distinfo.gz soc2015/roam/ports/net/ng_ayiya/pkg-descr soc2015/roam/ports/net/ng_ayiya/pkg-plist Added: soc2015/roam/ports/net/ng_ayiya/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/ng_ayiya/Makefile Sun Aug 2 22:51:51 2015 (r289126) @@ -0,0 +1,33 @@ +# Created by: Peter Pentchev +# $FreeBSD$ + +PORTNAME= ng_ayiya +DISTVERSION= 0.1.0.dev210 +EXTRACT_SUFX= .tar.xz +PORTVERSION= ${DISTVERSION:S/.dev/.d/} +CATEGORIES= net ipv6 +MASTER_SITES= http://www.freebsd.org/~roam/net/sixxs/ + +MAINTAINER= roam@FreeBSD.org +COMMENT= Netgraph implementation of the Anything-In-Anything protocol + +RUN_DEPENDS= p5-Net-SixXS>=0:${PORTSDIR}/net/p5-Net-SixXS + +USES= kmod + +do-build: + cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} DEBUG_FLAGS=-g + +do-install: + ${INSTALL_KLD} ${WRKSRC}/ng_ayiya/ng_ayiya.ko ${STAGEDIR}${KMODDIR} + ${INSTALL_KLD} ${WRKSRC}/ng_ayiya/ng_ayiya.ko.symbols ${STAGEDIR}${KMODDIR} + ${INSTALL_PROGRAM} ${WRKSRC}/ayiya_resp/ayiya_resp ${STAGEDIR}${PREFIX}/bin + ${MKDIR} ${STAGEDIR}${PREFIX}/include/netgraph + ${INSTALL_DATA} ${WRKSRC}/ng_ayiya/ng_ayiya.h ${STAGEDIR}${PREFIX}/include/netgraph + +.if !defined(NOPORTEXAMPLES) + ${MKDIR} ${STAGEDIR}${EXAMPLESDIR} + ${INSTALL_SCRIPT} ${WRKSRC}/ng_ayiya/scaffold.pl ${STAGEDIR}${EXAMPLESDIR} +.endif + +.include Added: soc2015/roam/ports/net/ng_ayiya/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/ng_ayiya/distinfo Sun Aug 2 22:51:51 2015 (r289126) @@ -0,0 +1,2 @@ +SHA256 (ng_ayiya-0.1.0.dev210.tar.xz) = 4bdc6de730d750409f53498a44493256c0a8c0830d243e3e8508213ed0890b0e +SIZE (ng_ayiya-0.1.0.dev210.tar.xz) = 18236 Added: soc2015/roam/ports/net/ng_ayiya/distinfo.gz ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/ng_ayiya/distinfo.gz Sun Aug 2 22:51:51 2015 (r289126) @@ -0,0 +1,2 @@ +SHA256 (ng_ayiya-0.1.0.dev210.tar.gz) = e715be50f3494ad7bd66deab8ac3c924bb0b052c01262c074c9eef3c1ef49f1e +SIZE (ng_ayiya-0.1.0.dev210.tar.gz) = 19873 Added: soc2015/roam/ports/net/ng_ayiya/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/ng_ayiya/pkg-descr Sun Aug 2 22:51:51 2015 (r289126) @@ -0,0 +1,5 @@ +A Netgraph node that acts as a link between a socket (TCP, UDP, SCTP, ...) +connection to an AYIYA server (e.g. the SixXS POPs) and a local network +interface (e.g. one that can route the IPv6 traffic for a SixXS tunnel). + +WWW: https://wiki.freebsd.org/SummerOfCode2015/AYIYASixXSNetgraphNode Added: soc2015/roam/ports/net/ng_ayiya/pkg-plist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/ng_ayiya/pkg-plist Sun Aug 2 22:51:51 2015 (r289126) @@ -0,0 +1,5 @@ +/%%KMODDIR%%/ng_ayiya.ko +/%%KMODDIR%%/ng_ayiya.ko.symbols +bin/ayiya_resp +include/netgraph/ng_ayiya.h +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/scaffold.pl From owner-svn-soc-all@freebsd.org Sun Aug 2 22:51:59 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB5E49B1A50 for ; Sun, 2 Aug 2015 22:51:59 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B2B2173 for ; Sun, 2 Aug 2015 22:51:59 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72MpxKr067616 for ; Sun, 2 Aug 2015 22:51:59 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72MpwkE067611 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 22:51:58 GMT (envelope-from roam@FreeBSD.org) Date: Sun, 2 Aug 2015 22:51:58 GMT Message-Id: <201508022251.t72MpwkE067611@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289127 - in soc2015/roam/ports/net/sixxs-aiccu: . files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 22:51:59 -0000 Author: roam Date: Sun Aug 2 22:51:58 2015 New Revision: 289127 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289127 Log: Teach AICCU about the ng_ayiya node. Added: soc2015/roam/ports/net/sixxs-aiccu/files/netgraph.patch Modified: soc2015/roam/ports/net/sixxs-aiccu/Makefile Modified: soc2015/roam/ports/net/sixxs-aiccu/Makefile ============================================================================== --- soc2015/roam/ports/net/sixxs-aiccu/Makefile Sun Aug 2 22:51:51 2015 (r289126) +++ soc2015/roam/ports/net/sixxs-aiccu/Makefile Sun Aug 2 22:51:58 2015 (r289127) @@ -25,9 +25,10 @@ BUILD_WRKSRC= ${WRKDIR}/aiccu/unix-console PORTDOCS= README -OPTIONS_DEFINE= GNUTLS LOG_DAEMON DOCS +OPTIONS_DEFINE= GNUTLS LOG_DAEMON DOCS NETGRAPH GNUTLS_DESC= Use gnutls to secure TIC supporting starttls LOG_DAEMON_DESC=Log to LOG_DAEMON instead to LOG_LOCAL7 +NETGRAPH_DESC= Use the ng_ayiya Netgraph node as an AYIYA implementation OPTIONS_DEFAULT+= GNUTLS @@ -39,6 +40,14 @@ LDFLAGS+= -lgnutls .endif +.if ${PORT_OPTIONS:MGNUTLS} +BUILD_DEPENDS+= ng_ayiya>=0:${PORTSDIR}/net/ng_ayiya +RUN_DEPENDS+= ng_ayiya>=0:${PORTSDIR}/net/ng_ayiya +EXTRA_PATCHES+= ${FILESDIR}/netgraph.patch +CFLAGS+= -DAICCU_NETGRAPH +LDFLAGS+= -lnetgraph +.endif + post-patch: @${REINPLACE_CMD} \ -e 's:verbose true:verbose false:' \ Added: soc2015/roam/ports/net/sixxs-aiccu/files/netgraph.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/roam/ports/net/sixxs-aiccu/files/netgraph.patch Sun Aug 2 22:51:58 2015 (r289127) @@ -0,0 +1,623 @@ +From ec5025bff45bf0f84317c31555fdf95a9a29ce17 Mon Sep 17 00:00:00 2001 +From: Peter Pentchev +Date: Fri, 31 Jul 2015 15:37:40 +0000 +Subject: [PATCH] Try to teach AICCU about ng_ayiya. + +TODO: Make it stop, i.e. get ng_ayiya to send a message down +the control hook upon receiving a "shutdown" message and get +AICCU to hear that message and, well, stop. +--- + common/aiccu.h | 1 + + common/aiccu_freebsd4.c | 8 ++ + common/aiccu_kame.c | 25 +++++++ + common/aiccu_netgraph.h | 20 +++++ + common/ayiya.c | 19 ++++- + common/common.c | 60 ++++++++++++--- + common/common.h | 2 +- + common/tic.c | 2 +- + common/tun.c | 190 ++++++++++++++++++++++++++++++++++++++++++++++++ + unix-console/Makefile | 5 ++ + unix-console/main.c | 5 ++ + 11 files changed, 323 insertions(+), 14 deletions(-) + create mode 100644 common/aiccu_netgraph.h + +diff --git common/aiccu.h common/aiccu.h +index ef65000..1c0c1f2 100755 +--- common/aiccu.h ++++ common/aiccu.h +@@ -19,6 +19,7 @@ + #include "heartbeat.h" + #include "ayiya.h" + #include "resolver.h" ++#include "aiccu_netgraph.h" + + #ifdef NEWSTUFF_TSP + #include "tsp.h" +diff --git common/aiccu_freebsd4.c common/aiccu_freebsd4.c +index 95a6554..c2e1cc2 100755 +--- common/aiccu_freebsd4.c ++++ common/aiccu_freebsd4.c +@@ -19,6 +19,9 @@ bool aiccu_os_install(void) + + bool aiccu_os_setup(struct TIC_Tunnel *hTunnel) + { ++#ifdef AICCU_NETGRAPH ++ do_log(LOG_ERR, "RDBG aiccu_os_setup(): configure the Netgraph node\n"); exit(42); ++#else + if (hTunnel->uses_tundev == 0) + { + /* Create the tunnel device */ +@@ -76,6 +79,7 @@ bool aiccu_os_setup(struct TIC_Tunnel *hTunnel) + } + + return true; ++#endif /* AICCU_NETGRAPH */ + } + + void aiccu_os_reconfig(struct TIC_Tunnel *hTunnel) +@@ -93,6 +97,9 @@ void aiccu_os_reconfig(struct TIC_Tunnel *hTunnel) + + void aiccu_os_delete(struct TIC_Tunnel *hTunnel) + { ++#ifdef AICCU_NETGRAPH ++ dolog(LOG_ERR, "RDBG FIXME: tear down the Netgraph structure\n"); exit(42); ++#else + hTunnel = hTunnel; + + /* Mark the interface down */ +@@ -107,5 +114,6 @@ void aiccu_os_delete(struct TIC_Tunnel *hTunnel) + "ifconfig %s destroy", + g_aiccu->ipv6_interface); + } ++#endif /* AICCU_NETGRAPH */ + } + +diff --git common/aiccu_kame.c common/aiccu_kame.c +index c6d1ea3..9d79282 100755 +--- common/aiccu_kame.c ++++ common/aiccu_kame.c +@@ -65,6 +65,24 @@ bool aiccu_os_setup(struct TIC_Tunnel *hTunnel) + hTunnel->sIPv6_POP); + } + ++#ifdef AICCU_NETGRAPH ++ if (NgSendMsg(ng_sock.cs, "c", NGM_AYIYA_COOKIE, NGM_AYIYA_CONFIGURE, ++ NULL, 0) == -1) ++ { ++ dolog(LOG_ERR, "Could not send the 'configure' message to the '%s' Netgraph node: %s (%d)\n", ++ ng_node_name, strerror(errno), errno); ++ return false; ++ } ++ int32_t resp; ++ if (!ng_get_msg_response("configure", &resp, sizeof(resp))) ++ return false; ++ if (resp != 0) { ++ dolog(LOG_ERR, "Could not complete the '%s' Netgraph's node configuration: %s (%d)\n", ++ ng_node_name, strerror(resp), resp); ++ return false; ++ } ++#endif ++ + return true; + } + +@@ -82,6 +100,7 @@ void aiccu_os_reconfig(struct TIC_Tunnel *hTunnel) + + void aiccu_os_delete(struct TIC_Tunnel *hTunnel) + { ++#ifndef AICCU_NETGRAPH + hTunnel = hTunnel; + aiccu_exec( + "ifconfig %s down", +@@ -93,5 +112,11 @@ void aiccu_os_delete(struct TIC_Tunnel *hTunnel) + "ifconfig %s deletetunnel", + g_aiccu->ipv6_interface); + } ++#else ++ (void)hTunnel; ++ if (!tun_ng_connect("stop", true)) ++ return; ++ tun_ng_shutdown("stop", true); ++#endif + } + +diff --git common/aiccu_netgraph.h common/aiccu_netgraph.h +new file mode 100644 +index 0000000..3e2291e +--- /dev/null ++++ common/aiccu_netgraph.h +@@ -0,0 +1,20 @@ ++#ifndef AICCU_NETGRAPH_H ++#define AICCU_NETGRAPH_H ++ ++#include ++#include ++ ++#include ++ ++struct ng_connection_sock { ++ int cs, ds; ++}; ++ ++extern struct ng_connection_sock ng_sock; ++extern char ng_node_name[NG_NODESIZ]; ++extern bool ng_connected; ++ ++bool tun_ng_connect(const char *what, bool disconnect); ++bool tun_ng_shutdown(const char *what, bool self); ++bool ng_get_msg_response(const char *what, void *buf, size_t size); ++#endif +diff --git common/ayiya.c common/ayiya.c +index f4ed0aa..4068d3e 100755 +--- common/ayiya.c ++++ common/ayiya.c +@@ -155,6 +155,9 @@ DWORD WINAPI ayiya_writer(LPVOID arg); + DWORD WINAPI ayiya_writer(LPVOID arg) + #endif + { ++#ifdef AICCU_NETGRAPH ++ /* Do nothing, really. Everything is handled by the Netgraph node. */ ++#else + unsigned char buf[2048]; + struct pseudo_ayh *s = (struct pseudo_ayh *)buf; + struct sockaddr_storage ci; +@@ -272,11 +275,15 @@ DWORD WINAPI ayiya_writer(LPVOID arg) + #else + return 0; + #endif ++#endif /* AICCU_NETGRAPH */ + } + + /* Construct a beat and send it outwards */ + void ayiya_beat(void) + { ++#ifdef AICCU_NETGRAPH ++ dolog(LOG_ERR, "RDBG FIXME: send a Netgraph heartbeat\n"); ++#else + SHA_CTX sha1; + sha1_byte hash[SHA1_DIGEST_LENGTH]; + struct sockaddr_in target; +@@ -340,6 +347,7 @@ void ayiya_beat(void) + { + ayiya_log(LOG_ERR, beat_name, NULL, 0, "Only %u of %u bytes sent to network: %s (%d)\n", lenout, n, strerror(errno), errno); + } ++#endif /* AICCU_NETGRAPH */ + } + + bool ayiya(struct TIC_Tunnel *hTunnel) +@@ -444,9 +452,18 @@ bool ayiya(struct TIC_Tunnel *hTunnel) + SHA1_Init(&sha1); + SHA1_Update(&sha1, (const sha1_byte *)hTunnel->sPassword, (unsigned int)strlen(hTunnel->sPassword)); + SHA1_Final(ayiya_hash, &sha1); ++#ifdef AICCU_NETGRAPH ++ if (NgSendMsg(ng_sock.cs, "c", NGM_AYIYA_COOKIE, NGM_AYIYA_SECRETHASH, ++ ayiya_hash, sizeof(ayiya_hash)) == -1) ++ { ++ dolog(LOG_ERR, "Could not send the secret hash to the Netgraph node: %s (%d)\n", ++ strerror(errno), errno); ++ return false; ++ } ++#endif + + /* Setup listening socket */ +- ayiya_socket = connect_client(hTunnel->sIPv4_POP , AYIYA_PORT, AF_INET, SOCK_DGRAM); ++ ayiya_socket = connect_client(hTunnel->sIPv4_POP , AYIYA_PORT, AF_INET, SOCK_DGRAM, true); + if (!ayiya_socket) + { + ayiya_log(LOG_ERR, "start", NULL, 0, "Connection error:: could not create connection to AYIYA server\n"); +diff --git common/common.c common/common.c +index 488c145..d3216b8 100755 +--- common/common.c ++++ common/common.c +@@ -340,13 +340,20 @@ void sock_free(TLSSOCKET sock) + } + + /* Connect this client to a server */ +-TLSSOCKET connect_client(const char *hostname, const char *service, int family, int socktype) ++TLSSOCKET connect_client(const char *hostname, const char *service, int family, int socktype, bool ng_ayiya) + { +- TLSSOCKET sock; + struct addrinfo hints, *res, *ressave; ++ TLSSOCKET sock; + +- sock = sock_alloc(); +- if (!sock) return NULL; ++#ifndef AICCU_NETGRAPH ++ ng_ayiya = false; ++#endif ++ ++ if (!ng_ayiya) ++ { ++ sock = sock_alloc(); ++ if (!sock) return NULL; ++ } + + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = family; +@@ -355,28 +362,59 @@ TLSSOCKET connect_client(const char *hostname, const char *service, int family, + if (getaddrinfo(hostname, service, &hints, &res) != 0) + { + dolog(LOG_ERR, "Couldn't resolve host %s, service %s\n", hostname, service); +- sock_free(sock); ++ if (!ng_ayiya) ++ sock_free(sock); + return NULL; + } + + ressave = res; + ++ int s = -1; + while (res) + { +- sock->socket = socket(res->ai_family, res->ai_socktype, res->ai_protocol); +- if (sock->socket == -1) continue; +- if (connect(sock->socket, res->ai_addr, (unsigned int)res->ai_addrlen) == 0) break; +- closesocket(sock->socket); +- sock->socket = -1; ++ if (!ng_ayiya) ++ { ++ s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); ++ } else { ++ struct ngm_mkpeer m = { ++ .type = "ksocket", ++ .ourhook = "ayiya", ++ }; ++ snprintf(m.peerhook, sizeof(m.peerhook), "%d/%d/%d", ++ res->ai_family, res->ai_socktype, res->ai_protocol); ++ s = NgSendMsg(ng_sock.cs, "c", NGM_GENERIC_COOKIE, NGM_MKPEER, ++ &m, sizeof(m)); ++ } ++ if (s == -1) continue; ++ ++ int r; ++ if (!ng_ayiya) ++ r = connect(s, res->ai_addr, (unsigned int)res->ai_addrlen); ++ else ++ r = NgSendMsg(ng_sock.cs, "c.ayiya", NGM_KSOCKET_COOKIE, ++ NGM_KSOCKET_CONNECT, res->ai_addr, res->ai_addrlen) == -1; ++ if (r == 0) break; ++ if (!ng_ayiya) ++ closesocket(s); ++ else if (NgSendMsg(ng_sock.cs, "c.ayiya", NGM_GENERIC_COOKIE, ++ NGM_SHUTDOWN, NULL, 0) == -1) ++ dolog(LOG_ERR, "Could not shut down the ksocket node: %s (%d)\n", ++ ng_node_name, strerror(errno), errno); ++ s = -1; + res = res->ai_next; + } + + freeaddrinfo(ressave); + +- if (sock->socket == -1) ++ if (ng_ayiya) ++ return (TLSSOCKET)(s != -1); ++ ++ if (s == -1) + { + sock_free(sock); + sock = NULL; ++ } else { ++ sock->socket = s; + } + + return sock; +diff --git common/common.h common/common.h +index 575d854..6982331 100755 +--- common/common.h ++++ common/common.h +@@ -398,7 +398,7 @@ void vsyslog(int priority, const char *format, va_list ap); + /* Networking functions */ + void sock_printf(TLSSOCKET sock, const char *fmt, ...); + int sock_getline(TLSSOCKET sock, char *rbuf, unsigned int rbuflen, unsigned int *filled, char *ubuf, unsigned int ubuflen); +-TLSSOCKET connect_client(const char *hostname, const char *service, int family, int socktype); ++TLSSOCKET connect_client(const char *hostname, const char *service, int family, int socktype, bool ng_ayiya); + TLSSOCKET listen_server(const char *description, const char *hostname, const char *service, int family, int socktype); + void sock_free(TLSSOCKET sock); + #ifdef AICCU_GNUTLS +diff --git common/tic.c common/tic.c +index e0d70fe..8292a0a 100755 +--- common/tic.c ++++ common/tic.c +@@ -76,7 +76,7 @@ bool tic_Login(struct TIC_conf *tic, const char *username, const char *password, + D(dolog(LOG_DEBUG, "Trying to connect to TIC server %s\n", server)); + + /* Connect to the TIC server */ +- tic->sock = connect_client(server, TIC_PORT, AF_INET, SOCK_STREAM); ++ tic->sock = connect_client(server, TIC_PORT, AF_INET, SOCK_STREAM, false); + if (!tic->sock) + { + dolog(LOG_ERR, "Couldn't connect to the TIC server %s\n", server); +diff --git common/tun.c common/tun.c +index c5b6323..b4fa558 100755 +--- common/tun.c ++++ common/tun.c +@@ -48,6 +48,11 @@ struct ether_header + + #endif + ++#ifdef AICCU_NETGRAPH ++struct ng_connection_sock ng_sock = { .cs = -1, .ds = -1 }; ++char ng_node_name[NG_NODESIZ]; ++#endif ++ + void tun_log(int level, const char *what, const char *fmt, ...); + void tun_log(int level, const char *what, const char *fmt, ...) + { +@@ -68,8 +73,10 @@ void tun_log(int level, const char *what, const char *fmt, ...) + dolog(level, buf); + } + ++#ifndef AICCU_NETGRAPH + static const char reader_name[] = "tundev->tun"; + static const char writer_name[] = "tun->tundev"; ++#endif + + #ifdef _WIN32 + /* Windows doesn't have writev() but does have WSASend */ +@@ -148,6 +155,10 @@ DWORD WINAPI tun_reader(LPVOID arg); + DWORD WINAPI tun_reader(LPVOID arg) + #endif + { ++#ifdef AICCU_NETGRAPH ++ /* Nothing to do; the Netgraph node handles everything. */ ++ (void)arg; ++#else + unsigned char buf[2048]; + + /* The function that actually does something with the buffer */ +@@ -269,6 +280,7 @@ DWORD WINAPI tun_reader(LPVOID arg) + tun->function((char *)&buf[sizeof(struct ether)], (unsigned int)lenin - sizeof(struct ether)); + #endif + } ++#endif /* AICCU_NETGRAPH */ + + D(dolog(LOG_DEBUG, "TUN Reader stopping\n")); + #ifndef _WIN32 +@@ -278,6 +290,7 @@ DWORD WINAPI tun_reader(LPVOID arg) + #endif + } + ++#ifndef AICCU_NETGRAPH + /* Socket -> Tun */ + void tun_write(char *buf, unsigned int length) + { +@@ -357,6 +370,7 @@ void tun_write(char *buf, unsigned int length) + } + #endif + } ++#endif + + #ifdef _WIN32 + +@@ -687,6 +701,105 @@ bool tun_fixup_adapters(void) + + #endif + ++#ifdef AICCU_NETGRAPH ++static void ++tun_ng_disconnect(void) ++{ ++ close(ng_sock.ds); ++ ng_sock.ds = -1; ++ close(ng_sock.cs); ++ ng_sock.cs = -1; ++} ++ ++bool ++tun_ng_connect(const char *what, bool disconnect) ++{ ++ if (ng_sock.cs != -1 || ng_sock.ds != -1) ++ { ++ if (disconnect) ++ { ++ tun_ng_disconnect(); ++ } else { ++ tun_log(LOG_ERR, what, "The Netgraph socket seems to be already initialized\n"); ++ return false; ++ } ++ } ++ if (ng_node_name[0] == '\0') ++ { ++ tun_log(LOG_ERR, what, "Internal error: the Netgraph node name has not been initialized\n"); ++ return false; ++ } ++ ++ char name[NG_NODESIZ]; ++ snprintf(name, sizeof(name), "%s_%s_%ld", ++ ng_node_name, what, (long)getpid()); ++ if (NgMkSockNode(name, &ng_sock.cs, &ng_sock.ds) == -1) ++ { ++ tun_log(LOG_ERR, what, "Could not create the Netgraph socket node: %s (%d)\n", ++ strerror(errno), errno); ++ return false; ++ } ++ return true; ++} ++ ++static bool ++tun_ng_shutdown_node(const char *what, const char *hook) ++{ ++ char path[NG_PATHSIZ]; ++ ++ snprintf(path, sizeof(path), "%s:%s", ng_node_name, hook); ++ if (NgSendMsg(ng_sock.cs, path, NGM_GENERIC_COOKIE, NGM_SHUTDOWN, ++ NULL, 0) == -1 && errno != ENOENT) ++ { ++ tun_log(LOG_ERR, what, "Could not shut down the %s Netgraph node: %s (%d)\n", ++ path, strerror(errno), errno); ++ return false; ++ } ++ return true; ++} ++ ++bool ++tun_ng_shutdown(const char *what, bool self) ++{ ++ if (!tun_ng_shutdown_node(what, "ayiya") || ++ !tun_ng_shutdown_node(what, "inet6") || ++ self && !tun_ng_shutdown_node(what, "")) ++ return false; ++ ++ if (self) ++ tun_ng_disconnect(); ++ return true; ++} ++ ++bool ++ng_get_msg_response(const char *what, void *buf, size_t size) ++{ ++ static char ng_path[NG_PATHSIZ]; ++ static struct { ++ struct ng_mesg msg; ++ char data[8192]; ++ } __attribute__((packed)) ng_buf; ++ ++ int len = NgRecvMsg(ng_sock.cs, &ng_buf.msg, sizeof(ng_buf), ng_path); ++ size_t expected = sizeof(ng_buf.msg) + size; ++ if (len < 0) ++ { ++ dolog(LOG_ERR, "Could not get the %s Netgraph response: %s (%d)\n", ++ what, strerror(errno), errno); ++ return false; ++ } ++ else if ((size_t)len < expected) ++ { ++ dolog(LOG_ERR, "Received a short %s Netgraph response (%d out of %u bytes)\n", ++ what, len, errno); ++ return false; ++ } ++ len -= sizeof(ng_buf.msg); ++ memcpy(buf, ng_buf.data, size); ++ return true; ++} ++#endif ++ + bool tun_start(struct tun_reader *tun) + { + #ifndef _WIN32 +@@ -716,6 +829,82 @@ bool tun_start(struct tun_reader *tun) + } + + #else /* *BSD/Darwin */ ++#ifdef AICCU_NETGRAPH ++ if (!tun_ng_connect("start", false)) ++ return false; ++ ++ struct ngm_connect c = { ++ .ourhook = "c", ++ .peerhook = "control", ++ }; ++ snprintf(c.path, sizeof(c.path), "%s:", ng_node_name); ++ if (NgSendMsg(ng_sock.cs, ".", NGM_GENERIC_COOKIE, NGM_CONNECT, ++ &c, sizeof(c)) == -1) { ++ if (errno == ENOENT) { ++ tun_log(LOG_DEBUG, "start", "About to create the '%s' Netgraph node\n", ++ ng_node_name); ++ struct ngm_mkpeer m = { ++ .type = "ayiya", ++ .ourhook = "c", ++ .peerhook = "control", ++ }; ++ if (NgSendMsg(ng_sock.cs, ".", NGM_GENERIC_COOKIE, ++ NGM_MKPEER, &m, sizeof(m)) == -1) ++ { ++ tun_log(LOG_ERR, "start", "Could not create a '%s' Netgraph node: %s (%s)\n", ++ m.type, strerror(errno), errno); ++ return false; ++ } ++ ++ if (NgNameNode(ng_sock.cs, "c", "%s", ng_node_name) == -1) ++ { ++ tun_log(LOG_ERR, "start", "Could not set the Netgraph node's name to '%s': %s (%d)\n", ++ ng_node_name, strerror(errno), errno); ++ return false; ++ } ++ } else if (errno == EEXIST) { ++ tun_log(LOG_ERR, "start", "Something is already connected to the '%s' Netgraph node's '%s' hook\n", ++ ng_node_name, c.peerhook); ++ return false; ++ } else { ++ tun_log(LOG_ERR, "start", "Could not connect to the '%s' hook of the '%s' Netgraph node: %s (%d)\n", ++ c.peerhook, ng_node_name, strerror(errno), errno); ++ return false; ++ } ++ } else { ++ tun_log(LOG_DEBUG, "start", "Connected to the %s Netgraph node\n", ++ ng_node_name); ++ } ++ ++ if (!tun_ng_shutdown("start", false)) ++ return false; ++ ++ struct ngm_mkpeer m = { ++ .type = "iface", ++ .ourhook = "inet6", ++ .peerhook = "inet6", ++ }; ++ if (NgSendMsg(ng_sock.cs, "c", NGM_GENERIC_COOKIE, NGM_MKPEER, ++ &m, sizeof(m)) == -1) ++ { ++ tun_log(LOG_ERR, "start", "Could not create a '%s' Netgraph node: %s (%s)\n", ++ m.type, strerror(errno), errno); ++ return false; ++ } ++ if (NgSendMsg(ng_sock.cs, "c.inet6", NGM_GENERIC_COOKIE, NGM_NODEINFO, ++ NULL, 0) == -1) ++ { ++ tun_log(LOG_ERR, "start", "Could not query the '%s' Netgraph node's name: %s (%d)\n", ++ m.type, strerror(errno), errno); ++ return false; ++ } ++ struct nodeinfo inf; ++ if (!ng_get_msg_response("nodeinfo", &inf, sizeof(inf))) ++ return false; ++ tun_log(LOG_DEBUG, "start", "Got Netgraph interface node info: name '%s' type '%s' id '%lld' hooks %u\n", inf.name, inf.type, (long long)inf.id, inf.hooks); ++ if (g_aiccu->ipv6_interface) free(g_aiccu->ipv6_interface); ++ g_aiccu->ipv6_interface = strdup(inf.name); ++#else + + char buf[128]; + unsigned int i; +@@ -781,6 +970,7 @@ bool tun_start(struct tun_reader *tun) + } + #endif + ++#endif /* AICCU_NETGRAPH */ + #endif /* linux */ + + +diff --git unix-console/Makefile unix-console/Makefile +index d5e5c07..a661111 100755 +--- unix-console/Makefile ++++ unix-console/Makefile +@@ -34,6 +34,11 @@ ifeq ($(shell echo $(CFLAGS) | grep -c "\-O"),0) + CFLAGS += -O3 + endif + ++# Link with the Netgraph library if needed ++ifneq ($(shell echo $(CFLAGS) | grep -c "\-DAICCU_NETGRAPH"),0) ++LDFLAGS += -lnetgraph ++endif ++ + # This is a console client + CFLAGS += -D AICCU_CONSOLE + +diff --git unix-console/main.c unix-console/main.c +index 8a4d9a9..527868f 100755 +--- unix-console/main.c ++++ unix-console/main.c +@@ -348,6 +348,11 @@ int main(int argc, char *argv[]) + tic_Logout(g_aiccu->tic, NULL); + g_aiccu->tic = NULL; + ++#ifdef AICCU_NETGRAPH ++ snprintf(ng_node_name, sizeof(ng_node_name), "aiccu_%s", hTunnel->sId); ++ dolog(LOG_DEBUG, "Using Netgraph node name %s\n", ng_node_name); ++#endif ++ + if (g_aiccu->verbose) + { + printf("Tunnel Information for %s:\n",hTunnel->sId); +-- +2.4.6 + From owner-svn-soc-all@freebsd.org Sun Aug 2 23:17:03 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8B7E89B1ED7 for ; Sun, 2 Aug 2015 23:17:03 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7BFF9BF3 for ; Sun, 2 Aug 2015 23:17:03 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t72NH3w7024057 for ; Sun, 2 Aug 2015 23:17:03 GMT (envelope-from clord@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t72NH21L024052 for svn-soc-all@FreeBSD.org; Sun, 2 Aug 2015 23:17:02 GMT (envelope-from clord@FreeBSD.org) Date: Sun, 2 Aug 2015 23:17:02 GMT Message-Id: <201508022317.t72NH21L024052@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to clord@FreeBSD.org using -f From: clord@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289128 - in soc2015/clord/head/sys: boot/ficl contrib/ficl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 23:17:03 -0000 Author: clord Date: Sun Aug 2 23:17:01 2015 New Revision: 289128 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289128 Log: Only include extras.c in build if target is testmain. Previously the functions in extras.c were provided in testmain.c, but in Ficl 4 that is no longer the case, and they should not be needed for anything except testmain. Modified: soc2015/clord/head/sys/boot/ficl/Makefile soc2015/clord/head/sys/contrib/ficl/compatibility.c soc2015/clord/head/sys/contrib/ficl/extras.c Modified: soc2015/clord/head/sys/boot/ficl/Makefile ============================================================================== --- soc2015/clord/head/sys/boot/ficl/Makefile Sun Aug 2 22:51:58 2015 (r289127) +++ soc2015/clord/head/sys/boot/ficl/Makefile Sun Aug 2 23:17:01 2015 (r289128) @@ -11,9 +11,9 @@ .PATH: ${FICLDIR}/${MACHINE_CPUARCH} .endif .PATH: ${FICLDIR}/ficlplatform -BASE_SRCS= bit.c callback.c compatibility.c dictionary.c double.c extras.c \ - fileaccess.c float.c hash.c loader.c lzuncompress.c prefix.c \ - primitives.c search.c stack.c system.c tools.c unix.c utility.c vm.c word.c +BASE_SRCS= bit.c callback.c compatibility.c dictionary.c double.c fileaccess.c \ + float.c hash.c loader.c lzuncompress.c prefix.c primitives.c search.c \ + stack.c system.c tools.c unix.c utility.c vm.c word.c SRCS= ${BASE_SRCS} sysdep.c softcore.c CLEANFILES= softcore.c main main.o @@ -43,7 +43,7 @@ .endif .ifmake testmain CFLAGS+= -DTESTMAIN -D_TESTMAIN -SRCS+= main.c +SRCS+= main.c extras.c PROG= testmain .include .else Modified: soc2015/clord/head/sys/contrib/ficl/compatibility.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/compatibility.c Sun Aug 2 22:51:58 2015 (r289127) +++ soc2015/clord/head/sys/contrib/ficl/compatibility.c Sun Aug 2 23:17:01 2015 (r289128) @@ -278,6 +278,8 @@ FICL_PLATFORM_EXTERN int isAFiclWord(ficlDictionary *dictionary, ficlWord *word) { return ficlDictionaryIsAWord(dictionary, word); } +#ifdef TESTMAIN FICL_PLATFORM_EXTERN void buildTestInterface(ficlSystem *system) { ficlSystemCompileExtras(system); } +#endif Modified: soc2015/clord/head/sys/contrib/ficl/extras.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/extras.c Sun Aug 2 22:51:58 2015 (r289127) +++ soc2015/clord/head/sys/contrib/ficl/extras.c Sun Aug 2 23:17:01 2015 (r289128) @@ -1,10 +1,14 @@ /* $FreeBSD$ */ +#ifdef TESTMAIN #include #include +#include +#else +#include +#endif #include #include -#include #include "ficl.h" @@ -12,7 +16,7 @@ #ifndef FICL_ANSI /* -** Ficl interface to _getcwd (Win32) +** Ficl interface to getcwd ** Prints the current working directory using the VM's ** textOut method... */ @@ -30,9 +34,9 @@ /* -** Ficl interface to _chdir (Win32) +** Ficl interface to chdir ** Gets a newline (or NULL) delimited string from the input -** and feeds it to the Win32 chdir function... +** and feeds it to chdir() ** Example: ** cd c:\tmp */ @@ -73,7 +77,7 @@ ** Gets a newline (or NULL) delimited string from the input ** and feeds it to the ANSI system function... ** Example: -** system del *.* +** system rm -rf / ** \ ouch! */ static void ficlPrimitiveSystem(ficlVm *vm) From owner-svn-soc-all@freebsd.org Mon Aug 3 00:35:42 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D1B219AF04B for ; Mon, 3 Aug 2015 00:35:42 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A8B459DE for ; Mon, 3 Aug 2015 00:35:42 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t730Zgtu061187 for ; Mon, 3 Aug 2015 00:35:42 GMT (envelope-from clord@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t730ZfaO061145 for svn-soc-all@FreeBSD.org; Mon, 3 Aug 2015 00:35:41 GMT (envelope-from clord@FreeBSD.org) Date: Mon, 3 Aug 2015 00:35:41 GMT Message-Id: <201508030035.t730ZfaO061145@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to clord@FreeBSD.org using -f From: clord@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289129 - soc2015/clord/head/sys/contrib/ficl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 00:35:42 -0000 Author: clord Date: Mon Aug 3 00:35:41 2015 New Revision: 289129 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289129 Log: Remove dependence on sscanf so that libstand can be used in place of stdlib. Modified: soc2015/clord/head/sys/contrib/ficl/ficl.h soc2015/clord/head/sys/contrib/ficl/system.c Modified: soc2015/clord/head/sys/contrib/ficl/ficl.h ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/ficl.h Sun Aug 2 23:17:01 2015 (r289128) +++ soc2015/clord/head/sys/contrib/ficl/ficl.h Mon Aug 3 00:35:41 2015 (r289129) @@ -635,7 +635,9 @@ /* ** the Good Stuff starts here... */ -#define FICL_VERSION "4.1.0" +#define FICL_VERSION "4.1.0" +#define FICL_VERSION_MAJOR 4 +#define FICL_VERSION_MINOR 1 #if !defined (FICL_PROMPT) #define FICL_PROMPT "ok> " Modified: soc2015/clord/head/sys/contrib/ficl/system.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/system.c Sun Aug 2 23:17:01 2015 (r289128) +++ soc2015/clord/head/sys/contrib/ficl/system.c Mon Aug 3 00:35:41 2015 (r289129) @@ -81,20 +81,15 @@ ficlSystem *ficlSystemGlobal = NULL; -int sscanf(const char * restrict str, const char * restrict format, ...); - /************************************************************************** f i c l S e t V e r s i o n E n v ** Create a double ficlCell environment constant for the version ID **************************************************************************/ static void ficlSystemSetVersion(ficlSystem *system) { - int major = 0; - int minor = 0; ficl2Integer combined; ficlDictionary *environment = ficlSystemGetEnvironment(system); - sscanf(FICL_VERSION, "%d.%d", &major, &minor); - FICL_2INTEGER_SET(major, minor, combined); + FICL_2INTEGER_SET(FICL_VERSION_MAJOR, FICL_VERSION_MINOR, combined); ficlDictionarySet2Constant(environment, "ficl-version", combined); ficlDictionarySetConstant(environment, "ficl-robust", FICL_ROBUST); return; From owner-svn-soc-all@freebsd.org Mon Aug 3 00:37:46 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 291A29AF075 for ; Mon, 3 Aug 2015 00:37:46 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F0199A02 for ; Mon, 3 Aug 2015 00:37:45 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t730bj2p063290 for ; Mon, 3 Aug 2015 00:37:45 GMT (envelope-from clord@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t730bhth063241 for svn-soc-all@FreeBSD.org; Mon, 3 Aug 2015 00:37:43 GMT (envelope-from clord@FreeBSD.org) Date: Mon, 3 Aug 2015 00:37:43 GMT Message-Id: <201508030037.t730bhth063241@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to clord@FreeBSD.org using -f From: clord@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289130 - soc2015/clord/head/sys/contrib/ficl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 00:37:46 -0000 Author: clord Date: Mon Aug 3 00:37:43 2015 New Revision: 289130 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289130 Log: Fix remaining files to only include standard library headers if target is testmain, otherwise they will rely on libstand. Modified: soc2015/clord/head/sys/contrib/ficl/dictionary.c soc2015/clord/head/sys/contrib/ficl/hash.c soc2015/clord/head/sys/contrib/ficl/primitives.c soc2015/clord/head/sys/contrib/ficl/utility.c Modified: soc2015/clord/head/sys/contrib/ficl/dictionary.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/dictionary.c Mon Aug 3 00:35:41 2015 (r289129) +++ soc2015/clord/head/sys/contrib/ficl/dictionary.c Mon Aug 3 00:37:43 2015 (r289130) @@ -53,9 +53,13 @@ /* $FreeBSD$ */ +#ifdef TESTMAIN #include #include #include +#else +#include +#endif #include #include "ficl.h" Modified: soc2015/clord/head/sys/contrib/ficl/hash.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/hash.c Mon Aug 3 00:35:41 2015 (r289129) +++ soc2015/clord/head/sys/contrib/ficl/hash.c Mon Aug 3 00:37:43 2015 (r289130) @@ -1,6 +1,10 @@ /* $FreeBSD$ */ +#ifdef TESTMAIN #include +#else +#include +#endif #include "ficl.h" Modified: soc2015/clord/head/sys/contrib/ficl/primitives.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/primitives.c Mon Aug 3 00:35:41 2015 (r289129) +++ soc2015/clord/head/sys/contrib/ficl/primitives.c Mon Aug 3 00:37:43 2015 (r289130) @@ -43,10 +43,14 @@ /* $FreeBSD$ */ +#ifdef TESTMAIN #include #include -#include #include +#else +#include +#endif +#include #include "ficl.h" Modified: soc2015/clord/head/sys/contrib/ficl/utility.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/utility.c Mon Aug 3 00:35:41 2015 (r289129) +++ soc2015/clord/head/sys/contrib/ficl/utility.c Mon Aug 3 00:37:43 2015 (r289130) @@ -1,6 +1,10 @@ /* $FreeBSD$ */ +#ifdef TESTMAIN #include +#else +#include +#endif #include "ficl.h" From owner-svn-soc-all@freebsd.org Mon Aug 3 20:15:13 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 063B39B274C for ; Mon, 3 Aug 2015 20:15:13 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EADD6D7E for ; Mon, 3 Aug 2015 20:15:12 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t73KFCTv092448 for ; Mon, 3 Aug 2015 20:15:12 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t73KFC59092417 for svn-soc-all@FreeBSD.org; Mon, 3 Aug 2015 20:15:12 GMT (envelope-from iateaca@FreeBSD.org) Date: Mon, 3 Aug 2015 20:15:12 GMT Message-Id: <201508032015.t73KFC59092417@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iateaca@FreeBSD.org using -f From: iateaca@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289172 - soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 20:15:13 -0000 Author: iateaca Date: Mon Aug 3 20:15:11 2015 New Revision: 289172 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289172 Log: accept the frames in the Promiscuous mode for the destination addresses that do not match the station's address Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c ============================================================================== --- soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Mon Aug 3 19:15:19 2015 (r289171) +++ soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Mon Aug 3 20:15:11 2015 (r289172) @@ -472,6 +472,13 @@ } } + /* + * if the physical destination address does not match the station's + * address, accept the frame only in the Promiscuous Physical mode + */ + if (rcr & ED_RCR_PRO) + return 1; + return 0; } From owner-svn-soc-all@freebsd.org Tue Aug 4 09:17:01 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE2F99B36DC for ; Tue, 4 Aug 2015 09:17:01 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB867B1F for ; Tue, 4 Aug 2015 09:17:01 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t749H1RO041719 for ; Tue, 4 Aug 2015 09:17:01 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t749H1E8041717 for svn-soc-all@FreeBSD.org; Tue, 4 Aug 2015 09:17:01 GMT (envelope-from kczekirda@FreeBSD.org) Date: Tue, 4 Aug 2015 09:17:01 GMT Message-Id: <201508040917.t749H1E8041717@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289200 - soc2015/kczekirda/www MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 09:17:02 -0000 Author: kczekirda Date: Tue Aug 4 09:17:00 2015 New Revision: 289200 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289200 Log: fix typo Modified: soc2015/kczekirda/www/menu.py Modified: soc2015/kczekirda/www/menu.py ============================================================================== --- soc2015/kczekirda/www/menu.py Tue Aug 4 08:51:56 2015 (r289199) +++ soc2015/kczekirda/www/menu.py Tue Aug 4 09:17:00 2015 (r289200) @@ -1,4 +1,4 @@ -#1/usr/local/bin/python +#!/usr/local/bin/python import sqlite3, os from bottle import route, run, redirect, template, static_file, request From owner-svn-soc-all@freebsd.org Tue Aug 4 10:20:11 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9AF39B13C0 for ; Tue, 4 Aug 2015 10:20:11 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE60AC95 for ; Tue, 4 Aug 2015 10:20:11 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t74AKBHe043409 for ; Tue, 4 Aug 2015 10:20:11 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t74AK9kY043393 for svn-soc-all@FreeBSD.org; Tue, 4 Aug 2015 10:20:09 GMT (envelope-from kczekirda@FreeBSD.org) Date: Tue, 4 Aug 2015 10:20:09 GMT Message-Id: <201508041020.t74AK9kY043393@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289202 - in soc2015/kczekirda/www: . tpl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 10:20:11 -0000 Author: kczekirda Date: Tue Aug 4 10:20:09 2015 New Revision: 289202 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289202 Log: task management init Added: soc2015/kczekirda/www/tpl/add_task.tpl soc2015/kczekirda/www/tpl/delete_task.tpl Modified: soc2015/kczekirda/www/menu.py soc2015/kczekirda/www/tpl/main.tpl Modified: soc2015/kczekirda/www/menu.py ============================================================================== --- soc2015/kczekirda/www/menu.py Tue Aug 4 09:45:10 2015 (r289201) +++ soc2015/kczekirda/www/menu.py Tue Aug 4 10:20:09 2015 (r289202) @@ -6,8 +6,10 @@ database = 'cluster.sqlite' main_tpl = 'tpl/main.tpl' add_node_tpl = 'tpl/add_node.tpl' +add_task_tpl = 'tpl/add_task.tpl' edit_node_tpl = 'tpl/edit_node.tpl' delete_node_tpl = 'tpl/delete_node.tpl' +delete_task_tpl = 'tpl/delete_task.tpl' default = 'menu.ipxe' @route('/static/:path#.+#', name='static') @@ -24,13 +26,16 @@ conn = sqlite3.connect(database) c = conn.cursor() c.execute("SELECT * FROM nodes") - result = c.fetchall() + result_nodes = c.fetchall() + c.execute("SELECT * FROM tasks") + result_tasks = c.fetchall() c.close - output = template(main_tpl,rows=result) + output = template(main_tpl,rows_nodes=result_nodes,rows_tasks=result_tasks) return output else: conn = sqlite3.connect(database) conn.execute("CREATE TABLE nodes (id INTEGER PRIMARY KEY, host char(254) NOT NULL, mac char(20) NOT NULL, ip char(20) NOT NULL, boot char(50) NOT NULL)") + conn.execute("CREATE TABLE tasks (id INTEGER PRIMARY KEY, revision char(20) NOT NULL, host char(254), status char(20))") conn.commit() return redirect('/admin') @@ -87,6 +92,30 @@ return redirect('/admin') else: return template(add_node_tpl) + +@route('/admin/add_task', method='GET') +def add(): + if request.GET.get('add','').strip(): + revision = request.GET.get('revision','').strip() + conn = sqlite3.connect(database) + c = conn.cursor() + c.execute("INSERT INTO tasks (revision) VALUES (?)", (revision,)) + conn.commit() + c.close() + return redirect('/admin') + else: + return template(add_task_tpl) + +@route('/admin/delete_task/:revision', method='GET') +def delete(revision): + if request.GET.get('delete','').strip(): + conn = sqlite3.connect(database) + c = conn.cursor() + c.execute("DELETE FROM tasks WHERE revision LIKE '%s'" %revision) + conn.commit() + return redirect('/admin') + else: + return template(delete_task_tpl,revision=revision) @route('/menu/:mac', method='GET') def static(mac): Added: soc2015/kczekirda/www/tpl/add_task.tpl ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/kczekirda/www/tpl/add_task.tpl Tue Aug 4 10:20:09 2015 (r289202) @@ -0,0 +1,12 @@ + + + +Testing cluster management +
+

Add new task

+
+

revision

+

+
+

Back

+
Added: soc2015/kczekirda/www/tpl/delete_task.tpl ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/kczekirda/www/tpl/delete_task.tpl Tue Aug 4 10:20:09 2015 (r289202) @@ -0,0 +1,11 @@ + + + +Testing cluster management +
+

Delete task {{revision}}

+
+ +
+

Back

+
Modified: soc2015/kczekirda/www/tpl/main.tpl ============================================================================== --- soc2015/kczekirda/www/tpl/main.tpl Tue Aug 4 09:45:10 2015 (r289201) +++ soc2015/kczekirda/www/tpl/main.tpl Tue Aug 4 10:20:09 2015 (r289202) @@ -3,10 +3,10 @@ Testing cluster management
-

Nodes

+ -%for row in rows: +%for row in rows_nodes: %id = row[0] %host = row[1] %mac = row[2] @@ -22,6 +22,22 @@ %end + + + +%for row in rows_tasks: + %id = row[0] + %revision = row[1] + %host = row[2] + %status = row[3] + + + + + + + +%end +

Nodes

IDhostmac addressip addressboot
Delete
Add node

Tasks

IDrevisionhoststatus
{{id}}{{revision}}{{host}}{{status}}Delete
Add task
-

Add node

From owner-svn-soc-all@freebsd.org Tue Aug 4 15:06:08 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B9569B3334 for ; Tue, 4 Aug 2015 15:06:08 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C8E3F39 for ; Tue, 4 Aug 2015 15:06:08 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t74F68TW055185 for ; Tue, 4 Aug 2015 15:06:08 GMT (envelope-from stefano@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t74F67Ge054241 for svn-soc-all@FreeBSD.org; Tue, 4 Aug 2015 15:06:07 GMT (envelope-from stefano@FreeBSD.org) Date: Tue, 4 Aug 2015 15:06:07 GMT Message-Id: <201508041506.t74F67Ge054241@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to stefano@FreeBSD.org using -f From: stefano@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289210 - soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 15:06:08 -0000 Author: stefano Date: Tue Aug 4 15:06:06 2015 New Revision: 289210 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289210 Log: [libvmmapi] add new API to get vm fd (vm_get_fd()) Modified: soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.c soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.h Modified: soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.c Tue Aug 4 14:27:25 2015 (r289209) +++ soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.c Tue Aug 4 15:06:06 2015 (r289210) @@ -685,6 +685,12 @@ } int +vm_get_fd(struct vmctx *ctx) +{ + return (ctx->fd); +} + +int vm_map_user_buf(struct vmctx *ctx, vm_paddr_t gpa, size_t len, void *host_buf) { struct vm_user_buf user_buf; Modified: soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.h Tue Aug 4 14:27:25 2015 (r289209) +++ soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.h Tue Aug 4 15:06:06 2015 (r289210) @@ -108,6 +108,7 @@ int vm_get_intinfo(struct vmctx *ctx, int vcpu, uint64_t *i1, uint64_t *i2); int vm_set_intinfo(struct vmctx *ctx, int vcpu, uint64_t exit_intinfo); +int vm_get_fd(struct vmctx *ctx); int vm_map_user_buf(struct vmctx *ctx, vm_paddr_t gpa, size_t len, void *host_buf); /* From owner-svn-soc-all@freebsd.org Tue Aug 4 15:11:40 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73B869B3441 for ; Tue, 4 Aug 2015 15:11:40 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5EA8E11CB for ; Tue, 4 Aug 2015 15:11:40 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t74FBejd050982 for ; Tue, 4 Aug 2015 15:11:40 GMT (envelope-from stefano@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t74FBam3050244 for svn-soc-all@FreeBSD.org; Tue, 4 Aug 2015 15:11:36 GMT (envelope-from stefano@FreeBSD.org) Date: Tue, 4 Aug 2015 15:11:36 GMT Message-Id: <201508041511.t74FBam3050244@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to stefano@FreeBSD.org using -f From: stefano@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289211 - in soc2015/stefano/ptnetmap/stable/10: lib/libvmmapi sys/amd64/include sys/amd64/vmm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 15:11:40 -0000 Author: stefano Date: Tue Aug 4 15:11:36 2015 New Revision: 289211 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289211 Log: [vmm.ko] add new IOCTL (VM_IO_REG_HANDLER to catch write/read on specific I/O address and send notification. For now I've implemented only 1 type of handler (VM_IO_REGH_KWEVENTS) to use events in the kernel through wakeup() and tsleep()/msleep(), but I wrote the code to be easily extended to support other type of handler (cond_signal, write/ioctl on fd, etc). Modified: soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.c soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.h soc2015/stefano/ptnetmap/stable/10/sys/amd64/include/vmm.h soc2015/stefano/ptnetmap/stable/10/sys/amd64/include/vmm_dev.h soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm.c soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_dev.c soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_ioport.c soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_ioport.h Modified: soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.c Tue Aug 4 15:06:06 2015 (r289210) +++ soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.c Tue Aug 4 15:11:36 2015 (r289211) @@ -704,6 +704,23 @@ } int +vm_io_reg_handler(struct vmctx *ctx, uint16_t port, uint16_t in, uint32_t mask_data, uint32_t data, + enum vm_io_regh_type type, void *arg) +{ + struct vm_io_reg_handler ioregh; + + bzero(&ioregh, sizeof(ioregh)); + ioregh.port = port; + ioregh.in = in; + ioregh.mask_data = mask_data; + ioregh.data = data; + ioregh.type = type; + ioregh.arg = arg; + + return (ioctl(ctx->fd, VM_IO_REG_HANDLER, &ioregh)); +} + +int vm_setup_pptdev_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func, uint64_t addr, uint64_t msg, int numvec) { Modified: soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.h Tue Aug 4 15:06:06 2015 (r289210) +++ soc2015/stefano/ptnetmap/stable/10/lib/libvmmapi/vmmapi.h Tue Aug 4 15:11:36 2015 (r289211) @@ -110,7 +110,8 @@ int vm_set_intinfo(struct vmctx *ctx, int vcpu, uint64_t exit_intinfo); int vm_get_fd(struct vmctx *ctx); int vm_map_user_buf(struct vmctx *ctx, vm_paddr_t gpa, size_t len, void *host_buf); - +int vm_io_reg_handler(struct vmctx *ctx, uint16_t port, uint16_t in, + uint32_t mask_data, uint32_t data, enum vm_io_regh_type type, void *arg); /* * Return a pointer to the statistics buffer. Note that this is not MT-safe. */ Modified: soc2015/stefano/ptnetmap/stable/10/sys/amd64/include/vmm.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/amd64/include/vmm.h Tue Aug 4 15:06:06 2015 (r289210) +++ soc2015/stefano/ptnetmap/stable/10/sys/amd64/include/vmm.h Tue Aug 4 15:11:36 2015 (r289211) @@ -287,6 +287,7 @@ struct vatpic *vm_atpic(struct vm *vm); struct vatpit *vm_atpit(struct vm *vm); struct vpmtmr *vm_pmtmr(struct vm *vm); +struct ioregh *vm_ioregh(struct vm *vm); /* * Inject exception 'vme' into the guest vcpu. This function returns 0 on @@ -381,7 +382,13 @@ EDGE_TRIGGER, LEVEL_TRIGGER }; - + +enum vm_io_regh_type { + VM_IO_REGH_DELETE, + VM_IO_REGH_KWEVENTS, /* kernel wait events */ + VM_IO_REGH_MAX +}; + /* * The 'access' field has the format specified in Table 21-2 of the Intel * Architecture Manual vol 3b. Modified: soc2015/stefano/ptnetmap/stable/10/sys/amd64/include/vmm_dev.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/amd64/include/vmm_dev.h Tue Aug 4 15:06:06 2015 (r289210) +++ soc2015/stefano/ptnetmap/stable/10/sys/amd64/include/vmm_dev.h Tue Aug 4 15:11:36 2015 (r289211) @@ -117,6 +117,15 @@ size_t len; }; +struct vm_io_reg_handler { + uint16_t port; + uint16_t in; + uint32_t mask_data; /* 0 means match anything */ + uint32_t data; + enum vm_io_regh_type type; + void *arg; +}; + struct vm_pptdev_msi { int vcpu; int bus; @@ -262,6 +271,7 @@ IOCNUM_GET_CPUSET = 91, IOCNUM_MAP_USER_BUF = 100, + IOCNUM_IO_REG_HANDLER = 101, }; #define VM_RUN \ @@ -318,6 +328,8 @@ _IOW('v', IOCNUM_MAP_PPTDEV_MMIO, struct vm_pptdev_mmio) #define VM_MAP_USER_BUF \ _IOW('v', IOCNUM_MAP_USER_BUF, struct vm_user_buf) +#define VM_IO_REG_HANDLER \ + _IOW('v', IOCNUM_IO_REG_HANDLER, struct vm_io_reg_handler) #define VM_PPTDEV_MSI \ _IOW('v', IOCNUM_PPTDEV_MSI, struct vm_pptdev_msi) #define VM_PPTDEV_MSIX \ Modified: soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm.c Tue Aug 4 15:06:06 2015 (r289210) +++ soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm.c Tue Aug 4 15:11:36 2015 (r289211) @@ -137,6 +137,7 @@ struct vatpic *vatpic; /* (i) virtual atpic */ struct vatpit *vatpit; /* (i) virtual atpit */ struct vpmtmr *vpmtmr; /* (i) virtual ACPI PM timer */ + struct ioregh *ioregh; /* () I/O reg handler */ volatile cpuset_t active_cpus; /* (i) active vcpus */ int suspend; /* (i) stop VM execution */ volatile cpuset_t suspended_cpus; /* (i) suspended vcpus */ @@ -377,6 +378,7 @@ vm->vatpic = vatpic_init(vm); vm->vatpit = vatpit_init(vm); vm->vpmtmr = vpmtmr_init(vm); + vm->ioregh = ioregh_init(vm); CPU_ZERO(&vm->active_cpus); @@ -439,6 +441,7 @@ if (vm->iommu != NULL) iommu_destroy_domain(vm->iommu); + ioregh_cleanup(vm->ioregh); vpmtmr_cleanup(vm->vpmtmr); vatpit_cleanup(vm->vatpit); vhpet_cleanup(vm->vhpet); @@ -505,29 +508,15 @@ return (0); } -static int vm_gpa_wire(struct vm *vm); int vm_map_usermem(struct vm *vm, vm_paddr_t gpa, size_t len, void *buf, struct thread *td) { vm_object_t obj; - int error; - if ((obj = vmm_usermem_alloc(vm->vmspace, gpa, len, buf, td)) == NULL) return (ENOMEM); -#if 0 - error = vm_gpa_wire(vm); /* XXX-ste: is needed? */ - - if (error) - goto err; -#endif - return (0); - -//err: - vmm_usermem_free(vm->vmspace, gpa, len); - return (error); } int @@ -2253,6 +2242,12 @@ return (vm->vpmtmr); } +struct ioregh * +vm_ioregh(struct vm *vm) +{ + return (vm->ioregh); +} + enum vm_reg_name vm_segment_name(int seg) { Modified: soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_dev.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_dev.c Tue Aug 4 15:06:06 2015 (r289210) +++ soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_dev.c Tue Aug 4 15:11:36 2015 (r289211) @@ -54,6 +54,7 @@ #include "vmm_lapic.h" #include "vmm_stat.h" #include "vmm_mem.h" +#include "vmm_ioport.h" #include "io/ppt.h" #include "io/vatpic.h" #include "io/vioapic.h" @@ -165,6 +166,7 @@ struct vm_pptdev_msi *pptmsi; struct vm_pptdev_msix *pptmsix; struct vm_user_buf *usermem; + struct vm_io_reg_handler *ioregh; struct vm_nmi *vmnmi; struct vm_stats *vmstats; struct vm_stat_desc *statdesc; @@ -302,6 +304,11 @@ error = vm_map_usermem(sc->vm, usermem->gpa, usermem->len, usermem->addr, td); break; + case VM_IO_REG_HANDLER: + ioregh = (struct vm_io_reg_handler *)data; + error = vmm_ioport_reg_handler(sc->vm, ioregh->port, ioregh->in, ioregh->mask_data, + ioregh->data, ioregh->type, ioregh->arg); + break; case VM_BIND_PPTDEV: pptdev = (struct vm_pptdev *)data; error = vm_assign_pptdev(sc->vm, pptdev->bus, pptdev->slot, Modified: soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_ioport.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_ioport.c Tue Aug 4 15:06:06 2015 (r289210) +++ soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_ioport.c Tue Aug 4 15:11:36 2015 (r289211) @@ -100,31 +100,246 @@ } #endif /* KTR */ +#ifdef VMM_IOPORT_REG_HANDLER +#include +#include +#include +#include +#include + +static MALLOC_DEFINE(M_IOREGH, "ioregh", "bhyve ioport reg handlers"); + +#define IOREGH_LOCK(ioregh) mtx_lock_spin(&((ioregh)->mtx)) +#define IOREGH_UNLOCK(ioregh) mtx_unlock_spin(&((ioregh)->mtx)) + +#define IOPORT_MAX_REG_HANDLER 12 + +typedef int (*ioport_reg_handler_func_t)(struct vm *vm, struct ioport_reg_handler *regh, + uint32_t *val); + +struct ioport_reg_handler { + uint16_t port; + uint16_t in; + uint32_t mask_data; + uint32_t data; + ioport_reg_handler_func_t handler; + void *handler_arg; +}; + +struct ioregh { + struct mtx mtx; + /* TODO: use hash table is better */ + struct ioport_reg_handler handlers[IOPORT_MAX_REG_HANDLER]; +}; + +/* ----- I/O reg handlers ----- */ + +/* VM_IO_REGH_KWEVENTS handler */ +static int +vmm_ioport_reg_wakeup(struct vm *vm, struct ioport_reg_handler *regh, uint32_t *val) +{ + wakeup(regh->handler_arg); + return (0); +} + +/* call with ioregh->mtx held */ +static struct ioport_reg_handler * +vmm_ioport_find_handler(struct ioregh *ioregh, uint16_t port, uint16_t in, uint32_t mask_data, uint32_t data) +{ + struct ioport_reg_handler *regh; + uint32_t mask; + int i; + + regh = ioregh->handlers; + for (i = 0; i < IOPORT_MAX_REG_HANDLER; i++) { + if (regh[i].handler != NULL) { + mask = regh[i].mask_data & mask_data; + if ((regh[i].port == port) && (regh[i].in == in) + && ((mask & regh[i].data) == (mask & data))) { + return ®h[i]; + } + } + } + + return (NULL); +} + +/* call with ioregh->mtx held */ +static struct ioport_reg_handler * +vmm_ioport_empty_handler(struct ioregh *ioregh) +{ + struct ioport_reg_handler *regh; + int i; + + regh = ioregh->handlers; + for (i = 0; i < IOPORT_MAX_REG_HANDLER; i++) { + if (regh[i].handler == NULL) { + return ®h[i]; + } + } + + return (NULL); +} + + +static int +vmm_ioport_add_handler(struct vm *vm, uint16_t port, uint16_t in, uint32_t mask_data, uint32_t data, + ioport_reg_handler_func_t handler, void *handler_arg) +{ + struct ioport_reg_handler *regh; + struct ioregh *ioregh; + int ret = 0; + + ioregh = vm_ioregh(vm); + + IOREGH_LOCK(ioregh); + + regh = vmm_ioport_find_handler(ioregh, port, in, mask_data, data); + if (regh != NULL) { + printf("%s: handler for port %d in %d mask_data %d data %d already registered\n", + __FUNCTION__, port, in, mask_data, data); + ret = EEXIST; + goto err; + } + + regh = vmm_ioport_empty_handler(ioregh); + if (regh == NULL) { + printf("%s: empty reg_handler slot not found\n", __FUNCTION__); + ret = ENOMEM; + goto err; + } + + regh->port = port; + regh->in = in; + regh->mask_data = mask_data; + regh->data = data; + regh->handler = handler; + regh->handler_arg = handler_arg; + +err: + IOREGH_UNLOCK(ioregh); + return (ret); +} + +static int +vmm_ioport_del_handler(struct vm *vm, uint16_t port, uint16_t in, uint32_t mask_data, uint32_t data) +{ + struct ioport_reg_handler *regh; + struct ioregh *ioregh; + int ret = 0; + + ioregh = vm_ioregh(vm); + + IOREGH_LOCK(ioregh); + + regh = vmm_ioport_find_handler(ioregh, port, in, mask_data, data); + + if (regh == NULL) { + ret = EINVAL; + goto err; + } + + bzero(regh, sizeof(struct ioport_reg_handler)); +err: + IOREGH_UNLOCK(ioregh); + return (ret); +} + +int +vmm_ioport_reg_handler(struct vm *vm, uint16_t port, uint16_t in, uint32_t mask_data, uint32_t data, + enum vm_io_regh_type type, void *arg) +{ + int ret = 0; + + switch (type) { + case VM_IO_REGH_DELETE: + ret = vmm_ioport_del_handler(vm, port, in, mask_data, data); + break; + case VM_IO_REGH_KWEVENTS: + ret = vmm_ioport_add_handler(vm, port, in, mask_data, data, vmm_ioport_reg_wakeup, arg); + break; + default: + printf("%s: unknown reg_handler type\n", __FUNCTION__); + ret = EINVAL; + break; + } + + return (ret); +} + +static int +invoke_reg_handler(struct vm *vm, int vcpuid, struct vm_exit *vmexit, uint32_t *val, int *error) +{ + struct ioport_reg_handler *regh; + struct ioregh *ioregh; + uint32_t mask_data; + + mask_data = vie_size2mask(vmexit->u.inout.bytes); + ioregh = vm_ioregh(vm); + + IOREGH_LOCK(ioregh); + regh = vmm_ioport_find_handler(ioregh, vmexit->u.inout.port, vmexit->u.inout.in, + mask_data, vmexit->u.inout.eax); + if (regh == NULL) { + IOREGH_UNLOCK(ioregh); + return (0); + } + /* XXX: maybe is better to use refcount and lock only find */ + *error = (*(regh->handler))(vm, regh, val); + IOREGH_UNLOCK(ioregh); + return (1); +} + +struct ioregh * +ioregh_init(struct vm *vm) +{ + struct ioregh *ioregh; + + ioregh = malloc(sizeof(struct ioregh), M_IOREGH, M_WAITOK | M_ZERO); + + mtx_init(&ioregh->mtx, "ioregh lock", NULL, MTX_SPIN); + + return (ioregh); +} + +void +ioregh_cleanup(struct ioregh *ioregh) +{ + free(ioregh, M_IOREGH); +} +#else /* !VMM_IOPORT_REG_HANDLER */ +#define invoke_reg_handler(_1, _2, _3, _4, _5) (0) +#endif /* VMM_IOPORT_REG_HANDLER */ + static int emulate_inout_port(struct vm *vm, int vcpuid, struct vm_exit *vmexit, bool *retu) { ioport_handler_func_t handler; uint32_t mask, val; - int error; + int regh = 0, error = 0; /* * If there is no handler for the I/O port then punt to userspace. */ - if (vmexit->u.inout.port >= MAX_IOPORTS || - (handler = ioport_handler[vmexit->u.inout.port]) == NULL) { + if ((vmexit->u.inout.port >= MAX_IOPORTS || + (handler = ioport_handler[vmexit->u.inout.port]) == NULL) && + (regh = invoke_reg_handler(vm, vcpuid, vmexit, &val, &error)) == 0) { *retu = true; return (0); } - mask = vie_size2mask(vmexit->u.inout.bytes); + if (!regh) { + mask = vie_size2mask(vmexit->u.inout.bytes); + + if (!vmexit->u.inout.in) { + val = vmexit->u.inout.eax & mask; + } - if (!vmexit->u.inout.in) { - val = vmexit->u.inout.eax & mask; + error = (*handler)(vm, vcpuid, vmexit->u.inout.in, + vmexit->u.inout.port, vmexit->u.inout.bytes, &val); } - error = (*handler)(vm, vcpuid, vmexit->u.inout.in, - vmexit->u.inout.port, vmexit->u.inout.bytes, &val); if (error) { /* * The value returned by this function is also the return value Modified: soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_ioport.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_ioport.h Tue Aug 4 15:06:06 2015 (r289210) +++ soc2015/stefano/ptnetmap/stable/10/sys/amd64/vmm/vmm_ioport.h Tue Aug 4 15:11:36 2015 (r289211) @@ -29,6 +29,24 @@ #ifndef _VMM_IOPORT_H_ #define _VMM_IOPORT_H_ +#define VMM_IOPORT_REG_HANDLER + +#ifdef VMM_IOPORT_REG_HANDLER +struct ioport_reg_handler; +struct ioregh; + +struct ioregh *ioregh_init(struct vm *vm); +void ioregh_cleanup(struct ioregh *ioregh); + +int +vmm_ioport_reg_handler(struct vm *vm, uint16_t port, uint16_t in, uint32_t mask_data, uint32_t data, + enum vm_io_regh_type type, void *arg); +#else /* !VMM_IOPORT_REG_HANDLER */ +#define ioregh_init(_1) (NULL) +#define ioregh_cleanup(_1) +#define vmm_ioport_reg_handler(_1, _2, _3, _4,_5, _6, _7) (EINVAL) +#endif /* VMM_IOPORT_REG_HANDLER */ + typedef int (*ioport_handler_func_t)(struct vm *vm, int vcpuid, bool in, int port, int bytes, uint32_t *val); From owner-svn-soc-all@freebsd.org Tue Aug 4 15:22:55 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 579E79B37E3 for ; Tue, 4 Aug 2015 15:22:55 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 473421E04 for ; Tue, 4 Aug 2015 15:22:55 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t74FMtHC062576 for ; Tue, 4 Aug 2015 15:22:55 GMT (envelope-from stefano@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t74FMrVY062555 for svn-soc-all@FreeBSD.org; Tue, 4 Aug 2015 15:22:53 GMT (envelope-from stefano@FreeBSD.org) Date: Tue, 4 Aug 2015 15:22:53 GMT Message-Id: <201508041522.t74FMrVY062555@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to stefano@FreeBSD.org using -f From: stefano@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289212 - soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 15:22:55 -0000 Author: stefano Date: Tue Aug 4 15:22:52 2015 New Revision: 289212 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289212 Log: [bhyve/ptnetmap] add guest/host(kthread) notification and cleanup 1) notification from ptnetmap kthread to guest VM (interrupt/irq) The bhyve user-space, during netmap configuration, passes the ioctl parameters (fd, com, data) to ptnetmap kthreads. The ptnetmap kthread (attached to bhyve process) uses kern_ioctl() with these parameters to notify the guest VM. 2) notification from guest VM to ptnetmap kthread (write into the specific register) Use new IOCTL on vmm.ko (VM_IO_REG_HANDLER) to catch write/read on specific I/O address and send notification. With this new IOCTL, when the guest writes on specific register, the vmm.ko invokes wakeup() on the parameter (chan) specified from bhyve user-space application. The same parameter is passed to the ptnetmap kthreads that call tsleep(chan, ...) to wait the event. Added: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/README.network Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/net_backends.c soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_ptnetmap_memdev.c soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_virtio_ptnetmap.h soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/ptnetmap.h Added: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/README.network ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/README.network Tue Aug 4 15:22:52 2015 (r289212) @@ -0,0 +1,122 @@ +Network frontends and backends in bhyve + +20140804 + +The following is a proposal on how to implement network frontends (FE) +and backends (BE) in bhyve, and how to interface them. + +We need to address the following requirements: +1. Depending on the type of FE and BE, one may need zero or more + additional threads (iothreads) in charge of sending or receiving + packets, implementing one side of paravirtualized devices, etc. + + The requirements for an intermediate thread are the following: + + --- transmit --- + Frontend Backend Operations + non-PV non block* (1) all in VCPU + other cases (2) notify_tx() in VCPU, I/O in thread + + case 1: VCPU executes (autonomously or on kick_tx) + fe->fe2be(); // fill the ring + be->transmit(); + fe->fe2be(); // reclaim buffers + + case 2: VCPU executes (autonomously) + be->notify_tx(); + + iothread executes + for (;;) { + + fe->fe2be(); // fill the ring + be->transmit(); // e.g. txsync, write + fe->fe2be(); // reclaim buffers + } + + non blocking means that either the BE tx function is non + blocking, or that we have an independent notification mechanism + (e.g. an event loop, kevent, epoll...) to notify the FE when + transmit will be possible and issue a kick_tx() to the VCPU + + --- receive --- + Backend Operations + non block* (1) all in VCPU + other cases (2) all in thread + + case 1: VCPU executes (autonomously or on kick_rx) + if (needed) fe->be2fe(); // release buffers from FE + be->receive(); // read or rxsync + if (needed) fe->be2fe(); // pass packets to FE + main thread does fe->kick_rx() when data available + + case 2: i/o thread executes (autonomously) + for (;;) { + + fe->be2fe(); // reclaim buffers from FE + be->receive(); // read or rxsync + fe->be2fe(); // pass packets to FE and kick_rx + } + /* note, in netmap be->receive() may be empty because poll() + * will already fill the ring with packets. + */ + + same as above, non blocking means that the BE will use an + existing mechanism to notify the FE when receive will be possible + and issue a kick_rx() to the VCPU + +2. for performance reasons, it is important that the interface between + FE and BE support batched transfers and asynchronous completion + notifications. + + Given that the netmap API has the features required by #2, and that + netmap backends (and possibly even frontends) are going to be used + with bhyve, we suggest to standardize netmap as the FE-BE API + +In practice, the FE will need to call some BE-supplied function +during its operation, and the same goes for the BE. +To implement this, both entities export some information +through descriptors visible to the other entity. + +Frontend descriptor + + struct fe_desc { + ... + int (*be2fe)(struct fe_desc *, struct netmap_ring *); + int (*fe2be)(struct fe_desc *, struct netmap_ring *); + ... + } + + fe->be2fe() + is invoked by the BE (when receiving from the network) + to move packets from the netmap ring into the FE and to release + completed buffers from the FE back into the netmap ring. + The amount of data moved can be determined by the BE by comparing + the ring pointers before and after the call. + + Before returning, be2fe() will likely issue a kick to the VCPU + (e.g. an interrupt) to notify the availability of new data. + + The return value may be used to indicate events that cannot + be represented by the ring pointers. + + The function runs in the context of a thread "owned" by the BE, + and should implement protection against concurrent + activities on the FE's data structures, whereas the netmap_ring + is only used by this function during its execution. + + fe->fe2be() + is it needed ? + +Backend descriptors + + struct be_desc { + ... + int (*notify_tx)(struct re_desc *, struct netmap_ring *); + int (*notify_rx)(struct re_desc *, struct netmap_ring *); + ... + } + + be->notify_tx() + is invoked by the ... + + Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/net_backends.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/net_backends.c Tue Aug 4 15:11:36 2015 (r289211) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/net_backends.c Tue Aug 4 15:22:52 2015 (r289212) @@ -46,7 +46,7 @@ #include #include "mevent.h" -#include "dev/virtio/network/virtio_net.h" +#include #include "net_backends.h" #include @@ -443,30 +443,38 @@ return 0; } +/* used by netmap and ptnetmap */ static int -netmap_init(struct net_backend *be, const char *devname, - net_backend_cb_t cb, void *param) +netmap_commom_init(struct net_backend *be, struct netmap_priv *priv, uint32_t nr_flags, + const char *devname, net_backend_cb_t cb, void *param) { const char *ndname = "/dev/netmap"; - struct netmap_priv *priv = NULL; + struct nmreq req; char tname[40]; - priv = calloc(1, sizeof(struct netmap_priv)); - if (priv == NULL) { - WPRINTF(("Unable alloc netmap private data\n")); - return -1; - } - strncpy(priv->ifname, devname, sizeof(priv->ifname)); priv->ifname[sizeof(priv->ifname) - 1] = '\0'; - priv->nmd = nm_open(priv->ifname, NULL, NETMAP_NO_TX_POLL, NULL); + memset(&req, 0, sizeof(req)); + req.nr_flags |= nr_flags; + + priv->nmd = nm_open(priv->ifname, &req, NETMAP_NO_TX_POLL, NULL); if (priv->nmd == NULL) { WPRINTF(("Unable to nm_open(): device '%s', " "interface '%s', errno (%s)\n", ndname, devname, strerror(errno))); goto err_open; } +#if 0 + /* check parent (nm_desc with the same allocator already mapped) */ + parent_nmd = netmap_find_parent(nmd); + /* mmap or inherit from parent */ + if (nm_mmap(nmd, parent_nmd)) { + error_report("failed to mmap %s: %s", netmap_opts->ifname, strerror(errno)); + nm_close(nmd); + return -1; + } +#endif priv->tx = NETMAP_TXRING(priv->nmd->nifp, 0); priv->rx = NETMAP_RXRING(priv->nmd->nifp, 0); @@ -476,7 +484,6 @@ priv->rx_continue = 0; be->fd = priv->nmd->fd; - be->priv = priv; /* Create a thread for netmap poll. */ pthread_create(&priv->evloop_tid, NULL, netmap_evloop_thread, (void *)be); @@ -486,6 +493,32 @@ return 0; err_open: + return -1; +} + +static int +netmap_init(struct net_backend *be, const char *devname, + net_backend_cb_t cb, void *param) +{ + const char *ndname = "/dev/netmap"; + struct netmap_priv *priv = NULL; + char tname[40]; + + priv = calloc(1, sizeof(struct netmap_priv)); + if (priv == NULL) { + WPRINTF(("Unable alloc netmap private data\n")); + return -1; + } + + if (netmap_commom_init(be, priv, 0, devname, cb, param)) { + goto err; + } + + be->priv = priv; + + return 0; + +err: free(priv); return -1; @@ -708,9 +741,9 @@ /* * The ptnetmap backend */ -#include -#include "net/netmap.h" -#include "dev/netmap/netmap_virt.h" +#include /* IFNAMSIZ */ +#include +#include #include "ptnetmap.h" struct ptnbe_priv { @@ -721,10 +754,8 @@ unsigned long acked_features; /* ptnetmap acked features */ }; - - /* The virtio-net features supported by ptnetmap. */ -#define VIRTIO_NET_F_PTNETMAP 0x2000000 /* ptnetmap available */ +#define VIRTIO_NET_F_PTNETMAP 0x2000000 /* (25) ptnetmap available */ #define PTNETMAP_FEATURES VIRTIO_NET_F_PTNETMAP @@ -737,10 +768,6 @@ static uint64_t ptnbe_set_features(struct net_backend *be, uint64_t features) { - if (features & PTNETMAP_FEATURES) { - WPRINTF(("ptnbe_set_features\n")); - } - return 0; } @@ -763,48 +790,20 @@ WPRINTF(("Unable alloc netmap private data\n")); return -1; } - WPRINTF(("ptnbe_init(): devname '%s'\n", devname)); npriv = &priv->up; - strncpy(npriv->ifname, devname + PTNETMAP_NAME_HDR, sizeof(npriv->ifname)); - npriv->ifname[sizeof(npriv->ifname) - 1] = '\0'; - memset(&req, 0, sizeof(req)); - req.nr_flags |= NR_PASSTHROUGH_HOST; - - npriv->nmd = nm_open(npriv->ifname, &req, NETMAP_NO_TX_POLL, NULL); - if (npriv->nmd == NULL) { - WPRINTF(("Unable to nm_open(): device '%s', " - "interface '%s', errno (%s)\n", - ndname, devname, strerror(errno))); - goto err_open; - } -#if 0 - /* check parent (nm_desc with the same allocator already mapped) */ - parent_nmd = netmap_find_parent(nmd); - /* mmap or inherit from parent */ - if (nm_mmap(nmd, parent_nmd)) { - error_report("failed to mmap %s: %s", netmap_opts->ifname, strerror(errno)); - nm_close(nmd); - return -1; + if (netmap_commom_init(be, npriv, NR_PTNETMAP_HOST, devname + PTNETMAP_NAME_HDR, cb, param)) { + goto err; } -#endif - - - npriv->tx = NETMAP_TXRING(npriv->nmd->nifp, 0); - npriv->rx = NETMAP_RXRING(npriv->nmd->nifp, 0); - npriv->cb = cb; - npriv->cb_param = param; - - be->fd = npriv->nmd->fd; be->priv = priv; ptnbe_init_ptnetmap(be); return 0; -err_open: +err: free(priv); return -1; @@ -816,6 +815,7 @@ struct ptnbe_priv *priv = be->priv; if (priv) { + ptnetmap_delete(&priv->ptns); nm_close(priv->up.nmd); } be->fd = -1; @@ -903,8 +903,7 @@ if (priv->created) return 0; - /* TODO: ioctl to start kthreads */ -#if 1 + /* ioctl to start ptnetmap kthreads */ memset(&req, 0, sizeof(req)); strncpy(req.nr_name, priv->up.ifname, sizeof(req.nr_name)); req.nr_version = NETMAP_API; @@ -916,8 +915,6 @@ priv->up.ifname, strerror(errno)); } else priv->created = 1; -#endif - return err; } @@ -929,15 +926,15 @@ struct nmreq req; int err; + if (!priv->created) + return 0; + if (!(priv->acked_features & NET_PTN_FEATURES_BASE)) { printf("ptnetmap features not acked\n"); return EFAULT; } - if (!priv->created) - return 0; - - /* TODO: ioctl to stop kthreads */ + /* ioctl to stop ptnetmap kthreads */ memset(&req, 0, sizeof(req)); strncpy(req.nr_name, priv->up.ifname, sizeof(req.nr_name)); req.nr_version = NETMAP_API; @@ -956,6 +953,8 @@ .name = "ptnetmap|ptvale", .init = ptnbe_init, .cleanup = ptnbe_cleanup, + .send = netmap_send, + .recv = netmap_receive, .get_features = ptnbe_get_features, .set_features = ptnbe_set_features, .get_ptnetmap = ptnbe_get_ptnetmap, Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_ptnetmap_memdev.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_ptnetmap_memdev.c Tue Aug 4 15:11:36 2015 (r289211) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_ptnetmap_memdev.c Tue Aug 4 15:22:52 2015 (r289212) @@ -1,3 +1,29 @@ +/* + * Copyright (C) 2015 Stefano Garzarella (stefano.garzarella@gmail.com) + * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. + */ + #include __FBSDID("$FreeBSD$"); @@ -17,22 +43,9 @@ #include "pci_emul.h" #include "ptnetmap.h" - -/* ptnetmap memdev PCI-ID and PCI-BARS XXX-ste: remove*/ -#define PTN_MEMDEV_NAME "ptnetmap-memdev" -#define PTNETMAP_PCI_VENDOR_ID 0x3333 /* XXX-ste: set vendor_id */ -#define PTNETMAP_PCI_DEVICE_ID 0x0001 -#define PTNETMAP_IO_PCI_BAR 0 -#define PTNETMAP_MEM_PCI_BAR 1 - -/* ptnetmap memdev register */ -/* 32 bit r/o */ -#define PTNETMAP_IO_PCI_FEATURES 0 -/* 32 bit r/o */ -#define PTNETMAP_IO_PCI_MEMSIZE 4 -/* 16 bit r/o */ -#define PTNETMAP_IO_PCI_HOSTID 8 -#define PTNEMTAP_IO_SIZE 10 +#include /* IFNAMSIZ */ +#include +#include struct ptn_memdev_softc { struct pci_devinst *pi; /* PCI device instance */ @@ -129,8 +142,8 @@ return 0; if (baridx == PTNETMAP_MEM_PCI_BAR) { - printf("ptnetmap_memdev: MEM read\n"); - printf("ptnentmap_memdev: mem_read - offset: %lx size: %d ret: %lx\n", offset, size, ret); + printf("ptnetmap_memdev: unexpected MEM read - offset: %lx size: %d ret: %lx\n", + offset, size, ret); return 0; /* XXX */ } @@ -149,7 +162,6 @@ break; } - printf("ptnentmap_memdev: io_read - offset: %lx size: %d ret: %llu\n", offset, size,(unsigned long long)ret); return ret; } @@ -164,22 +176,16 @@ return; if (baridx == PTNETMAP_MEM_PCI_BAR) { - printf("ptnetmap_memdev: MEM write\n"); - return; /* XXX */ + printf("ptnetmap_memdev: unexpected MEM write - offset: %lx size: %d value: %lx\n", + offset, size, value); + return; } - /* XXX probably should do something better than just assert() */ - assert(baridx == PTNETMAP_IO_PCI_BAR); - switch (offset) { - default: printf("ptnentmap_memdev: write io reg unexpected\n"); break; } - - - printf("ptnentmap_memdev: io_write - offset: %lx size: %d val: %lx\n", offset, size, value); } static int @@ -187,12 +193,9 @@ { int ret; - printf("ptnetmap_memdev: configuring\n"); - if (sc->pi == NULL || sc->mem_ptr == NULL) return 0; - /* init iobar */ ret = pci_emul_alloc_bar(sc->pi, PTNETMAP_IO_PCI_BAR, PCIBAR_IO, PTNEMTAP_IO_SIZE); if (ret) { @@ -209,10 +212,6 @@ return ret; } - printf("ptnetmap_memdev: pci_addr: %llx, mem_size: %llu, mem_ptr: %p\n", - (unsigned long long) sc->pi->pi_bar[PTNETMAP_MEM_PCI_BAR].addr, - (unsigned long long) sc->mem_size, sc->mem_ptr); - ret = vm_map_user_buf(sc->pi->pi_vmctx, sc->pi->pi_bar[PTNETMAP_MEM_PCI_BAR].addr, sc->mem_size, sc->mem_ptr); if (ret) { @@ -220,8 +219,6 @@ return ret; } - printf("ptnetmap_memdev: configured\n"); - return 0; } @@ -232,8 +229,6 @@ uint64_t size; int ret; - printf("ptnetmap_memdev: loading\n"); - sc = ptn_memdev_find_empty_pi(); if (sc == NULL) { sc = ptn_memdev_create(); @@ -260,8 +255,6 @@ goto err; } - printf("ptnetmap_memdev: loaded\n"); - return (0); err: ptn_memdev_delete(sc); @@ -274,7 +267,6 @@ { struct ptn_memdev_softc *sc; int ret; - printf("ptnetmap_memdev: attaching\n"); /* if a device with the same mem_id is already attached, we are done */ if (ptn_memdev_find_memid(mem_id)) { @@ -295,17 +287,13 @@ sc->mem_size = mem_size; sc->mem_id = mem_id; - printf("ptnetmap_memdev_attach: mem_id: %u, mem_size: %lu, mem_ptr: %p\n", mem_id, - (unsigned long) mem_size, mem_ptr); - - /* TODO: configure device BARs */ + /* configure device BARs */ ret = ptn_memdev_configure(sc); if (ret) { printf("ptnetmap_memdev: configure error\n"); goto err; } - printf("ptnetmap_memdev: attached\n"); return 0; err: Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_virtio_ptnetmap.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_virtio_ptnetmap.h Tue Aug 4 15:11:36 2015 (r289211) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/pci_virtio_ptnetmap.h Tue Aug 4 15:22:52 2015 (r289212) @@ -1,12 +1,41 @@ +/* + * Copyright (C) 2015 Stefano Garzarella (stefano.garzarella@gmail.com) + * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. + */ + #ifndef __PCI_VIRTIO_PTNETMAP_H__ #define __PCI_VIRTIO_PTNETMAP_H__ -/* XXX-ste: move in other file and split in .c .h? */ #ifdef BHYVE_VIRTIO_PTNETMAP +#include +#include /* VM_LAPIC_MSI */ +#include + +#include "ptnetmap.h" /* ptnetmap virtio register BASE */ #define PTNETMAP_VIRTIO_IO_BASE sizeof(struct virtio_net_config) -#include "ptnetmap.h" static void ptnetmap_configure_csb(struct vmctx *ctx, struct paravirt_csb** csb, uint32_t csbbal, @@ -23,7 +52,6 @@ * The CSB is then remapped if the new pointer is != 0 */ if (*csb) { - /* TODO: unmap */ *csb = NULL; } if (base) { @@ -56,8 +84,6 @@ /* extend cfgsize. virtio creates PCIBAR for us */ vc->vc_cfgsize += PTNEMTAP_VIRTIO_IO_SIZE; - - printf("ptnetmap-virtio init END\n"); } static int @@ -75,17 +101,12 @@ printf("ERROR ptnetmap: csb not initialized\n"); return ret; } + /* share netmap_if info to the guest through CSB */ csb->nifp_offset = ptns->offset; csb->num_tx_rings = ptns->num_tx_rings; csb->num_rx_rings = ptns->num_rx_rings; csb->num_tx_slots = ptns->num_tx_slots; csb->num_rx_slots = ptns->num_rx_slots; - printf("txr %u rxr %u txd %u rxd %u nifp_offset %u\n", - csb->num_tx_rings, - csb->num_rx_rings, - csb->num_tx_slots, - csb->num_rx_slots, - csb->nifp_offset); return ret; } @@ -95,6 +116,12 @@ { struct ptnetmap_state *ptns = sc->ptn.state; struct paravirt_csb *csb = sc->ptn.csb; + struct pci_devinst *pi; + struct vmctx *vmctx; + struct vqueue_info *vq; + struct msix_table_entry *mte; + struct iovec iov[1]; + uint16_t idx; int ret; if (sc->ptn.up) { @@ -107,22 +134,59 @@ return -1; } - /* TODO-ste: add support for multiqueue */ + /* TODO: add support for multiqueue */ + pi = sc->vsc_vs.vs_pi; + vmctx = pi->pi_vmctx; - /* TODO: Stop processing guest/host IO notifications in qemu. + /* Configure the RX ring */ + sc->ptn.cfg.rx_ring.irqfd = vm_get_fd(vmctx); + sc->ptn.cfg.rx_ioctl.com = VM_LAPIC_MSI; + vq = &sc->vsc_queues[VTNET_RXQ]; + mte = &pi->pi_msix.table[vq->vq_msix_idx]; + sc->ptn.cfg.rx_ioctl.data.msg = mte->msg_data; + sc->ptn.cfg.rx_ioctl.data.addr = mte->addr; + /* push fake-elem in the rx queue to enable interrupts */ + if (vq_getchain(vq, &idx, iov, 1, NULL) > 0) { + vq_relchain(vq, idx, 0); + } + /* enable rx notification from guest */ + vq->vq_used->vu_flags &= ~VRING_USED_F_NO_NOTIFY; + /* + * Stop processing guest/host IO notifications in bhyve. * Start processing them in ptnetmap. */ - - - /* Configure the RX ring */ - sc->ptn.cfg.rx_ring.ioeventfd = -1; - sc->ptn.cfg.rx_ring.irqfd = -1; + ret = vm_io_reg_handler(vmctx, pi->pi_bar[0].addr + VTCFG_R_QNOTIFY, 0, + 0xFFFFFFFF, VTNET_RXQ, VM_IO_REGH_KWEVENTS, (void *) vq); + if (ret != 0) { + printf("ERROR ptnetmap: vm_io_reg_handler %d\n", ret); + goto err_reg_rx; + } + sc->ptn.cfg.rx_ring.ioeventfd = (uint64_t) vq; /* Configure the TX ring */ - sc->ptn.cfg.tx_ring.ioeventfd = -1; - sc->ptn.cfg.tx_ring.irqfd = -1; - - /* TODO: push fake-elem in the tx/rx queue to enable interrupts */ + sc->ptn.cfg.tx_ring.irqfd = vm_get_fd(vmctx); + sc->ptn.cfg.tx_ioctl.com = VM_LAPIC_MSI; + vq = &sc->vsc_queues[VTNET_TXQ]; + mte = &pi->pi_msix.table[vq->vq_msix_idx]; + sc->ptn.cfg.tx_ioctl.data.msg = mte->msg_data; + sc->ptn.cfg.tx_ioctl.data.addr = mte->addr; + /* push fake-elem in the tx queue to enable interrupts */ + if (vq_getchain(vq, &idx, iov, 1, NULL) > 0) { + vq_relchain(vq, idx, 0); + } + /* enable tx notification from guest */ + vq->vq_used->vu_flags &= ~VRING_USED_F_NO_NOTIFY; + /* + * Stop processing guest/host IO notifications in bhyve. + * Start processing them in ptnetmap. + */ + ret = vm_io_reg_handler(vmctx, pi->pi_bar[0].addr + VTCFG_R_QNOTIFY, 0, + 0xFFFFFFFF, VTNET_TXQ, VM_IO_REGH_KWEVENTS, (void *) vq); + if (ret != 0) { + printf("ERROR ptnetmap: vm_io_reg_handler %d\n", ret); + goto err_reg_tx; + } + sc->ptn.cfg.tx_ring.ioeventfd = (uint64_t) vq; /* Initialize CSB */ sc->ptn.cfg.csb = sc->ptn.csb; @@ -131,7 +195,8 @@ sc->ptn.csb->guest_need_rxkick = 1; sc->ptn.csb->host_need_rxkick = 1; - sc->ptn.cfg.features = PTNETMAP_CFG_FEAT_CSB | PTNETMAP_CFG_FEAT_EVENTFD; + sc->ptn.cfg.features = PTNETMAP_CFG_FEAT_CSB | PTNETMAP_CFG_FEAT_EVENTFD | + PTNETMAP_CFG_FEAT_IOCTL; /* Configure the net backend. */ ret = ptnetmap_create(sc->ptn.state, &sc->ptn.cfg); @@ -143,22 +208,38 @@ return (0); err_ptn_create: + vm_io_reg_handler(vmctx, pi->pi_bar[0].addr + VTCFG_R_QNOTIFY, 0, + 0xFFFFFFFF, VTNET_TXQ, VM_IO_REGH_DELETE, 0); +err_reg_tx: + vm_io_reg_handler(vmctx, pi->pi_bar[0].addr + VTCFG_R_QNOTIFY, 0, + 0xFFFFFFFF, VTNET_RXQ, VM_IO_REGH_DELETE, 0); +err_reg_rx: return (ret); } static int pci_vtnet_ptnetmap_down(struct pci_vtnet_softc *sc) { + struct pci_devinst *pi; + struct vmctx *vmctx; int ret; if (!sc->ptn.state || !sc->ptn.up) { return (0); } - sc->ptn.up = 0; + pi = sc->vsc_vs.vs_pi; + vmctx = pi->pi_vmctx; + /* - * TODO: Start processing guest/host IO notifications in qemu. + * Start processing guest/host IO notifications in bhyve. */ + vm_io_reg_handler(vmctx, pi->pi_bar[0].addr + VTCFG_R_QNOTIFY, 0, + 0xFFFFFFFF, VTNET_RXQ, VM_IO_REGH_DELETE, 0); + vm_io_reg_handler(vmctx, pi->pi_bar[0].addr + VTCFG_R_QNOTIFY, 0, + 0xFFFFFFFF, VTNET_TXQ, VM_IO_REGH_DELETE, 0); + + sc->ptn.up = 0; return (ptnetmap_delete(sc->ptn.state)); } @@ -177,53 +258,50 @@ memcpy(&sc->ptn.reg[offset], &value, size); switch (offset) { - case PTNETMAP_VIRTIO_IO_PTFEAT: - val = (uint32_t *)(sc->ptn.reg + offset); - ret = (sc->ptn.features &= *val); - ptnetmap_ack_features(sc->ptn.state, sc->ptn.features); - printf("ptnetmap acked features: %x\n", sc->ptn.features); - - sc->ptn.reg[PTNETMAP_VIRTIO_IO_PTFEAT] = ret; + case PTNETMAP_VIRTIO_IO_PTFEAT: + val = (uint32_t *)(sc->ptn.reg + offset); + ret = (sc->ptn.features &= *val); + ptnetmap_ack_features(sc->ptn.state, sc->ptn.features); + + sc->ptn.reg[PTNETMAP_VIRTIO_IO_PTFEAT] = ret; + break; + case PTNETMAP_VIRTIO_IO_PTCTL: + val = (uint32_t *)(sc->ptn.reg + offset); + + ret = EINVAL; + switch(*val) { + case NET_PARAVIRT_PTCTL_CONFIG: + ret = pci_vtnet_ptnetmap_get_mem(sc); break; - case PTNETMAP_VIRTIO_IO_PTCTL: - val = (uint32_t *)(sc->ptn.reg + offset); - - ret = EINVAL; - switch(*val) { - case NET_PARAVIRT_PTCTL_CONFIG: - ret = pci_vtnet_ptnetmap_get_mem(sc); - break; - case NET_PARAVIRT_PTCTL_REGIF: - ret = pci_vtnet_ptnetmap_up(sc); - break; - case NET_PARAVIRT_PTCTL_UNREGIF: - ret = pci_vtnet_ptnetmap_down(sc); - break; - case NET_PARAVIRT_PTCTL_HOSTMEMID: - ret = ptnetmap_get_hostmemid(sc->ptn.state); - break; - case NET_PARAVIRT_PTCTL_IFNEW: - case NET_PARAVIRT_PTCTL_IFDELETE: - case NET_PARAVIRT_PTCTL_FINALIZE: - case NET_PARAVIRT_PTCTL_DEREF: - ret = 0; - break; - } - printf("PTSTS - ret %d\n", ret); - sc->ptn.reg[PTNETMAP_VIRTIO_IO_PTSTS] = ret; + case NET_PARAVIRT_PTCTL_REGIF: + ret = pci_vtnet_ptnetmap_up(sc); break; - case PTNETMAP_VIRTIO_IO_CSBBAH: + case NET_PARAVIRT_PTCTL_UNREGIF: + ret = pci_vtnet_ptnetmap_down(sc); break; - case PTNETMAP_VIRTIO_IO_CSBBAL: - ptnetmap_configure_csb(sc->vsc_vs.vs_pi->pi_vmctx, &sc->ptn.csb, *((uint32_t *)(sc->ptn.reg + PTNETMAP_VIRTIO_IO_CSBBAL)), - *((uint32_t *)(sc->ptn.reg + PTNETMAP_VIRTIO_IO_CSBBAH))); + case NET_PARAVIRT_PTCTL_HOSTMEMID: + ret = ptnetmap_get_hostmemid(sc->ptn.state); break; - default: + case NET_PARAVIRT_PTCTL_IFNEW: + case NET_PARAVIRT_PTCTL_IFDELETE: + case NET_PARAVIRT_PTCTL_FINALIZE: + case NET_PARAVIRT_PTCTL_DEREF: + ret = 0; break; + } + sc->ptn.reg[PTNETMAP_VIRTIO_IO_PTSTS] = ret; + break; + case PTNETMAP_VIRTIO_IO_CSBBAH: + break; + case PTNETMAP_VIRTIO_IO_CSBBAL: + ptnetmap_configure_csb(sc->vsc_vs.vs_pi->pi_vmctx, &sc->ptn.csb, + *((uint32_t *)(sc->ptn.reg + PTNETMAP_VIRTIO_IO_CSBBAL)), + *((uint32_t *)(sc->ptn.reg + PTNETMAP_VIRTIO_IO_CSBBAH))); + break; + default: + break; } - printf("ptnentmap_vtnet: io_write - offset: %d size: %d val: %u\n", offset, size, value); - return (0); } @@ -240,14 +318,14 @@ memcpy(value, &sc->ptn.reg[offset], size); #if 0 switch (offset) { - case PTNETMAP_VIRTIO_IO_PTFEAT: - case PTNETMAP_VIRTIO_IO_PTSTS: - break; - default: - break; + case PTNETMAP_VIRTIO_IO_PTFEAT: + case PTNETMAP_VIRTIO_IO_PTSTS: + break; + default: + printf("pci_vtnet_ptnentmap: write io reg unexpected\n"); + break; } #endif - printf("ptnentmap_vtnet: io_read - offset: %d size: %d ret: %u\n", offset, size, *value); return (0); } Modified: soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/ptnetmap.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/ptnetmap.h Tue Aug 4 15:11:36 2015 (r289211) +++ soc2015/stefano/ptnetmap/stable/10/usr.sbin/bhyve/ptnetmap.h Tue Aug 4 15:22:52 2015 (r289212) @@ -1,3 +1,29 @@ +/* + * Copyright (C) 2015 Stefano Garzarella (stefano.garzarella@gmail.com) + * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. + */ + #ifndef __PTNETMAP_H__ #define __PTNETMAP_H__ From owner-svn-soc-all@freebsd.org Tue Aug 4 15:36:52 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 351879B3DDB for ; Tue, 4 Aug 2015 15:36:52 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 24D0BEB7 for ; Tue, 4 Aug 2015 15:36:52 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t74FaqaB073730 for ; Tue, 4 Aug 2015 15:36:52 GMT (envelope-from stefano@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t74Fanr4073718 for svn-soc-all@FreeBSD.org; Tue, 4 Aug 2015 15:36:49 GMT (envelope-from stefano@FreeBSD.org) Date: Tue, 4 Aug 2015 15:36:49 GMT Message-Id: <201508041536.t74Fanr4073718@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to stefano@FreeBSD.org using -f From: stefano@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289213 - in soc2015/stefano/ptnetmap/stable/10/sys: conf dev/netmap net MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 15:36:52 -0000 Author: stefano Date: Tue Aug 4 15:36:49 2015 New Revision: 289213 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289213 Log: [ptnetmap] extend ptnetmap kthread support for FreeBSD: - add ioctl to send notification (irq) to vm - add tsleep() and implement nm_kthread_wakeup_worker() for FreeBSD to receive notification. - generalize ptnetmap_txsync() and ptnetmap_rxsync() - cleanup Modified: soc2015/stefano/ptnetmap/stable/10/sys/conf/files soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/if_lem_netmap.h soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/if_vtnet_netmap.h soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap.c soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_kern.h soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_mem2.c soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_monitor.c soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_pipe.c soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_vale.c soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_virt.h soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/ptnetmap.c soc2015/stefano/ptnetmap/stable/10/sys/net/netmap.h Modified: soc2015/stefano/ptnetmap/stable/10/sys/conf/files ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/conf/files Tue Aug 4 15:22:52 2015 (r289212) +++ soc2015/stefano/ptnetmap/stable/10/sys/conf/files Tue Aug 4 15:36:49 2015 (r289213) @@ -1941,6 +1941,7 @@ dev/netmap/netmap_offloadings.c optional netmap dev/netmap/netmap_pipe.c optional netmap dev/netmap/netmap_vale.c optional netmap +dev/netmap/ptnetmap.c optional netmap dev/nge/if_nge.c optional nge dev/nxge/if_nxge.c optional nxge \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/if_lem_netmap.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/if_lem_netmap.h Tue Aug 4 15:22:52 2015 (r289212) +++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/if_lem_netmap.h Tue Aug 4 15:36:49 2015 (r289213) @@ -472,7 +472,7 @@ } #if defined (NIC_PTNETMAP) && defined (WITH_PTNETMAP_GUEST) -static uint32_t lem_netmap_ptctl(struct ifnet *, uint32_t); +static uint32_t lem_ptnetmap_ptctl(struct ifnet *, uint32_t); static int lem_ptnetmap_config(struct netmap_adapter *na, @@ -486,7 +486,7 @@ if (csb == NULL) return EINVAL; - ret = lem_netmap_ptctl(ifp, NET_PARAVIRT_PTCTL_CONFIG); + ret = lem_ptnetmap_ptctl(ifp, NET_PARAVIRT_PTCTL_CONFIG); if (ret) return ret; @@ -508,54 +508,14 @@ //u_int ring_nr = kring->ring_id; struct ifnet *ifp = na->ifp; struct adapter *adapter = ifp->if_softc; - struct paravirt_csb *csb = adapter->csb; - bool send_kick = false; - - /* Disable notifications */ - csb->guest_need_txkick = 0; + int ret, notify = 0; - /* - * First part: process new packets to send. - */ - kring->nr_hwcur = csb->tx_ring.hwcur; - ptnetmap_guest_write_kring_csb(&csb->tx_ring, kring->rcur, kring->rhead); - if (kring->rhead != kring->nr_hwcur) { - send_kick = true; - } + ret = ptnetmap_txsync(kring, flags, ¬ify); - /* Send kick to the host if it needs them */ - if ((send_kick && ACCESS_ONCE(csb->host_need_txkick)) || (flags & NAF_FORCE_RECLAIM)) { - csb->tx_ring.sync_flags = flags; + if (notify) E1000_WRITE_REG(&adapter->hw, E1000_TDT(0), 0); - } - /* - * Second part: reclaim buffers for completed transmissions. - */ - if (flags & NAF_FORCE_RECLAIM || nm_kr_txempty(kring)) { - ptnetmap_guest_read_kring_csb(&csb->tx_ring, &kring->nr_hwcur, &kring->nr_hwtail, kring->nkr_num_slots); - } - - /* - * Ring full. The user thread will go to sleep and - * we need a notification (interrupt) from the NIC, - * whene there is free space. - */ - if (kring->rcur == kring->nr_hwtail) { - /* Reenable notifications. */ - csb->guest_need_txkick = 1; - /* Double check */ - ptnetmap_guest_read_kring_csb(&csb->tx_ring, &kring->nr_hwcur, &kring->nr_hwtail, kring->nkr_num_slots); - /* If there is new free space, disable notifications */ - if (kring->rcur != kring->nr_hwtail) { - csb->guest_need_txkick = 0; - } - } - - ND("TX - CSB: head:%u cur:%u hwtail:%u - KRING: head:%u cur:%u", - csb->tx_ring.head, csb->tx_ring.cur, csb->tx_ring.hwtail, kring->rhead, kring->rcur); - - return 0; + return ret; } static int @@ -565,59 +525,14 @@ //u_int ring_nr = kring->ring_id; struct ifnet *ifp = na->ifp; struct adapter *adapter = ifp->if_softc; - struct paravirt_csb *csb = adapter->csb; - - int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR; - uint32_t h_hwcur = kring->nr_hwcur, h_hwtail = kring->nr_hwtail; + int ret, notify = 0; - /* Disable notifications */ - csb->guest_need_rxkick = 0; - - ptnetmap_guest_read_kring_csb(&csb->rx_ring, &h_hwcur, &h_hwtail, kring->nkr_num_slots); - - /* - * First part: import newly received packets. - */ - if (netmap_no_pendintr || force_update) { - kring->nr_hwtail = h_hwtail; - kring->nr_kflags &= ~NKR_PENDINTR; - } - - /* - * Second part: skip past packets that userspace has released. - */ - kring->nr_hwcur = h_hwcur; - if (kring->rhead != kring->nr_hwcur) { - ptnetmap_guest_write_kring_csb(&csb->rx_ring, kring->rcur, kring->rhead); - /* Send kick to the host if it needs them */ - if (ACCESS_ONCE(csb->host_need_rxkick)) { - csb->rx_ring.sync_flags = flags; - E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), 0); - } - } - - /* - * Ring empty. The user thread will go to sleep and - * we need a notification (interrupt) from the NIC, - * whene there are new packets. - */ - if (kring->rcur == kring->nr_hwtail) { - /* Reenable notifications. */ - csb->guest_need_rxkick = 1; - /* Double check */ - ptnetmap_guest_read_kring_csb(&csb->rx_ring, &kring->nr_hwcur, &kring->nr_hwtail, kring->nkr_num_slots); - /* If there are new packets, disable notifications */ - if (kring->rcur != kring->nr_hwtail) { - csb->guest_need_rxkick = 0; - } - } - - ND("RX - CSB: head:%u cur:%u hwtail:%u - KRING: head:%u cur:%u", - csb->rx_ring.head, csb->rx_ring.cur, csb->rx_ring.hwtail, kring->rhead, kring->rcur); - - return 0; + ret = ptnetmap_rxsync(kring, flags, ¬ify); + if (notify) + E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), 0); + return ret; } static int @@ -630,7 +545,7 @@ int ret; if (onoff) { - ret = lem_netmap_ptctl(ifp, NET_PARAVIRT_PTCTL_REGIF); + ret = lem_ptnetmap_ptctl(ifp, NET_PARAVIRT_PTCTL_REGIF); if (ret) return ret; @@ -660,7 +575,7 @@ } else { na->na_flags &= ~NAF_NETMAP_ON; adapter->ptnetmap_enabled = 0; - ret = lem_netmap_ptctl(ifp, NET_PARAVIRT_PTCTL_UNREGIF); + ret = lem_ptnetmap_ptctl(ifp, NET_PARAVIRT_PTCTL_UNREGIF); } return lem_netmap_reg(na, onoff); @@ -673,16 +588,17 @@ return EOPNOTSUPP; } -static struct paravirt_csb * -lem_netmap_getcsb(struct ifnet *ifp) +static void +lem_ptnetmap_setup_csb(struct adapter *adapter) { - struct adapter *adapter = ifp->if_softc; + struct ifnet *ifp = adapter->ifp; + struct netmap_pt_guest_adapter* ptna = (struct netmap_pt_guest_adapter *)NA(ifp); - return adapter->csb; + ptna->csb = adapter->csb; } static uint32_t -lem_netmap_ptctl(struct ifnet *ifp, uint32_t val) +lem_ptnetmap_ptctl(struct ifnet *ifp, uint32_t val) { struct adapter *adapter = ifp->if_softc; uint32_t ret; @@ -704,22 +620,21 @@ E1000_WRITE_REG(&adapter->hw, E1000_PTFEAT, NET_PTN_FEATURES_BASE); /* get back the acknowledged features */ features = E1000_READ_REG(&adapter->hw, E1000_PTFEAT); - device_printf(adapter->dev, "netmap passthrough: %s\n", + device_printf(adapter->dev, "ptnetmap support: %s\n", (features & NET_PTN_FEATURES_BASE) ? "base" : "none"); return features; } static struct netmap_pt_guest_ops lem_ptnetmap_ops = { - .nm_getcsb = lem_netmap_getcsb, - .nm_ptctl = lem_netmap_ptctl, + .nm_ptctl = lem_ptnetmap_ptctl, }; #elif defined (NIC_PTNETMAP) #warning "if_lem supports ptnetmap but netmap does not support it" -#warning "(configure netmap with passthrough support)" +#warning "(configure netmap with ptnetmap support)" #elif defined (WITH_PTNETMAP_GUEST) #warning "netmap supports ptnetmap but e1000 does not support it" -#warning "(configure if_lem with passthrough support)" +#warning "(configure if_lem with ptnetmap support)" #endif /* NIC_PTNETMAP && WITH_PTNETMAP_GUEST */ static void @@ -747,6 +662,7 @@ na.nm_rxsync = lem_ptnetmap_rxsync; na.nm_bdg_attach = lem_ptnetmap_bdg_attach; /* XXX */ netmap_pt_guest_attach(&na, &lem_ptnetmap_ops); + lem_ptnetmap_setup_csb(adapter); } else #endif /* NIC_PTNETMAP && defined WITH_PTNETMAP_GUEST */ netmap_attach(&na); Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/if_vtnet_netmap.h ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/if_vtnet_netmap.h Tue Aug 4 15:22:52 2015 (r289212) +++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/if_vtnet_netmap.h Tue Aug 4 15:36:49 2015 (r289213) @@ -418,7 +418,7 @@ #define PTNETMAP_VIRTIO_IO_BASE sizeof(struct virtio_net_config) #ifndef VIRTIO_NET_F_PTNETMAP -#define VIRTIO_NET_F_PTNETMAP 0x1000000 /* linux/qeum 24 */ +#define VIRTIO_NET_F_PTNETMAP 0x2000000 /* linux/qeum 25 */ #endif /* VIRTIO_NET_F_PTNETMAP */ static void inline @@ -520,130 +520,40 @@ vtnet_ptnetmap_txsync(struct netmap_kring *kring, int flags) { struct netmap_adapter *na = kring->na; - struct netmap_pt_guest_adapter *ptna = (struct netmap_pt_guest_adapter *)na; struct ifnet *ifp = na->ifp; u_int ring_nr = kring->ring_id; - - /* device-specific */ struct SOFTC_T *sc = ifp->if_softc; - struct vtnet_txq *txq = &sc->vtnet_txqs[ring_nr]; - struct virtqueue *vq = txq->vtntx_vq; - struct paravirt_csb *csb = ptna->csb; - bool send_kick = false; + struct virtqueue *vq = sc->vtnet_txqs[ring_nr].vtntx_vq; + int ret, notify = 0; - /* Disable notifications */ - csb->guest_need_txkick = 0; + ret = ptnetmap_txsync(kring, flags, ¬ify); - /* - * First part: process new packets to send. - */ - kring->nr_hwcur = csb->tx_ring.hwcur; - ptnetmap_guest_write_kring_csb(&csb->tx_ring, kring->rcur, kring->rhead); - if (kring->rhead != kring->nr_hwcur) { - send_kick = true; - } - - /* Send kick to the host if it needs them */ - if ((send_kick && ACCESS_ONCE(csb->host_need_txkick)) || (flags & NAF_FORCE_RECLAIM)) { - csb->tx_ring.sync_flags = flags; + if (notify) virtqueue_notify(vq); - } - - /* - * Second part: reclaim buffers for completed transmissions. - */ - if (flags & NAF_FORCE_RECLAIM || nm_kr_txempty(kring)) { - ptnetmap_guest_read_kring_csb(&csb->tx_ring, &kring->nr_hwcur, &kring->nr_hwtail, kring->nkr_num_slots); - } - /* - * Ring full. The user thread will go to sleep and - * we need a notification (interrupt) from the NIC, - * whene there is free space. - */ - if (kring->rcur == kring->nr_hwtail) { - /* Reenable notifications. */ - csb->guest_need_txkick = 1; - /* Double check */ - ptnetmap_guest_read_kring_csb(&csb->tx_ring, &kring->nr_hwcur, &kring->nr_hwtail, kring->nkr_num_slots); - /* If there is new free space, disable notifications */ - if (kring->rcur != kring->nr_hwtail) { - csb->guest_need_txkick = 0; - } - } - - - ND(1,"TX - CSB: head:%u cur:%u hwtail:%u - KRING: head:%u cur:%u tail: %u", - csb->tx_ring.head, csb->tx_ring.cur, csb->tx_ring.hwtail, kring->rhead, kring->rcur, kring->nr_hwtail); ND("TX - vq_index: %d", vq->index); - return 0; + return ret; } static int vtnet_ptnetmap_rxsync(struct netmap_kring *kring, int flags) { struct netmap_adapter *na = kring->na; - struct netmap_pt_guest_adapter *ptna = (struct netmap_pt_guest_adapter *)na; struct ifnet *ifp = na->ifp; u_int ring_nr = kring->ring_id; - - /* device-specific */ struct SOFTC_T *sc = ifp->if_softc; - struct vtnet_rxq *rxq = &sc->vtnet_rxqs[ring_nr]; - struct virtqueue *vq = rxq->vtnrx_vq; - struct paravirt_csb *csb = ptna->csb; - - int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR; - uint32_t h_hwcur = kring->nr_hwcur, h_hwtail = kring->nr_hwtail; - - /* Disable notifications */ - csb->guest_need_rxkick = 0; + struct virtqueue *vq = sc->vtnet_rxqs[ring_nr].vtnrx_vq; + int ret, notify = 0; - ptnetmap_guest_read_kring_csb(&csb->rx_ring, &h_hwcur, &h_hwtail, kring->nkr_num_slots); - - /* - * First part: import newly received packets. - */ - if (netmap_no_pendintr || force_update) { - kring->nr_hwtail = h_hwtail; - kring->nr_kflags &= ~NKR_PENDINTR; - } - - /* - * Second part: skip past packets that userspace has released. - */ - kring->nr_hwcur = h_hwcur; - if (kring->rhead != kring->nr_hwcur) { - ptnetmap_guest_write_kring_csb(&csb->rx_ring, kring->rcur, kring->rhead); - /* Send kick to the host if it needs them */ - if (ACCESS_ONCE(csb->host_need_rxkick)) { - csb->rx_ring.sync_flags = flags; - virtqueue_notify(vq); - } - } + ret = ptnetmap_rxsync(kring, flags, ¬ify); - /* - * Ring empty. The user thread will go to sleep and - * we need a notification (interrupt) from the NIC, - * whene there are new packets. - */ - if (kring->rcur == kring->nr_hwtail) { - /* Reenable notifications. */ - csb->guest_need_rxkick = 1; - /* Double check */ - ptnetmap_guest_read_kring_csb(&csb->rx_ring, &kring->nr_hwcur, &kring->nr_hwtail, kring->nkr_num_slots); - /* If there are new packets, disable notifications */ - if (kring->rcur != kring->nr_hwtail) { - csb->guest_need_rxkick = 0; - } - } + if (notify) + virtqueue_notify(vq); - ND("RX - CSB: head:%u cur:%u hwtail:%u - KRING: head:%u cur:%u", - csb->rx_ring.head, csb->rx_ring.cur, csb->rx_ring.hwtail, kring->rhead, kring->rcur); ND("RX - vq_index: %d", vq->index); - return 0; + return ret; } static int @@ -721,14 +631,6 @@ return EOPNOTSUPP; } -static struct paravirt_csb * -vtnet_ptnetmap_getcsb(struct ifnet *ifp) -{ - struct netmap_pt_guest_adapter *ptna = (struct netmap_pt_guest_adapter *)NA(ifp); - - return ptna->csb; -} - static uint32_t vtnet_ptnetmap_ptctl(struct ifnet *ifp, uint32_t val) { @@ -753,7 +655,7 @@ vtnet_ptnetmap_iowrite4(dev, PTNETMAP_VIRTIO_IO_PTFEAT, NET_PTN_FEATURES_BASE); /* get back the acknowledged features */ features = vtnet_ptnetmap_ioread4(dev, PTNETMAP_VIRTIO_IO_PTFEAT); - D("netmap passthrough: %s\n", + D("ptnetmap support: %s\n", (features & NET_PTN_FEATURES_BASE) ? "base" : "none"); return features; @@ -769,7 +671,6 @@ } static struct netmap_pt_guest_ops vtnet_ptnetmap_ops = { - .nm_getcsb = vtnet_ptnetmap_getcsb, /* TODO: remove */ .nm_ptctl = vtnet_ptnetmap_ptctl, }; #endif /* WITH_PTNETMAP_GUEST */ Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap.c Tue Aug 4 15:22:52 2015 (r289212) +++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap.c Tue Aug 4 15:36:49 2015 (r289213) @@ -542,6 +542,7 @@ SYSCTL_INT(_dev_netmap, OID_AUTO, generic_rings, CTLFLAG_RW, &netmap_generic_rings, 0 , ""); NMG_LOCK_T netmap_global_lock; +int netmap_use_count = 0; /* number of active netmap instances */ /* * mark the ring as stopped, and run through the locks @@ -726,6 +727,9 @@ return 1; } +static void netmap_txsync_to_host(struct netmap_adapter *na); +static int netmap_rxsync_from_host(struct netmap_adapter *na, struct thread *td, void *pwait); + /* kring->nm_sync callback for the host tx ring */ static int netmap_txsync_to_host_compat(struct netmap_kring *kring, int flags) @@ -959,11 +963,12 @@ } /* - * Destructor of the netmap_priv_d, called when the fd has - * no active open() and mmap(). - * Undo all the things done by NIOCREGIF. + * Destructor of the netmap_priv_d, called when the fd is closed + * Action: undo all the things done by NIOCREGIF, + * On FreeBSD we need to track whether there are active mmap()s, + * and we use np_active_mmaps for that. On linux, the field is always 0. + * Return: 1 if we can free priv, 0 otherwise. * - * returns 1 if this is the last instance and we can free priv */ /* call with NMG_LOCK held */ int @@ -971,17 +976,13 @@ { struct netmap_adapter *na = priv->np_na; -#ifdef __FreeBSD__ - /* - * np_refcount is the number of active mmaps on - * this file descriptor - */ - if (--priv->np_refcount > 0) { + /* number of active references to this fd */ + if (--priv->np_refs > 0) { return 0; } -#endif /* __FreeBSD__ */ + netmap_use_count--; if (!na) { - return 1; //XXX is it correct? + return 1; //XXX is it correct? } netmap_do_unregif(priv); netmap_adapter_put(na); @@ -1139,7 +1140,7 @@ * can be among multiple user threads erroneously calling * this routine concurrently. */ -void +static void netmap_txsync_to_host(struct netmap_adapter *na) { struct netmap_kring *kring = &na->tx_rings[na->num_tx_rings]; @@ -1177,7 +1178,7 @@ * returns the number of packets delivered to tx queues in * transparent mode, or a negative value if error */ -int +static int netmap_rxsync_from_host(struct netmap_adapter *na, struct thread *td, void *pwait) { struct netmap_kring *kring = &na->rx_rings[na->num_rx_rings]; @@ -1388,7 +1389,7 @@ * !0 !NULL impossible */ - /* try to see if this is a passthrough port */ + /* try to see if this is a ptnetmap port */ error = netmap_get_pt_host_na(nmr, na, create); if (error || *na != NULL) return error; @@ -1454,15 +1455,17 @@ * hwcur, rhead, rtail and hwtail are reliable */ u_int -nm_txsync_prologue(struct netmap_kring *kring, uint32_t head, uint32_t cur, uint32_t *tail) +nm_txsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring) { #define NM_ASSERT(t) if (t) { D("fail " #t); goto error; } + u_int head = ring->head; /* read only once */ + u_int cur = ring->cur; /* read only once */ u_int n = kring->nkr_num_slots; ND(5, "%s kcur %d ktail %d head %d cur %d tail %d", kring->name, kring->nr_hwcur, kring->nr_hwtail, - head, cur, tail ? *tail : 0); + ring->head, ring->cur, ring->tail); #if 1 /* kernel sanity checks; but we can trust the kring. */ if (kring->nr_hwcur >= n || kring->rhead >= n || kring->rtail >= n || kring->nr_hwtail >= n) @@ -1495,10 +1498,10 @@ NM_ASSERT(cur > kring->rtail && cur < head); } } - if (tail && *tail != kring->rtail) { + if (ring->tail != kring->rtail) { RD(5, "tail overwritten was %d need %d", - *tail, kring->rtail); - *tail = kring->rtail; + ring->tail, kring->rtail); + ring->tail = kring->rtail; } kring->rhead = head; kring->rcur = cur; @@ -1507,7 +1510,7 @@ error: RD(5, "%s kring error: head %d cur %d tail %d rhead %d rcur %d rtail %d hwcur %d hwtail %d", kring->name, - head, cur, tail ? *tail : 0, + head, cur, ring->tail, kring->rhead, kring->rcur, kring->rtail, kring->nr_hwcur, kring->nr_hwtail); return n; @@ -1527,14 +1530,15 @@ * */ u_int -nm_rxsync_prologue(struct netmap_kring *kring, uint32_t head, uint32_t cur, uint32_t *tail) +nm_rxsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring) { uint32_t const n = kring->nkr_num_slots; + uint32_t head, cur; ND(5,"%s kc %d kt %d h %d c %d t %d", kring->name, kring->nr_hwcur, kring->nr_hwtail, - head, cur, tail ? *tail : 0); + ring->head, ring->cur, ring->tail); /* * Before storing the new values, we should check they do not * move backwards. However: @@ -1542,8 +1546,8 @@ * - cur could in principle go back, however it does not matter * because we are processing a brand new rxsync() */ - kring->rcur = cur; /* read only once */ - kring->rhead = head; /* read only once */ + cur = kring->rcur = ring->cur; /* read only once */ + head = kring->rhead = ring->head; /* read only once */ #if 1 /* kernel sanity checks */ if (kring->nr_hwcur >= n || kring->nr_hwtail >= n) goto error; @@ -1571,11 +1575,11 @@ goto error; } } - if (tail && *tail != kring->rtail) { + if (ring->tail != kring->rtail) { RD(5, "%s tail overwritten was %d need %d", kring->name, - *tail, kring->rtail); - *tail = kring->rtail; + ring->tail, kring->rtail); + ring->tail = kring->rtail; } return head; @@ -1583,7 +1587,7 @@ RD(5, "kring error: hwcur %d rcur %d hwtail %d head %d cur %d tail %d", kring->nr_hwcur, kring->rcur, kring->nr_hwtail, - kring->rhead, kring->rcur, tail ? *tail : 0); + kring->rhead, kring->rcur, ring->tail); return n; } @@ -2025,6 +2029,41 @@ } +/* + * update kring and ring at the end of txsync. + */ +static inline void +nm_txsync_finalize(struct netmap_kring *kring) +{ + /* update ring tail to what the kernel knows */ + kring->ring->tail = kring->rtail = kring->nr_hwtail; + + /* note, head/rhead/hwcur might be behind cur/rcur + * if no carrier + */ + ND(5, "%s now hwcur %d hwtail %d head %d cur %d tail %d", + kring->name, kring->nr_hwcur, kring->nr_hwtail, + kring->rhead, kring->rcur, kring->rtail); +} + + +/* + * update kring and ring at the end of rxsync + */ +static inline void +nm_rxsync_finalize(struct netmap_kring *kring) +{ + /* tell userspace that there might be new packets */ + //struct netmap_ring *ring = kring->ring; + ND("head %d cur %d tail %d -> %d", ring->head, ring->cur, ring->tail, + kring->nr_hwtail); + kring->ring->tail = kring->rtail = kring->nr_hwtail; + /* make a copy of the state for next round */ + kring->rhead = kring->ring->head; + kring->rcur = kring->ring->cur; +} + + /* * ioctl(2) support for the "netmap" device. @@ -2232,8 +2271,7 @@ D("pre txsync ring %d cur %d hwcur %d", i, ring->cur, kring->nr_hwcur); - if (nm_txsync_prologue(kring, ring->head, ring->cur, - &ring->tail) >= kring->nkr_num_slots) { + if (nm_txsync_prologue(kring, ring) >= kring->nkr_num_slots) { netmap_ring_reinit(kring); } else if (kring->nm_sync(kring, NAF_FORCE_RECLAIM) == 0) { nm_txsync_finalize(kring); @@ -2243,8 +2281,7 @@ i, ring->cur, kring->nr_hwcur); } else { - if (nm_rxsync_prologue(kring, ring->head, ring->cur, - &ring->tail) >= kring->nkr_num_slots) { + if (nm_rxsync_prologue(kring, ring) >= kring->nkr_num_slots) { netmap_ring_reinit(kring); } else if (kring->nm_sync(kring, NAF_FORCE_READ) == 0) { nm_rxsync_finalize(kring); @@ -2440,8 +2477,7 @@ priv, i); continue; } - if (nm_txsync_prologue(kring, ring->head, ring->cur, - &ring->tail) >= kring->nkr_num_slots) { + if (nm_txsync_prologue(kring, ring) >= kring->nkr_num_slots) { netmap_ring_reinit(kring); revents |= POLLERR; } else { @@ -2494,8 +2530,7 @@ continue; } - if (nm_rxsync_prologue(kring, ring->head, ring->cur, - &ring->tail) >= kring->nkr_num_slots) { + if (nm_rxsync_prologue(kring, ring) >= kring->nkr_num_slots) { netmap_ring_reinit(kring); revents |= POLLERR; } Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c Tue Aug 4 15:22:52 2015 (r289212) +++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c Tue Aug 4 15:36:49 2015 (r289213) @@ -35,6 +35,7 @@ #include /* types used in module initialization */ #include /* DEV_MODULE */ #include +#include /* kern_ioctl() */ #include @@ -823,7 +824,7 @@ goto err_unlock; } vmh->priv = priv; - priv->np_refcount++; + priv->np_refs++; NMG_UNLOCK(); obj = cdev_pager_allocate(vmh, OBJT_DEVICE, @@ -840,7 +841,7 @@ err_deref: NMG_LOCK(); - priv->np_refcount--; + priv->np_refs--; err_unlock: NMG_UNLOCK(); // err: @@ -849,14 +850,14 @@ } /* - * netmap_close() is called on every close(), but we do not need to do - * anything at that moment, since the process may have other open file - * descriptors for /dev/netmap. Instead, we pass netmap_dtor() to + * On FreeBSD the close routine is only called on the last close on + * the device (/dev/netmap) so we cannot do anything useful. + * To track close() on individual file descriptors we pass netmap_dtor() to * devfs_set_cdevpriv() on open(). The FreeBSD kernel will call the destructor * when the last fd pointing to the device is closed. * - * Unfortunately, FreeBSD does not automatically track active mmap()s on an fd, - * so we have to track them by ourselvesi (see above). The result is that + * Note that FreeBSD does not even munmap() on close() so we also have + * to track mmap() ourselves, and postpone the call to * netmap_dtor() is called when the process has no open fds and no active * memory maps on /dev/netmap, as in linux. */ @@ -881,36 +882,29 @@ (void)devtype; (void)td; - // XXX wait or nowait ? priv = malloc(sizeof(struct netmap_priv_d), M_DEVBUF, M_NOWAIT | M_ZERO); if (priv == NULL) return ENOMEM; - + priv->np_refs = 1; error = devfs_set_cdevpriv(priv, netmap_dtor); - if (error) - return error; - - priv->np_refcount = 1; - - return 0; + if (error) { + free(priv, M_DEVBUF); + } else { + NMG_LOCK(); + netmap_use_count++; + NMG_UNLOCK(); + } + return error; } /******************** kthread wrapper ****************/ +#include + struct nm_kthread_ctx { - void *ioevent_file; - void *irq_file; -#if 0 /* to be dane after eventfd implementation */ - /* files to exchange notifications */ - struct file *ioevent_file; /* notification from guest */ - struct file *irq_file; /* notification to guest (interrupt) */ - struct eventfd_ctx *irq_ctx; - - /* poll ioeventfd to receive notification from the guest */ - poll_table poll_table; - wait_queue_head_t *waitq_head; - wait_queue_t waitq; -#endif /* 0 */ + struct thread *user_td; /* thread user-space (kthread creator) to send ioctl */ + struct ioctl_args irq_ioctl; /* notification to guest (interrupt) */ + void *ioevent_file; /* notification from guest */ /* worker function and parameter */ nm_kthread_worker_fn_t worker_fn; @@ -923,46 +917,45 @@ }; struct nm_kthread { - //struct mm_struct *mm; struct thread *worker; struct mtx worker_lock; - uint64_t scheduled; /* currently not used */ + uint64_t scheduled; /* pending wake_up request */ struct nm_kthread_ctx worker_ctx; + int run; /* used to stop kthread */ int affinity; }; void inline nm_kthread_wakeup_worker(struct nm_kthread *nmk) { - (void)nmk; + /* + * There may be a race between FE and BE, + * which call both this function, and worker kthread, + * that reads nmk->scheduled. + * + * For us it is not important the counter value, + * but simply that it has changed since the last + * time the kthread saw it. + */ + nmk->scheduled++; + if (nmk->worker_ctx.ioevent_file) { + wakeup(nmk->worker_ctx.ioevent_file); + } } void inline nm_kthread_send_irq(struct nm_kthread *nmk) { - (void)nmk; -} - -static -int is_suspended(void) -{ - struct proc *p; - struct thread *td; - int ret = 0; - - td = curthread; - p = td->td_proc; + struct nm_kthread_ctx *ctx = &nmk->worker_ctx; + int err; - if ((td->td_pflags & TDP_KTHREAD) == 0) - panic("%s: curthread is not a valid kthread", __func__); - PROC_LOCK(p); - if (td->td_flags & TDF_KTH_SUSP) { - wakeup(&td->td_flags); - //msleep(&td->td_flags, &p->p_mtx, PPAUSE, "ktsusp", 0); - ret = 1; + if (ctx->irq_ioctl.fd > 0) { + err = kern_ioctl(ctx->user_td, ctx->irq_ioctl.fd, ctx->irq_ioctl.com, ctx->irq_ioctl.data); + if (err) { + D("kern_ioctl error: %d ioctl parameters: fd %d com %lu data %p", + err, ctx->irq_ioctl.fd, ctx->irq_ioctl.com, ctx->irq_ioctl.data); + } } - PROC_UNLOCK(p); - return ret; } static void @@ -970,53 +963,57 @@ { struct nm_kthread *nmk = data; struct nm_kthread_ctx *ctx = &nmk->worker_ctx; + uint64_t old_scheduled = 0, new_scheduled = 0; thread_lock(curthread); - if (nmk->affinity >= 0) + if (nmk->affinity >= 0) { sched_bind(curthread, nmk->affinity); - thread_unlock(curthread); - for (; !is_suspended();) { - if (nmk->worker == NULL) - break; - ctx->worker_fn(ctx->worker_private); /* worker_body */ } - kthread_exit(); -} + thread_unlock(curthread); -static int -nm_kthread_open_files(struct nm_kthread *nmk, struct nm_eventfd_cfg_ring *ring_cfg) -{ - (void)nmk; - (void)ring_cfg; - return 0; -} + while (nmk->run) { + kthread_suspend_check(); -static void -nm_kthread_close_files(struct nm_kthread *nmk) -{ - (void)nmk; -} + new_scheduled = nmk->scheduled; -static void -nm_kthread_init_poll(struct nm_kthread *nmk, struct nm_kthread_ctx *ctx) -{ - (void)nmk; - (void)ctx; - return; + /* checks if there is a pending notification */ + if (likely(new_scheduled != old_scheduled)) { + old_scheduled = new_scheduled; + ctx->worker_fn(ctx->worker_private); /* worker_body */ + } else if (nmk->run) { + if (ctx->ioevent_file) { + /* wait on event with timetout 1 second */ + tsleep_sbt(ctx->ioevent_file, PPAUSE, "nmk_event", SBT_1S, SBT_1MS, C_ABSOLUTE); + nmk->scheduled++; + } + } + } + + kthread_exit(); } static int -nm_kthread_start_poll(struct nm_kthread_ctx *ctx, void *file) +nm_kthread_open_files(struct nm_kthread *nmk, struct nm_kthread_cfg *cfg) { - (void)ctx; - (void)file; + /* send irq through ioctl to bhyve (vmm.ko) */ + if (cfg->ring.irqfd) { + nmk->worker_ctx.irq_ioctl.fd = cfg->ring.irqfd; + nmk->worker_ctx.irq_ioctl.com = cfg->ioctl.com; + nmk->worker_ctx.irq_ioctl.data = (caddr_t)cfg->ioctl.data; + } + /* ring.ioeventfd contains the chan where do tsleep to wait events */ + if (cfg->ring.ioeventfd) { + nmk->worker_ctx.ioevent_file = (void *)cfg->ring.ioeventfd; + } + return 0; } static void -nm_kthread_stop_poll(struct nm_kthread_ctx *ctx) +nm_kthread_close_files(struct nm_kthread *nmk) { - (void)ctx; + nmk->worker_ctx.irq_ioctl.fd = 0; + nmk->worker_ctx.ioevent_file = NULL; } void @@ -1036,16 +1033,16 @@ return NULL; mtx_init(&nmk->worker_lock, "nm_kthread lock", NULL, MTX_DEF); + nmk->worker_ctx.user_td = curthread; nmk->worker_ctx.worker_fn = cfg->worker_fn; nmk->worker_ctx.worker_private = cfg->worker_private; nmk->worker_ctx.type = cfg->type; nmk->affinity = -1; /* open event fd */ - error = nm_kthread_open_files(nmk, &cfg->ring); + error = nm_kthread_open_files(nmk, cfg); if (error) goto err; - nm_kthread_init_poll(nmk, &nmk->worker_ctx); return nmk; err: @@ -1061,21 +1058,20 @@ if (nmk->worker) { return EBUSY; } - - error = kthread_add(nm_kthread_worker, nmk, curproc, + /* enable kthread main loop */ + nmk->run = 1; + /* create kthread */ + if((error = kthread_add(nm_kthread_worker, nmk, curproc, &nmk->worker, RFNOWAIT /* to be checked */, 0, "nm-kthread-%ld", - nmk->worker_ctx.type); - if (error) + nmk->worker_ctx.type))) { goto err; - D("started td 0x%p", nmk->worker); + } + + D("nm_kthread started td 0x%p", nmk->worker); - error = nm_kthread_start_poll(&nmk->worker_ctx, nmk->worker_ctx.ioevent_file); - if (error) - goto err_kstop; return 0; -err_kstop: - kthread_suspend(nmk->worker, 0); err: + D("nm_kthread start failed err %d", error); nmk->worker = NULL; return error; } @@ -1086,8 +1082,13 @@ if (!nmk->worker) { return; } - nm_kthread_stop_poll(&nmk->worker_ctx); - kthread_suspend(nmk->worker, 100); + /* tell to kthread to exit from main loop */ + nmk->run = 0; + + /* wake up kthread if it sleeps */ + kthread_resume(nmk->worker); + nm_kthread_wakeup_worker(nmk); + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@freebsd.org Tue Aug 4 16:38:08 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C9E79B2F95 for ; Tue, 4 Aug 2015 16:38:08 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5DCC4D45 for ; Tue, 4 Aug 2015 16:38:08 +0000 (UTC) (envelope-from stefano@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t74Gc8fq073506 for ; Tue, 4 Aug 2015 16:38:08 GMT (envelope-from stefano@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t74Gc7FZ073497 for svn-soc-all@FreeBSD.org; Tue, 4 Aug 2015 16:38:07 GMT (envelope-from stefano@FreeBSD.org) Date: Tue, 4 Aug 2015 16:38:07 GMT Message-Id: <201508041638.t74Gc7FZ073497@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to stefano@FreeBSD.org using -f From: stefano@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289216 - soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 16:38:08 -0000 Author: stefano Date: Tue Aug 4 16:38:07 2015 New Revision: 289216 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289216 Log: [ptnetmap] use thread_suspend_check() instead of kthread_suspend_check() thread_suspend_check() must be used if the kthread is attached to user process Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c ============================================================================== --- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c Tue Aug 4 15:15:06 2015 (r289215) +++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c Tue Aug 4 16:38:07 2015 (r289216) @@ -972,7 +972,13 @@ thread_unlock(curthread); while (nmk->run) { + /* check if the parent process dies */ + PROC_LOCK(curproc); + thread_suspend_check(0); + PROC_UNLOCK(curproc); +#if 0 kthread_suspend_check(); +#endif new_scheduled = nmk->scheduled; @@ -983,7 +989,7 @@ } else if (nmk->run) { if (ctx->ioevent_file) { /* wait on event with timetout 1 second */ - tsleep_sbt(ctx->ioevent_file, PPAUSE, "nmk_event", SBT_1S, SBT_1MS, C_ABSOLUTE); + tsleep_sbt(ctx->ioevent_file, PPAUSE, "nmk_event", SBT_1S, SBT_1S, C_ABSOLUTE); nmk->scheduled++; } } From owner-svn-soc-all@freebsd.org Wed Aug 5 15:40:56 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD9459B4965 for ; Wed, 5 Aug 2015 15:40:56 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B3D51000 for ; Wed, 5 Aug 2015 15:40:56 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t75FeuW5001370 for ; Wed, 5 Aug 2015 15:40:56 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t75FetgJ000784 for svn-soc-all@FreeBSD.org; Wed, 5 Aug 2015 15:40:55 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Wed, 5 Aug 2015 15:40:55 GMT Message-Id: <201508051540.t75FetgJ000784@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289247 - in soc2015/pratiksinghal/cubie-head/sys/arm: allwinner conf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Aug 2015 15:40:56 -0000 Author: pratiksinghal Date: Wed Aug 5 15:40:54 2015 New Revision: 289247 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289247 Log: Removed the errors, however the module attach function is not being called so far. Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/files.allwinner soc2015/pratiksinghal/cubie-head/sys/arm/conf/CUBIEBOARD Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c Wed Aug 5 14:45:52 2015 (r289246) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c Wed Aug 5 15:40:54 2015 (r289247) @@ -30,12 +30,13 @@ #include #include #include -#include +#include #include +#include +#include #include - -#include +#include #include "a10_ac97.h" @@ -85,17 +86,16 @@ * Enable Codec Ready interrupt */ -static ac97_attach(device_t dev) +static int ac97_attach(device_t dev) { struct a10_ac97_info *sc; - device_t gpio; int error; sc = device_get_softc(dev); sc->ac_dev = dev; sc->use_dma = 0; error = 0; - ienab = 0; + sc->ienab = 0; sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid, RF_ACTIVE); if (sc->mem_res == NULL) { @@ -108,7 +108,7 @@ goto fail; } error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, - NULL, ac97_intr, &sc->intr_handle); + NULL, NULL, sc,&sc->intr_handle); if (error) { device_printf(dev, "Cannot setup interrupt handler %d\n", error); goto fail; @@ -118,17 +118,17 @@ mtx_init(&sc->ac97_mtx, device_get_nameunit(dev), "a10_ac97", MTX_DEF); - device_printf("Before resetting device"); + device_printf(dev,"Before resetting device"); uint32_t val,total; - AC97_WRITE(sc, AC_CTL, AC_WARM_RST) + AC97_WRITE(sc, AC_CTL, AC_WARM_RST); total = 0; while (1) { val = AC97_READ(sc, AC_CTL); - if ((val >> 1) & 1 == 0) + if (((val >> 1) & 1) == 0) break; else - DELAY(2) + DELAY(2); total += 2; if (total > 40) break; @@ -145,7 +145,7 @@ fail: if (sc->mem_res != NULL) - bus_release_resouce(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res); + bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res); if (sc->irq_res != NULL) { bus_teardown_intr(dev, sc->irq_res, sc->intr_handle); bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq_res); @@ -155,7 +155,7 @@ return (ENXIO); } -static ac97_detach(device_t dev) +static int ac97_detach(device_t dev) { return (EBUSY); } @@ -173,7 +173,7 @@ static driver_t a10_ac97_driver = { "a10_ac97", a10_ac97_methods, - sizeof(struct a10_ac97_info); + sizeof(struct a10_ac97_info) }; DRIVER_MODULE(a10_ac97, pci, a10_ac97_driver, a10_ac97_devclass, 0, 0); Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/files.allwinner ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/files.allwinner Wed Aug 5 14:45:52 2015 (r289246) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/files.allwinner Wed Aug 5 15:40:54 2015 (r289247) @@ -8,7 +8,7 @@ arm/allwinner/a10_ahci.c optional ahci arm/allwinner/a10_clk.c standard arm/allwinner/a10_common.c standard -arm/allwinner/a10_ac97.c optional ac97 +arm/allwinner/a10_ac97.c optional sound arm/allwinner/a10_dma.c optional dma arm/allwinner/a10_ehci.c optional ehci arm/allwinner/a10_gpio.c optional gpio Modified: soc2015/pratiksinghal/cubie-head/sys/arm/conf/CUBIEBOARD ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/conf/CUBIEBOARD Wed Aug 5 14:45:52 2015 (r289246) +++ soc2015/pratiksinghal/cubie-head/sys/arm/conf/CUBIEBOARD Wed Aug 5 15:40:54 2015 (r289247) @@ -107,7 +107,7 @@ device miibus # AC97 Interface -device ac97 +device sound # Flattened Device Tree options FDT # Configure using FDT/DTB data From owner-svn-soc-all@freebsd.org Thu Aug 6 07:27:59 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF7D99B54AD for ; Thu, 6 Aug 2015 07:27:59 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0A9B31A for ; Thu, 6 Aug 2015 07:27:59 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t767RxiN008830 for ; Thu, 6 Aug 2015 07:27:59 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t767RxwA008813 for svn-soc-all@FreeBSD.org; Thu, 6 Aug 2015 07:27:59 GMT (envelope-from kczekirda@FreeBSD.org) Date: Thu, 6 Aug 2015 07:27:59 GMT Message-Id: <201508060727.t767RxwA008813@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289286 - soc2015/kczekirda/www MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2015 07:28:00 -0000 Author: kczekirda Date: Thu Aug 6 07:27:58 2015 New Revision: 289286 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289286 Log: first task status: new Modified: soc2015/kczekirda/www/menu.py Modified: soc2015/kczekirda/www/menu.py ============================================================================== --- soc2015/kczekirda/www/menu.py Thu Aug 6 06:47:28 2015 (r289285) +++ soc2015/kczekirda/www/menu.py Thu Aug 6 07:27:58 2015 (r289286) @@ -99,7 +99,7 @@ revision = request.GET.get('revision','').strip() conn = sqlite3.connect(database) c = conn.cursor() - c.execute("INSERT INTO tasks (revision) VALUES (?)", (revision,)) + c.execute("INSERT INTO tasks (revision,status) VALUES (?,?)", (revision,"new",)) conn.commit() c.close() return redirect('/admin') From owner-svn-soc-all@freebsd.org Thu Aug 6 20:58:49 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E0BCC9B51E9 for ; Thu, 6 Aug 2015 20:58:49 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1EFC1866 for ; Thu, 6 Aug 2015 20:58:49 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t76KwnlU074574 for ; Thu, 6 Aug 2015 20:58:49 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t76KwnkQ074558 for svn-soc-all@FreeBSD.org; Thu, 6 Aug 2015 20:58:49 GMT (envelope-from kczekirda@FreeBSD.org) Date: Thu, 6 Aug 2015 20:58:49 GMT Message-Id: <201508062058.t76KwnkQ074558@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289315 - soc2015/kczekirda/www MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2015 20:58:50 -0000 Author: kczekirda Date: Thu Aug 6 20:58:48 2015 New Revision: 289315 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289315 Log: tasks management - take task and changee task status funcions Modified: soc2015/kczekirda/www/menu.py Modified: soc2015/kczekirda/www/menu.py ============================================================================== --- soc2015/kczekirda/www/menu.py Thu Aug 6 19:53:41 2015 (r289314) +++ soc2015/kczekirda/www/menu.py Thu Aug 6 20:58:48 2015 (r289315) @@ -116,7 +116,23 @@ return redirect('/admin') else: return template(delete_task_tpl,revision=revision) - + +@route('/admin/change_status/:revision/:new_status', method='GET') +def change_status(revision,new_status): + conn = sqlite3.connect(database) + c = conn.cursor() + c.execute("UPDATE tasks SET status = ? WHERE revision LIKE ?", (new_status,revision)) + conn.commit() + return redirect('/admin') + +@route('/admin/take_task/:revision/:host', method='GET') +def take_task(revision,host): + conn = sqlite3.connect(database) + c = conn.cursor() + c.execute("UPDATE tasks SET host = ? WHERE revision LIKE ?", (host,revision)) + conn.commit() + return redirect('/admin') + @route('/menu/:mac', method='GET') def static(mac): conn = sqlite3.connect(database) From owner-svn-soc-all@freebsd.org Fri Aug 7 16:13:27 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9780E9B421F for ; Fri, 7 Aug 2015 16:13:27 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 663657DA for ; Fri, 7 Aug 2015 16:13:27 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t77GDRU8013018 for ; Fri, 7 Aug 2015 16:13:27 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t77GDQg8013002 for svn-soc-all@FreeBSD.org; Fri, 7 Aug 2015 16:13:26 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Fri, 7 Aug 2015 16:13:26 GMT Message-Id: <201508071613.t77GDQg8013002@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r289344 - in soc2015/pratiksinghal/cubie-head/sys: arm/allwinner boot/fdt/dts/arm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Aug 2015 16:13:27 -0000 Author: pratiksinghal Date: Fri Aug 7 16:13:25 2015 New Revision: 289344 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289344 Log: Device now being recognized and getting resetted properly. Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c soc2015/pratiksinghal/cubie-head/sys/boot/fdt/dts/arm/sun4i-a10.dtsi Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c Fri Aug 7 14:38:26 2015 (r289343) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c Fri Aug 7 16:13:25 2015 (r289344) @@ -72,12 +72,9 @@ static int ac97_probe(device_t dev) { - if (!ofw_bus_status_okay(dev)) - return (ENXIO); if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-a10-ac97")) return (ENXIO); device_set_desc(dev, "Allwinner AC97 Controller"); - return (BUS_PROBE_DEFAULT); } @@ -118,8 +115,6 @@ mtx_init(&sc->ac97_mtx, device_get_nameunit(dev), "a10_ac97", MTX_DEF); - device_printf(dev,"Before resetting device"); - uint32_t val,total; AC97_WRITE(sc, AC_CTL, AC_WARM_RST); total = 0; @@ -136,7 +131,8 @@ if (total > 40) device_printf(dev, "Device timedout\n"); else - device_printf(dev, "Device reset succesfully after %d seconds\n",total); + device_printf(dev, "Device reset succesfully\n"); + sc->ienab = AC_CODEC_READY_INT_EN; AC97_WRITE(sc, AC_INT, 0); AC97_WRITE(sc, AC_INT, sc->ienab); @@ -176,4 +172,4 @@ sizeof(struct a10_ac97_info) }; -DRIVER_MODULE(a10_ac97, pci, a10_ac97_driver, a10_ac97_devclass, 0, 0); +DRIVER_MODULE(a10_ac97, simplebus, a10_ac97_driver, a10_ac97_devclass, 0, 0); Modified: soc2015/pratiksinghal/cubie-head/sys/boot/fdt/dts/arm/sun4i-a10.dtsi ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/boot/fdt/dts/arm/sun4i-a10.dtsi Fri Aug 7 14:38:26 2015 (r289343) +++ soc2015/pratiksinghal/cubie-head/sys/boot/fdt/dts/arm/sun4i-a10.dtsi Fri Aug 7 16:13:25 2015 (r289344) @@ -129,8 +129,8 @@ ac97@01c21400 { compatible = "allwinner,sun4i-a10-ac97"; - reg = <0x01C214000 0x1000>; - interrupts = <46>; + reg = <0x01c21400 0x1000>; + interrupts = <14>; interrupt-parent = <&AINTC>; status = "disabled"; };