Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEC driver from genodelabs/genode 18.02 backported to Genode 16.08 #34

Open
wants to merge 14 commits into
base: focnados-1608
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions repos/base/include/util/reconstructible.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* \brief Utility for in-place (re-)construction of objects
* \author Norman Feske
* \date 2014-01-10
*/

/*
* Copyright (C) 2014-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/

#ifndef _INCLUDE__UTIL__RECONSTRUCTIBLE_H_
#define _INCLUDE__UTIL__RECONSTRUCTIBLE_H_

#include <util/construct_at.h>
#include <base/stdint.h>
#include <util/noncopyable.h>

namespace Genode {
template<typename> class Reconstructible;
template<typename> class Constructible;
}


/**
* Place holder for an object to be repeatedly constructed and destructed
*
* This class template acts as a smart pointer that refers to an object
* contained within the smart pointer itself. The contained object may be
* repeatedly constructed and destructed while staying in the same place. This
* is useful for replacing aggregated members during the lifetime of a compound
* object.
*
* \param MT type
*/
template <typename MT>
class Genode::Reconstructible : Noncopyable
{
private:

/**
* Static reservation of memory for the embedded object
*/
char _space[sizeof(MT)] __attribute__((aligned(sizeof(addr_t))));

/**
* True if the volatile object contains a constructed object
*/
bool _constructed = false;

template <typename... ARGS> void _do_construct(ARGS &&... args)
{
construct_at<MT>(_space, args...);
_constructed = true;
}

MT *_ptr() { return reinterpret_cast<MT *>(_space); }
MT const *_const_ptr() const { return reinterpret_cast<MT const *>(_space); }

void _check_constructed() const
{
if (!_constructed)
throw Deref_unconstructed_object();
}

protected:

/**
* Dummy type used as a hook for 'Constructible' to bypass the
* default constructor by invoking the 'Reconstructible(Lazy *)'
* constructor.
*/
struct Lazy { };

/**
* Constructor that omits the initial construction of the object
*/
Reconstructible(Lazy *) { }

public:

class Deref_unconstructed_object { };

/**
* Constructor
*
* The arguments are forwarded to the constructor of the embedded
* object.
*/
template <typename... ARGS>
Reconstructible(ARGS &&... args)
{
_do_construct(args...);
}

~Reconstructible() { destruct(); }

/**
* Construct new object in place
*
* If the 'Reconstructible' already hosts a constructed object, the old
* object will be destructed first.
*/
template <typename... ARGS>
void construct(ARGS &&... args)
{
destruct();
_do_construct(args...);
}

/**
* Destruct object
*/
void destruct()
{
if (!_constructed)
return;

/* invoke destructor */
_ptr()->~MT();

_constructed = false;
}

/**
* Return true of volatile object contains a constructed object
*/
bool constructed() const { return _constructed; }

/**
* Return true of volatile object contains a constructed object
*
* \deprecated use 'constructed' instead
*/
bool is_constructed() const { return constructed(); }

/**
* Access contained object
*/
MT *operator -> () { _check_constructed(); return _ptr(); }
MT const *operator -> () const { _check_constructed(); return _const_ptr(); }

MT &operator * () { _check_constructed(); return *_ptr(); }
MT const &operator * () const { _check_constructed(); return *_const_ptr(); }

void print(Output &out) const
{
if (_constructed)
_const_ptr()->print(out);
else
out.out_string("<unconstructed>");
}
};


/**
* Reconstructible object that holds no initially constructed object
*/
template <typename MT>
struct Genode::Constructible : Reconstructible<MT>
{
template <typename... ARGS>
Constructible(ARGS &&...)
:
Reconstructible<MT>((typename Reconstructible<MT>::Lazy *)nullptr)
{ }
};

#endif /* _INCLUDE__UTIL__RECONSTRUCTIBLE_H_ */
56 changes: 56 additions & 0 deletions repos/dde_linux/fec.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
linux-x.x.x/drivers/net/ethernet/freescale/fec.h
linux-x.x.x/drivers/net/ethernet/freescale/fec_main.c
linux-x.x.x/drivers/net/ethernet/freescale/fec_ptp.c
linux-x.x.x/drivers/net/phy/mdio_bus.c
linux-x.x.x/drivers/net/phy/phy_device.c
linux-x.x.x/drivers/net/phy/phy.c
linux-x.x.x/drivers/net/phy/at803x.c
linux-x.x.x/net/core/skbuff.c
linux-x.x.x/net/ethernet/eth.c
linux-x.x.x/include/asm-generic/atomic64.h
linux-x.x.x/include/asm-generic/bitops/non-atomic.h
linux-x.x.x/include/asm-generic/bitops/__ffs.h
linux-x.x.x/include/asm-generic/bitops/__fls.h
linux-x.x.x/include/asm-generic/bitops/ffs.h
linux-x.x.x/include/asm-generic/bitops/fls.h
linux-x.x.x/include/asm-generic/bitops/fls64.h
linux-x.x.x/include/linux/errqueue.h
linux-x.x.x/include/linux/fec.h
linux-x.x.x/include/linux/gpio/consumer.h
linux-x.x.x/include/linux/if_ether.h
linux-x.x.x/include/linux/list.h
linux-x.x.x/include/linux/list_nulls.h
linux-x.x.x/include/linux/log2.h
linux-x.x.x/include/linux/mii.h
linux-x.x.x/include/linux/mod_devicetable.h
linux-x.x.x/include/linux/net.h
linux-x.x.x/include/linux/netdev_features.h
linux-x.x.x/include/linux/phy.h
linux-x.x.x/include/linux/ptp_clock_kernel.h
linux-x.x.x/include/linux/rculist.h
linux-x.x.x/include/linux/rculist_nulls.h
linux-x.x.x/include/linux/skbuff.h
linux-x.x.x/include/linux/socket.h
linux-x.x.x/include/linux/timecounter.h
linux-x.x.x/include/net/dst.h
linux-x.x.x/include/net/dst_ops.h
linux-x.x.x/include/net/neighbour.h
linux-x.x.x/include/net/sock.h
linux-x.x.x/include/net/tcp_states.h
linux-x.x.x/include/net/tso.h
linux-x.x.x/include/uapi/linux/byteorder/little_endian.h
linux-x.x.x/include/uapi/linux/errqueue.h
linux-x.x.x/include/uapi/linux/ethtool.h
linux-x.x.x/include/uapi/linux/if.h
linux-x.x.x/include/uapi/linux/if_ether.h
linux-x.x.x/include/uapi/linux/if_packet.h
linux-x.x.x/include/uapi/linux/mdio.h
linux-x.x.x/include/uapi/linux/mii.h
linux-x.x.x/include/uapi/linux/net.h
linux-x.x.x/include/uapi/linux/net_tstamp.h
linux-x.x.x/include/uapi/linux/neighbour.h
linux-x.x.x/include/uapi/linux/ptp_clock.h
linux-x.x.x/include/uapi/linux/rtnetlink.h
linux-x.x.x/include/uapi/linux/socket.h
linux-x.x.x/include/uapi/linux/sockios.h
linux-x.x.x/include/uapi/linux/swab.h
5 changes: 5 additions & 0 deletions repos/dde_linux/lib/import/import-fec_nic_include.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/nic/fec
SRC_DIR := $(REP_DIR)/src/drivers/nic/fec
INC_DIR += $(LX_CONTRIB_DIR)/drivers/net/ethernet/freescale
INC_DIR += $(LIB_CACHE_DIR)/fec_nic_include/include/include/include
CC_OPT += -U__linux__ -D__KERNEL__
35 changes: 35 additions & 0 deletions repos/dde_linux/lib/mk/fec_nic_include.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Pseudo library to generate a symlink for each header file included by the
# contrib code. Each symlink points to the same 'lx_emul.h' file, which
# provides our emulation of the Linux kernel API.
#

ifeq ($(called_from_lib_mk),yes)

LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/nic/fec
LX_EMUL_H := $(REP_DIR)/src/drivers/nic/fec/lx_emul.h

#
# Determine the header files included by the contrib code. For each
# of these header files we create a symlink to 'lx_emul.h'.
#
SCAN_DIRS := $(addprefix $(LX_CONTRIB_DIR)/include/, asm-generic linux net uapi) \
$(addprefix $(LX_CONTRIB_DIR)/, drivers net)
GEN_INCLUDES := $(shell grep -rIh "^\#include .*" $(SCAN_DIRS) |\
sed "s/^\#include [^<\"]*[<\"]\([^>\"]*\)[>\"].*/\1/" |\
sort | uniq)

#
# Put Linux headers in 'GEN_INC' dir, since some include use "../../" paths use
# three level include hierarchy
#
GEN_INC := $(shell pwd)/include/include/include
GEN_INCLUDES := $(addprefix $(GEN_INC)/,$(GEN_INCLUDES))

all: $(GEN_INCLUDES)

$(GEN_INCLUDES):
$(VERBOSE)mkdir -p $(dir $@)
$(VERBOSE)ln -sf $(LX_EMUL_H) $@

endif
3 changes: 3 additions & 0 deletions repos/dde_linux/lib/mk/spec/arm/lx_kit_setjmp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SRC_S += setjmp.S

vpath %.S $(REP_DIR)/src/lx_kit/spec/arm
3 changes: 3 additions & 0 deletions repos/dde_linux/lib/mk/spec/x86_32/lx_kit_setjmp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SRC_S += setjmp.S

vpath %.S $(REP_DIR)/src/lx_kit/spec/x86_32
3 changes: 3 additions & 0 deletions repos/dde_linux/lib/mk/spec/x86_64/lx_kit_setjmp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SRC_S += setjmp.S

vpath %.S $(REP_DIR)/src/lx_kit/spec/x86_64
2 changes: 1 addition & 1 deletion repos/dde_linux/lib/mk/usb.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LIB_DIR = $(REP_DIR)/src/lib/usb
LIB_INC_DIR = $(LIB_DIR)/include

LIBS += usb_include libc-setjmp config
LIBS += usb_include lx_kit_setjmp config
SRC_CC += main.cc lx_emul.cc storage.cc \
input_component.cc evdev.cc nic.cc raw.cc
SRC_C += dummies.c scsi.c raw_driver.c
Expand Down
4 changes: 1 addition & 3 deletions repos/dde_linux/lib/mk/wifi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ SHARED_LIB = yes
# wifi_include *must* be the first library, otherwise the include
# order is wrong
#
LIBS += wifi_include libc
LIBS += wifi_include lx_kit_setjmp libc

LD_OPT += --version-script=$(LIB_DIR)/symbol.map

SRC_CC += dummies.cc init.cc lxcc_emul.cc nic.cc socket_call.cc

# lx_kit
CC_OPT += -DUSE_INTERNAL_SETJMP
SRC_CC += mapped_io_mem_range.cc irq.cc pci.cc malloc.cc scheduler.cc \
work.cc timer.cc printf.cc env.cc
SRC_S += setjmp.S

SRC_C += lxc_emul.c

Expand Down
13 changes: 13 additions & 0 deletions repos/dde_linux/patches/fec_skbuff_cast.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9147f9f..c63ee5c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3281,7 +3281,7 @@ static inline void skb_remcsum_process(struct sk_buff *skb, void *ptr,

if (unlikely(skb->ip_summed != CHECKSUM_COMPLETE)) {
__skb_checksum_complete(skb);
- skb_postpull_rcsum(skb, skb->data, ptr - (void *)skb->data);
+ skb_postpull_rcsum(skb, skb->data, (unsigned char*)ptr - skb->data);
}

delta = remcsum_adjust(ptr, skb->csum, start, offset);
13 changes: 13 additions & 0 deletions repos/dde_linux/patches/fec_tx_bounce_dma.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index b2a3220..18629c6 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2825,7 +2825,7 @@ fec_enet_alloc_txq_buffers(struct net_device *ndev, unsigned int queue)
txq = fep->tx_queue[queue];
bdp = txq->tx_bd_base;
for (i = 0; i < txq->tx_ring_size; i++) {
- txq->tx_bounce[i] = kmalloc(FEC_ENET_TX_FRSIZE, GFP_KERNEL);
+ txq->tx_bounce[i] = kmalloc(FEC_ENET_TX_FRSIZE, GFP_KERNEL | GFP_LX_DMA);
if (!txq->tx_bounce[i])
goto err_alloc;

2 changes: 1 addition & 1 deletion repos/dde_linux/ports/dde_linux.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4956fbfec9787772b2679e900a38f8701db8205a
471e996102aff6b81e92a525661df0ff28ef7afe
17 changes: 16 additions & 1 deletion repos/dde_linux/ports/dde_linux.port
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LICENSE := GPLv2
VERSION := 2
DOWNLOADS := dwc_otg.git usb.archive intel_fb.archive lxip.archive \
wifi.archive libnl.archive wpa_supplicant.archive \
wifi.archive fec.archive libnl.archive wpa_supplicant.archive \
fw_6000.archive fw_6205a.archive fw_6205b.archive fw_7260.archive \
fw_7265.archive fw_8260.archive

Expand Down Expand Up @@ -79,6 +79,16 @@ DIR(lxip) := $(SRC_DIR_LXIP)
TAR_OPT(lxip) := --strip-components=1 --files-from $(REP_DIR)/lxip.list
HASH_INPUT += $(REP_DIR)/lxip.list

#
# Freescale Ethernet controller
#
SRC_DIR_FEC := src/drivers/nic/fec
VERSION_FEC := 4.4.3
URL(fec) := https://www.kernel.org/pub/linux/kernel/v4.x/linux-$(VERSION_FEC).tar.xz
SHA(fec) := 336d66925a15ce9077cbf2c38acbdc6c2644e33f
DIR(fec) := $(SRC_DIR_FEC)
TAR_OPT(fec) := --strip-components=1 --files-from - < <(sed 's/-x.x.x/-$(VERSION_FEC)/g' $(REP_DIR)/fec.list)
HASH_INPUT += $(REP_DIR)/fec.list

#
# libnl sources
Expand Down Expand Up @@ -161,6 +171,7 @@ PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/lxip*.pat
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/intel*.patch)))
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/usb*.patch)))
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/intel*.patch)))
PATCHES += $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/fec_*.patch)))

#IP stack
LXIP_OPT = -p1 -d$(SRC_DIR_LXIP)
Expand Down Expand Up @@ -194,4 +205,8 @@ PATCH_OPT(patches/usb_usbnet.patch) := $(USB_OPT)
# INTEL FB
PATCH_OPT(patches/intel_fb_export_api.patch) := -p1 -d$(SRC_DIR_INTEL_FB)

# Freescale NIC
PATCH_OPT(patches/fec_skbuff_cast.patch) := -p1 -d$(SRC_DIR_FEC)
PATCH_OPT(patches/fec_tx_bounce_dma.patch) := -p1 -d$(SRC_DIR_FEC)

# vi: set ft=make :
2 changes: 1 addition & 1 deletion repos/dde_linux/src/drivers/framebuffer/intel/target.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REQUIRES = x86

TARGET = intel_fb_drv
LIBS = base intel_fb_drv intel_fb_include libc-setjmp blit
LIBS = base intel_fb_drv intel_fb_include lx_kit_setjmp blit
SRC_CC = main.cc lx_emul.cc
SRC_C = dummies.c i915_params.c lx_emul_c.c

Expand Down
Loading