Skip to content

Commit

Permalink
Merge pull request #507 from intel-go/develop
Browse files Browse the repository at this point in the history
Bugfix release 0.7.1. Bugfixes in development environment and tests
  • Loading branch information
gshimansky committed Dec 12, 2018
2 parents 881d8d9 + 3c95771 commit 3c791dd
Show file tree
Hide file tree
Showing 19 changed files with 875 additions and 334 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -17,6 +17,7 @@ before_script:
- docker run -it -d --privileged -v /usr/src:/usr/src -v /lib/modules:/lib/modules -v /sys/devices/system/node:/sys/devices/system/node --name test-nff-go test-cosmic /bin/bash

script:
- docker exec -i test-nff-go go mod download
- docker exec -i test-nff-go make
# Build standalone examples
- docker exec -i test-nff-go bash -c "cd examples && make gopacketParserExample && cd .."
Expand Down
1 change: 1 addition & 0 deletions common/common.go
Expand Up @@ -154,6 +154,7 @@ const (
WrongPort
FailToInitDPDK
FailToCreateKNI
FailToReleaseKNI
)

// NFError is error type returned by nff-go functions
Expand Down
8 changes: 5 additions & 3 deletions dpdk/Dockerfile
Expand Up @@ -9,12 +9,14 @@ LABEL RUN docker run -it --privileged -v /sys/bus/pci/drivers:/sys/bus/pci/drive

EXPOSE 22022

RUN dnf -y install pciutils; dnf clean all
#Uncomment for Fedora
# RUN dnf -y install pciutils; dnf clean all

WORKDIR /workdir
COPY pktgen .
COPY Pktgen.lua .

# Workaround for linking agains libpcap.so.0.8 on Ubuntu
RUN ln -s libpcap.so.1 /usr/lib64/libpcap.so.0.8
# Uncomment for Fedora
#RUN ln -s libpcap.so.1 /usr/lib64/libpcap.so.0.8

CMD ["./pktgen", "-c", "0x1ff", "-n", "4", "--", "-P", "-m", "[1:1-2].0, [3:3-4].1, [5-6:5].2, [7-8:7].3", "-G"]
2 changes: 0 additions & 2 deletions dpdk/Makefile
Expand Up @@ -22,7 +22,6 @@ endif
dpdk: all

all: pktgen
cp $(PKTGEN_DIR)/Pktgen.lua .

$(DPDK_DIR)/$(DPDK_INSTALL_DIR):
$(MAKE) -C $(DPDK_DIR) config T=$(RTE_TARGET)
Expand All @@ -35,7 +34,6 @@ pktgen: $(PKTGEN_DIR)/app/$(RTE_TARGET)/pktgen
cp $(PKTGEN_DIR)/app/$(RTE_TARGET)/pktgen .

clean:
-rm pktgen Pktgen.lua
-$(MAKE) -C $(DPDK_DIR) clean
-rm -rf $(DPDK_DIR)/$(DPDK_INSTALL_DIR) $(DPDK_DIR)/build $(DPDK_DIR)/$(RTE_TARGET)
-$(MAKE) -C $(PKTGEN_DIR) realclean
Expand Down
27 changes: 19 additions & 8 deletions flow/flow.go
Expand Up @@ -375,6 +375,7 @@ type port struct {
txQueuesNumber int16
willReceive bool // will this port receive packets
willKNI bool // will this port has assigned KNI device
KNICoreIndex int
port uint16
MAC [common.EtherAddrLen]uint8
InIndex int32
Expand Down Expand Up @@ -601,7 +602,7 @@ func SystemStart() error {

// SystemStop stops the system. All Flow functions plus resource releasing
// Doesn't cleanup DPDK
func SystemStop() {
func SystemStop() error {
// TODO we should release rings here
schedState.systemStop()
for i := range createdPorts {
Expand All @@ -611,8 +612,17 @@ func SystemStop() {
createdPorts[i].txQueuesNumber = 0
createdPorts[i].willReceive = false
}
if createdPorts[i].willKNI {
err := low.FreeKNI(createdPorts[i].port)
if err != nil {
return err
}
schedState.setCoreByIndex(createdPorts[i].KNICoreIndex)
createdPorts[i].willKNI = false
}
}
low.FreeMempools()
return nil
}

// SystemReset stops whole framework plus cleanup DPDK
Expand Down Expand Up @@ -1566,19 +1576,20 @@ func CreateKniDevice(portId uint16, name string) (*Kni, error) {
if createdPorts[portId].willKNI {
return nil, common.WrapWithNFError(nil, "Requested KNI port already has KNI. Two KNIs for one port are prohibited.", common.MultipleKNIPort)
}
if core, _, err := schedState.getCore(); err != nil {
if core, coreIndex, err := schedState.getCore(); err != nil {
return nil, err
} else {
if err := low.CreateKni(portId, uint(core), name); err != nil {
return nil, err
}
kni := new(Kni)
// Port will be identifier of this KNI
// KNI structure itself is stored inside low.c
kni.portId = portId
createdPorts[portId].willKNI = true
createdPorts[portId].KNICoreIndex = coreIndex
return kni, nil
}
kni := new(Kni)
// Port will be identifier of this KNI
// KNI structure itself is stored inside low.c
kni.portId = portId
createdPorts[portId].willKNI = true
return kni, nil
}

func FillSliceFromMask(input []uintptr, mask *[burstSize]bool, output []uintptr) uint8 {
Expand Down
7 changes: 4 additions & 3 deletions flow/scheduler.go
Expand Up @@ -171,6 +171,7 @@ type scheduler struct {
pAttempts []uint64
maxInIndex int32
measureRings low.Rings
coreIndex int
}

type core struct {
Expand Down Expand Up @@ -204,7 +205,7 @@ func newScheduler(cpus []int, schedulerOff bool, schedulerOffRemove bool, stopDe
func (scheduler *scheduler) systemStart() (err error) {
scheduler.stopFlag = process
var core int
if core, _, err = scheduler.getCore(); err != nil {
if core, scheduler.coreIndex, err = scheduler.getCore(); err != nil {
return err
}
common.LogDebug(common.Initialization, "Start SCHEDULER at", core, "core")
Expand Down Expand Up @@ -333,9 +334,9 @@ func (scheduler *scheduler) systemStop() {
scheduler.ff[i].stopInstance(0, -1, scheduler)
}
}
scheduler.setCoreByIndex(0) // scheduler
scheduler.setCoreByIndex(scheduler.coreIndex)
if scheduler.stopDedicatedCore {
scheduler.setCoreByIndex(1) // stop
scheduler.setCoreByIndex(scheduler.coreIndex + 1)
}
scheduler.ff = nil
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -12,5 +12,5 @@ require (
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc // indirect
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 // indirect
golang.org/x/sys v0.0.0-20181004145325-8469e314837c // indirect
golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1 // indirect
golang.org/x/tools v0.0.0-20181204185109-3832e276fb48 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -33,3 +33,5 @@ golang.org/x/tools v0.0.0-20181002223833-cd09f19c2f7e h1:x8cnE8uLkl6ATwMpvL/N/wY
golang.org/x/tools v0.0.0-20181002223833-cd09f19c2f7e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1 h1:bsEj/LXbv3BCtkp/rBj9Wi/0Nde4OMaraIZpndHAhdI=
golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181204185109-3832e276fb48 h1:N6OJ2izGAYOu7TF6EHpWtlM+vFxWtFJoj/BxJI7UhSQ=
golang.org/x/tools v0.0.0-20181204185109-3832e276fb48/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7 changes: 7 additions & 0 deletions low/low.go
Expand Up @@ -515,6 +515,13 @@ func StopPort(port uint16) {
C.rte_eth_dev_stop(C.uint16_t(port))
}

func FreeKNI(port uint16) error {
if C.free_kni(C.uint16_t(port)) < 0 {
return common.WrapWithNFError(nil, "Problem with KNI releasing\n", common.FailToReleaseKNI)
}
return nil
}

// GetPortsNumber gets total number of available Ethernet devices.
func GetPortsNumber() int {
return int(C.rte_eth_dev_count())
Expand Down
4 changes: 4 additions & 0 deletions low/low.h
Expand Up @@ -150,6 +150,10 @@ int create_kni(uint16_t port, uint32_t core, char *name, struct rte_mempool *mbu
return 0;
}

int free_kni(uint16_t port) {
return rte_kni_release(kni[port]);
}

int checkRSSPacketCount(struct cPort *port, int16_t queue) {
return rte_eth_rx_queue_count(port->PortId, queue);
}
Expand Down
16 changes: 15 additions & 1 deletion nff-go-base/Makefile
Expand Up @@ -7,7 +7,9 @@ IMAGENAME = nff-go-base
EXECUTABLES =
NOCHECK_PKTGEN = yes

Dockerfile: Makefile
# This will not be used from "make deploy" or "make images" by default
# You should change images rule in mk/leaf.mk from "Dockerfile" to "Fedora"
Fedora: Makefile
echo 'ARG USER_NAME' > Dockerfile
echo 'FROM fedora' >> Dockerfile
if [ -n '${http_proxy}' ]; then \
Expand All @@ -19,6 +21,18 @@ Dockerfile: Makefile
echo 'RUN dnf -y install numactl-libs.x86_64; dnf clean all' >> Dockerfile
echo 'CMD ["/bin/bash"]' >> Dockerfile

Dockerfile: Makefile
echo 'ARG USER_NAME' > Dockerfile
echo 'FROM ubuntu:cosmic' >> Dockerfile
if [ -n '${http_proxy}' ]; then \
echo 'ENV http_proxy ${http_proxy}' >> Dockerfile; \
echo 'ENV https_proxy ${http_proxy}' >> Dockerfile; \
echo 'RUN echo Acquire::http::Proxy \"${http_proxy}\"\; >> /etc/apt/apt.conf' >> Dockerfile; \
echo 'RUN echo Acquire::https::Proxy \"${https_proxy}\"\; >> /etc/apt/apt.conf' >> Dockerfile; \
fi
echo 'RUN apt-get update; apt-get install -y libnuma-dev; apt-get install -y libpcap0.8-dev; apt-get install -y liblua5.3-dev; apt-get clean all' >> Dockerfile
echo 'CMD ["/bin/bash"]' >> Dockerfile

.PHONY: dpdk
dpdk:

Expand Down
1 change: 0 additions & 1 deletion scripts/get-depends.sh
Expand Up @@ -6,7 +6,6 @@ go get -v github.com/Sirupsen/logrus
go get -v github.com/pkg/errors
go get -v golang.org/x/net/proxy
go get -v github.com/docker/go-connections
go get -v golang.org/x/tools/cmd/stringer
go get -v github.com/vishvananda/netlink
go get -v github.com/google/gopacket

2 changes: 1 addition & 1 deletion test/framework/Makefile
Expand Up @@ -5,7 +5,7 @@
PATH_TO_MK = ../../mk
SUBDIRS = main

main: apptype_string.go
main:

%_string.go: types.go
go generate
Expand Down
17 changes: 10 additions & 7 deletions test/framework/dockerlauncher.go
Expand Up @@ -23,9 +23,9 @@ import (

// Pktgen commands constants
const (
PktgenGetPortsNumberCommand = "printf(\"%d\\n\", pktgen.portStats(\"all\", \"port\").n);"
PktgenGetPortsNumberCommand = "io.write(string.format(\"%d\\n\", pktgen.portStats(\"all\", \"port\").n)); io.flush();"
PktgenGetPortStatsCommand = "stat = pktgen.portStats(\"all\", \"rate\");"
PktgenPrintPortStatsCommand = "printf(\"%%d %%d %%d %%d\\n\", stat[%d].pkts_tx, stat[%d].mbits_tx, stat[%d].pkts_rx, stat[%d].mbits_rx);"
PktgenPrintPortStatsCommand = "io.write(string.format(\"%%d %%d %%d %%d\\n\", stat[%d].pkts_tx, stat[%d].mbits_tx, stat[%d].pkts_rx, stat[%d].mbits_rx)); io.flush();"
PktgenExitCommand = "os.exit(0);"

PktgenGetPortsNumberFormat = "%d"
Expand Down Expand Up @@ -227,7 +227,7 @@ func (app *RunningApp) testRoutine(report chan<- TestReport, done <-chan struct{
}
}

func (app *RunningApp) testPktgenRoutine(report chan<- TestReport, done <-chan struct{}) {
func (app *RunningApp) testPktgenRoutine(report chan<- TestReport, done <-chan struct{}, start bool) {
var connection net.Conn
var err error
var scanner *bufio.Scanner
Expand Down Expand Up @@ -314,10 +314,13 @@ func (app *RunningApp) testPktgenRoutine(report chan<- TestReport, done <-chan s
app.Logger.LogDebug("Got number of ports", numberOfPorts)

// Start generating packets on ports
app.Logger.LogDebug("Executing startup commands")
for _, cmd := range app.test.BenchConf.StartCommands {
if writeData(cmd) {
return
// If we don't start generating - this pktgen will be used for receiving and counting
if start {
app.Logger.LogDebug("Executing startup commands")
for _, cmd := range app.test.BenchConf.StartCommands {
if writeData(cmd) {
return
}
}
}

Expand Down

0 comments on commit 3c791dd

Please sign in to comment.