net: Add function that feeds data to RX fifo

Network drivers should call this when new data has been
received from network.

Change-Id: Ife78fa0683b8c410c38358300a6a18e9325f0ef8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-05-03 10:41:25 +03:00
commit 920a5f5e38
2 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,60 @@
/** @file
* @brief Network core definitions
*
* Definitions for networking support.
*/
/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __NET_CORE_H
#define __NET_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Network subsystem logging helpers */
#ifdef CONFIG_NETWORKING_WITH_LOGGING
#define NET_DBG(fmt, ...) printk("net: %s (%p): " fmt, __func__, \
sys_thread_self_get(), ##__VA_ARGS__)
#define NET_ERR(fmt, ...) printk("net: %s: " fmt, __func__, ##__VA_ARGS__)
#define NET_INFO(fmt, ...) printk("net: " fmt, ##__VA_ARGS__)
#define NET_PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__)
#else
#define NET_DBG(...)
#define NET_ERR(...)
#define NET_INFO(...)
#define NET_PRINT(...)
#endif /* CONFIG_NETWORKING_WITH_LOGGING */
struct net_buf;
struct net_context;
#include <misc/printk.h>
#include <string.h>
#include <net/net_if.h>
/* Called by lower network stack when a network packet has been received */
int net_recv(struct net_if *iface, struct net_buf *buf);
#ifdef __cplusplus
}
#endif
#endif /* __NET_CORE_H */

View file

@ -32,6 +32,9 @@
#include <string.h>
#include <errno.h>
#include <net/net_if.h>
#include <net/buf.h>
/* Stack for the rx fiber.
*/
#if !defined(CONFIG_NET_RX_STACK_SIZE)
@ -55,6 +58,18 @@ static void init_rx_queue(void)
net_rx_fiber, 0, 0, 7, 0);
}
/* Called by driver when an IP packet has been received */
int net_recv(struct net_if *iface, struct net_buf *buf)
{
if (!buf->frags) {
return -ENODATA;
}
nano_fifo_put(&rx_queue, buf);
return 0;
}
static int network_initialization(void)
{