Skip to content

Commit

Permalink
Merge PR #778 (v2016.03 release) onto master
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Mar 1, 2016
2 parents 0d6470d + 0ae7382 commit ed346d5
Show file tree
Hide file tree
Showing 187 changed files with 1,194 additions and 295 deletions.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,17 @@ clean:
(cd lib/luajit && $(MAKE) clean)
(cd src; $(MAKE) clean; rm -rf syscall.lua syscall)

PACKAGE:=snabbswitch
DIST_BINARY:=snabb
BUILDDIR:=$(shell pwd)

dist: DISTDIR:=$(BUILDDIR)/$(PACKAGE)-$(shell git describe --tags)
dist: all
mkdir "$(DISTDIR)"
git clone "$(BUILDDIR)" "$(DISTDIR)/snabbswitch"
rm -rf "$(DISTDIR)/snabbswitch/.git"
cp "$(BUILDDIR)/src/snabb" "$(DISTDIR)/$(DIST_BINARY)"
cd "$(DISTDIR)/.." && tar cJvf "`basename '$(DISTDIR)'`.tar.xz" "`basename '$(DISTDIR)'`"
rm -rf "$(DISTDIR)"

.SERIAL: all
11 changes: 8 additions & 3 deletions lib/luajit/src/lj_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,14 @@ void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs)
/* Move func + args down. */
memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1));
/* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */
/* Tailcalls can form a loop, so count towards the loop unroll limit. */
if (++J->tailcalled > J->loopunroll)
lj_trace_err(J, LJ_TRERR_LUNROLL);

J->tailcalled++;

/* Although it's true that tail calls can form a loop, the Lua programming
** idiom does not encourage this. Instead of counting tail calls towards the
** unroll limit and potentially causing important traces without loops to
** abort, eventually blacklist, and fall back to the interpreter, just rely on
** JIT_P_maxrecord to catch runaway tail-call loops. */
}

/* Check unroll limits for down-recursion. */
Expand Down
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CSRC = $(shell find . -regex '[^\#]*\.c' -not -regex './arch/.*' -printf '%P '
CHDR = $(shell find . -regex '[^\#]*\.h' -printf '%P ')
ASM = $(shell find . -regex '[^\#]*\.dasl' -printf '%P ')
ARCHSRC= $(shell find . -regex '^./arch/[^\#]*\.c' -printf '%P ')
RMSRC = $(shell find . -name README.md.src -printf '%P ')
RMSRC = $(shell find . -name README.src.md -printf '%P ')
# regexp is to include program/foo but not program/foo/bar
PROGRAM = $(shell find program -regex '^[^/]+/[^/]+' -type d -printf '%P ')
# sort to eliminate potential duplicate of programs.inc
Expand All @@ -30,7 +30,7 @@ ARCHOBJ:= $(patsubst %.c,obj/%_c.o, $(ARCHSRC))
ASMOBJ := $(patsubst %.dasl,obj/%_dasl.o, $(ASM))
JITOBJS:= $(patsubst %,obj/jit_%.o,$(JITSRC))
EXTRAOBJS := obj/jit_tprof.o obj/jit_vmprof.o obj/strict.o
RMOBJS := $(patsubst %.src,%,$(RMSRC))
RMOBJS := $(patsubst %.src.md,%.md,$(RMSRC))
INCOBJ := $(patsubst %.inc,obj/%_inc.o, $(INCSRC))
EXE := bin/snabb $(patsubst %,bin/%,$(PROGRAM))

Expand Down Expand Up @@ -152,7 +152,7 @@ $(JITOBJS): obj/jit_%.o: ../lib/luajit/src/jit/%.lua $(OBJDIR)
$(Q) luajit -bg -n $(patsubst obj/jit_%.o, jit.%, $@) $< $@


$(RMOBJS): %: %.src
$(RMOBJS): %.md: %.src.md
$(E) "MARKDOWN $@"
$(Q) scripts/process-markdown $< > $@

Expand Down
43 changes: 9 additions & 34 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,49 +333,24 @@ Allocate packet and fill it with the contents of *string*.

## Memory (core.memory)

Snabb Switch does two things specially when it comes to memory: It
runs with a fixed physical memory map and it allocates *huge pages*
from the operating system.
Snabb Switch allocates special
[DMA](https://en.wikipedia.org/wiki/Direct_memory_access) memory that
can be accessed directly by network cards. The important
characteristic of DMA memory is being located in contiguous physical
memory at a stable address.

Running with a fixed memory map means that every virtual address in the
Snabb Switch process has a fixed *physical address* in the RAM
chips. This means that we are always able to convert from a virtual
address in our process to a physical address that other hardware (for
example, a network card) can use for DMA.

Huge pages (also known as *HugeTLB pages*) are how we allocate large
amounts of contiguous memory, typically 2MB at a time. Hardware devices
sometimes require this, for example a network card's *descriptor ring*
may require a list of pointers to available buffers in physical memory.
— Function **memory.dma_alloc** *bytes*

— Variable **memory.chunks**
Returns a pointer to *bytes* of new DMA memory.

List of all allocated huge pages. Read-only. Each huge page is
represented by a table with the following keys:
— Function **memory.virtual_to_physical** *pointer*

* `pointer` - Virtual address
* `physical` - Physical address
* `size` - Size in bytes
* `used` - Bytes used
Returns the physical address (`uint64_t`) the DMA memory at *pointer*.

— Variable **memory.huge_page_size**

Size of a single huge page in bytes. Read-only.

— Variable **huge_page_bits**

Number of address bits per huge page. Read-only.

— Function **memory.dma_alloc** *bytes*

Allocate *bytes* of DMA-friendly memory. Returns virtual memory pointer,
physical address, and actual size.

— Function **memory.virtual_to_physical** *virtual_address*

Returns the physical address of memory at *virtual_address*.



## Lib (core.lib)

Expand Down
50 changes: 9 additions & 41 deletions src/README.md.src → src/README.src.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,56 +359,24 @@ Allocate packet and fill it with the contents of *string*.

## Memory (core.memory)

Snabb Switch does two things specially when it comes to memory: It
runs with a fixed physical memory map and it allocates *huge pages*
from the operating system.
Snabb Switch allocates special
[DMA](https://en.wikipedia.org/wiki/Direct_memory_access) memory that
can be accessed directly by network cards. The important
characteristic of DMA memory is being located in contiguous physical
memory at a stable address.

Running with a fixed memory map means that every virtual address in the
Snabb Switch process has a fixed *physical address* in the RAM
chips. This means that we are always able to convert from a virtual
address in our process to a physical address that other hardware (for
example, a network card) can use for DMA.

Huge pages (also known as *HugeTLB pages*) are how we allocate large
amounts of contiguous memory, typically 2MB at a time. Hardware devices
sometimes require this, for example a network card's *descriptor ring*
may require a list of pointers to available buffers in physical memory.

— Variable **memory.chunks**

List of all allocated huge pages. Read-only. Each huge page is
represented by a table with the following keys:

* `pointer` - Virtual address
* `physical` - Physical address
* `size` - Size in bytes
* `used` - Bytes used
— Function **memory.dma_alloc** *bytes*

— Variable **memory.dma_min_addr**
Returns a pointer to *bytes* of new DMA memory.

Variable **memory.dma_max_addr**
Function **memory.virtual_to_physical** *pointer*

Lowest and highest addresses of valid DMA memory. Useful information for
creating memory maps. Read-only.
Returns the physical address (`uint64_t`) the DMA memory at *pointer*.

— Variable **memory.huge_page_size**

Size of a single huge page in bytes. Read-only.

— Variable **huge_page_bits**

Number of address bits per huge page. Read-only.

— Function **memory.dma_alloc** *bytes*

Allocate *bytes* of DMA-friendly memory. Returns virtual memory pointer,
physical address, and actual size.

— Function **memory.virtual_to_physical** *virtual_address*

Returns the physical address of memory at *virtual_address*.



## Lib (core.lib)

Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/basic/basic_apps.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

local app = require("core.app")
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/bridge/base.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- Base class for an Ethernet bridge with split-horizon semantics.
--
-- A bridge conists of any number of ports, each of which is a member
Expand Down
2 changes: 2 additions & 0 deletions src/apps/bridge/flooding.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- This class derives from lib.bridge.base and implements the simplest
-- possible bridge, which floods a packet arriving on a port to all
-- destination ports within its scope according to the split-horizon
Expand Down
2 changes: 2 additions & 0 deletions src/apps/bridge/learning.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Use of this source code is governed by the Apache 2.0 license; see COPYING. */

/* Type for port and split-horizon group handles */
typedef uint16_t handle_t;

Expand Down
2 changes: 2 additions & 0 deletions src/apps/bridge/learning.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- This class derives from lib.bridge.base and implements a "learning
-- bridge" using a MAC address table provided by apps.bridge.mac_table
-- to store the set of source addresses of packets arriving on all
Expand Down
2 changes: 2 additions & 0 deletions src/apps/bridge/mac_table.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Use of this source code is governed by the Apache 2.0 license; see COPYING. */

#include <inttypes.h>
#include "learning.h"

Expand Down
1 change: 1 addition & 0 deletions src/apps/bridge/mac_table.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.
--
-- This module implements a MAC address table as part of the learning
-- bridge app (apps.bridge.learning). It associates a MAC address
Expand Down
2 changes: 2 additions & 0 deletions src/apps/csv.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

local app = require("core.app")
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/intel/intel.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Use of this source code is governed by the Apache 2.0 license; see COPYING. */

// RX descriptor written by software.
struct rx_desc {
uint64_t address; // 64-bit address of receive buffer
Expand Down
2 changes: 2 additions & 0 deletions src/apps/intel/intel10g.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

--- Device driver for the Intel 82599 10-Gigabit Ethernet controller.
--- This is one of the most popular production 10G Ethernet
--- controllers on the market and it is readily available in
Expand Down
2 changes: 2 additions & 0 deletions src/apps/intel/intel1g.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- intel1g: Device driver app for Intel 1G network cards
--
-- This is a device driver for Intel i210, i350 families of 1G network cards.
Expand Down
2 changes: 2 additions & 0 deletions src/apps/intel/intel_app.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

local zone = require("jit.zone")
Expand Down
2 changes: 2 additions & 0 deletions src/apps/intel/loadgen.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

local ffi = require("ffi")
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/ipv6/nd_light.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- This app implements a small subset of IPv6 neighbor discovery
-- (RFC4861). It has two ports, north and south. The south port
-- attaches to a port on which ND must be performed. The north port
Expand Down
2 changes: 2 additions & 0 deletions src/apps/ipv6/ns_responder.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- This app acts as a responder for neighbor solicitaions for a
-- specific target address and as a relay for all other packets. It
-- has two ports, north and south. The south port attaches to a port
Expand Down
2 changes: 2 additions & 0 deletions src/apps/keyed_ipv6_tunnel/tunnel.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

-- http://tools.ietf.org/html/draft-mkonstan-keyed-ipv6-tunnel-01
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/packet_filter/conntrack.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- conntrack.lua -- Connection tracking for IPv4/IPv6 TCP/UDP sessions
--
-- This module exposes the following API:
Expand Down
2 changes: 2 additions & 0 deletions src/apps/packet_filter/pcap_filter.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

local app = require("core.app")
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/pcap/pcap.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

local ffi = require("ffi")
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/rate_limiter/rate_limiter.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(..., package.seeall)

local app = require("core.app")
Expand Down
File renamed without changes.
11 changes: 6 additions & 5 deletions src/apps/socket/raw.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(..., package.seeall)

local S = require("syscall")
Expand All @@ -14,14 +16,13 @@ RawSocket = {}

function RawSocket:new (ifname)
assert(ifname)
local index, err = S.util.if_nametoindex(ifname)
if not index then error(err) end

local tp = h.htons(c.ETH_P["ALL"])
local sock, err = S.socket(c.AF.PACKET, bit.bor(c.SOCK.RAW, c.SOCK.NONBLOCK), tp)
if not sock then error(err) end
local index, err = S.util.if_nametoindex(ifname, sock)
if err then
S.close(sock)
error(err)
end

local addr = t.sockaddr_ll{sll_family = c.AF.PACKET, sll_ifindex = index, sll_protocol = tp}
local ok, err = S.bind(sock, addr)
if not ok then
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/solarflare/ef_vi.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Use of this source code is governed by the Apache 2.0 license; see COPYING. */

#include <time.h>

/* etherfabric/base.h */
Expand Down
2 changes: 2 additions & 0 deletions src/apps/solarflare/poll.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Use of this source code is governed by the Apache 2.0 license; see COPYING. */

/* poll.c - Poll multiple ef_vi interfaces in one FFI call to save on FFI overhead */

#include <stdint.h>
Expand Down
2 changes: 1 addition & 1 deletion src/apps/solarflare/selftest.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash

./snabb snabbmark solarflare 10e6 128 10
2 changes: 2 additions & 0 deletions src/apps/solarflare/solarflare.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

local lib = require("core.lib")
Expand Down
2 changes: 1 addition & 1 deletion src/apps/tap/selftest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
sudo ip netns add snabbtest || exit $TEST_SKIPPED
sudo ip netns exec snabbtest ip link add name snabbtest type bridge
sudo ip netns exec snabbtest ip link set up dev snabbtest
Expand Down
2 changes: 2 additions & 0 deletions src/apps/tap/tap.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(..., package.seeall)

local S = require("syscall")
Expand Down
2 changes: 2 additions & 0 deletions src/apps/test/synth.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

module(...,package.seeall)

local ffi = require("ffi")
Expand Down
Binary file added src/apps/test/synth.pcap.output
Binary file not shown.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/apps/vhost/vhost.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Use of this source code is governed by the Apache 2.0 license; see COPYING. */

// vhost_memory structure is used to declare which memory address
// ranges we want to use for DMA. The kernel uses this to create a
// shared memory mapping.
Expand Down
2 changes: 2 additions & 0 deletions src/apps/vhost/vhost_user.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Use of this source code is governed by the Apache 2.0 license; see COPYING. */

#include <assert.h>
#include <errno.h>
#include <fcntl.h>
Expand Down
2 changes: 2 additions & 0 deletions src/apps/vhost/vhost_user.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* Use of this source code is governed by the Apache 2.0 license; see COPYING. */

enum {
VHOST_USER_MEMORY_MAX_NREGIONS = 8
};
Expand Down
2 changes: 2 additions & 0 deletions src/apps/vhost/vhost_user.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

--
-- See http://www.virtualopensystems.com/en/solutions/guides/snabbswitch-qemu/

Expand Down
File renamed without changes.
Loading

0 comments on commit ed346d5

Please sign in to comment.