From fedf91c763441a6b522483f98b19cc6f9d0366c4 Mon Sep 17 00:00:00 2001 From: Michael Blizek Date: Sat, 2 Jan 2010 13:08:18 +0100 Subject: [PATCH] new buffering logic part 2 --- net/cor/Makefile | 2 +- net/cor/common.c | 39 ++++++++++++++++++++++++++++++++------- net/cor/cor.h | 8 ++++++-- net/cor/forward.c | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 net/cor/forward.c diff --git a/net/cor/Makefile b/net/cor/Makefile index d5276ad69b4..b9e92017b41 100644 --- a/net/cor/Makefile +++ b/net/cor/Makefile @@ -1 +1 @@ -obj-y := common.o rcv.o snd.o sock.o kpacket_parse.o kpacket_gen.o cpacket_parse.o neighbor.o +obj-y := common.o rcv.o snd.o sock.o kpacket_parse.o kpacket_gen.o cpacket_parse.o neighbor.o forward.o diff --git a/net/cor/common.c b/net/cor/common.c index c528cda9261..14fe467aaae 100644 --- a/net/cor/common.c +++ b/net/cor/common.c @@ -286,8 +286,7 @@ found: #define PAGESIZE (1 << PAGE_SHIFT) -/* -static void data_nextreadchunk(struct data_buf *data) +static void databuf_nextreadchunk(struct data_buf *data) { struct list_head *next = data->lastread->buf_list.next; @@ -300,7 +299,7 @@ static void data_nextreadchunk(struct data_buf *data) buf_list); } -void data_pull(struct data_buf *data, char *dst, int len) { +void databuf_pull(struct data_buf *data, char *dst, int len) { BUG_ON(data->read_remaining < len); while(len > 0) { @@ -339,9 +338,37 @@ void data_pull(struct data_buf *data, char *dst, int len) { data->last_read_offset += cpy; if (cpy == srcbufcpylen) - data_nextreadchunk(data); + databuf_nextreadchunk(data); + } +} + +static void databuf_free(struct data_buf *data) +{ + while (!list_empty(&(data->items))) { + struct data_buf_item *item = container_of(data->items.next, + struct data_buf_item, buf_list); + if (item->type == TYPE_BUF) { + kfree(item->data.buf.buf); + } else if (item->type == TYPE_SKB) { + kfree_skb(item->data.skb); + } else { + BUG(); + } + + + + list_del(&(item->buf_list)); + + #warning todo free data_buf_item } -} */ +} + +static void databuf_init(struct data_buf *data) +{ + memset(data, 0, sizeof(struct data_buf)); + mutex_init(&(data->lock)); + INIT_LIST_HEAD(&(data->items)); +} static int ringbuffer_init(struct ringbuffer *buf) { @@ -506,8 +533,6 @@ static void free_conn(struct ref_counter *cnt) - - if (conn->reversedir != 0) conn->reversedir->reversedir = 0; diff --git a/net/cor/cor.h b/net/cor/cor.h index 1ca4269bf32..95abd6a199d 100644 --- a/net/cor/cor.h +++ b/net/cor/cor.h @@ -303,6 +303,9 @@ struct cor_sched_data{ struct sk_buff_head requeue_queue; }; +#define TYPE_BUF 0 +#define TYPE_SKB 1 + struct data_buf_item{ struct list_head buf_list; @@ -511,6 +514,8 @@ struct conn{ struct neighbor *nb; }kernel; }target; + + struct data_buf buf; struct conn *reversedir; }; @@ -555,8 +560,7 @@ static inline char *cor_pull_skb(struct sk_buff *skb, unsigned int len) struct data{ __u8 type; -#define TYPE_BUF 0 -#define TYPE_SKB 1 + union { struct { char *buf; diff --git a/net/cor/forward.c b/net/cor/forward.c new file mode 100644 index 00000000000..f6d76ef49e6 --- /dev/null +++ b/net/cor/forward.c @@ -0,0 +1,35 @@ +/* + * Connection oriented routing + * Copyright (C) 2007-2008 Michael Blizek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include + +#include "cor.h" + +int receive_userbuf(struct conn *rconn, struct msghdr *msg) +{ +} + +void receive_buf(struct conn *rconn, char *buf, int len) +{ +} + +void receive_skb(struct conn *rconn, struct sk_buff *skb) +{ +} -- 2.11.4.GIT