Skip to contentSkip to conversation

Netchannel: default, find, add to socket

PATCH In review Kelly Daly 3 participants 6 messages Jul 11, 2006 – Jul 26, 2006

Subsystems (3)
lore
Share & tools
lore

Kelly Daly

author
#0 lore raw

PATCH 1/1 Netchannel: default, find, add to socket

Implement finding of correct netchannel for buffer, default netchannel and attach a netchannel to a socket

---

diff -urp davem/include/linux/netchannel.h
kelly_new/include/linux/netchannel.h

include/linux/netchannel.h +6 -0
@@ -19,6 +19,7 @@ struct netchannel {
 	void 			(*netchan_callb)(struct netchannel *);
 	void			*netchan_callb_data;
 	unsigned long		netchan_head;
+	wait_queue_head_t	wq;
 };
 
 extern void netchannel_init(struct netchannel *,
@@ -56,6 +57,11 @@ static inline unsigned char *netchan_buf
 	return netchan_buf_base(bp) + bp->netchan_buf_offset;
 }
 
+static inline int netchan_data_len(const struct netchannel_buftrailer *bp)
+{
+	return bp->netchan_buf_len - bp->netchan_buf_offset;
+}
+
 extern int netchannel_enqueue(struct netchannel *, struct 

netchannel_buftrailer *);
extern struct netchannel_buftrailer *__netchannel_dequeue(struct netchannel
*);
static inline struct netchannel_buftrailer *netchannel_dequeue(struct
netchannel *np)
@@ -65,6 +71,10 @@ static inline struct netchannel_buftrail
return __netchannel_dequeue(np);
}

+extern struct netchannel *find_netchannel(const struct netchannel_buftrailer *bp);
+extern int sock_add_netchannel(struct sock *sk);
extern struct sk_buff *skb_netchan_graft(struct netchannel_buftrailer *,
gfp_t);

#endif /* _LINUX_NETCHANNEL_H */
diff -urp davem/include/net/inet_hashtables.h kelly_new/include/net/inet_hashtables.h
--- davem/include/net/inet_hashtables.h 2006-06-16 14:34:20.000000000 +1000
+++ kelly_new/include/net/inet_hashtables.h 2006-06-19 10:42:45.000000000
+1000
@@ -418,4 +418,7 @@ static inline struct sock *inet_lookup(s

extern int inet_hash_connect(struct inet_timewait_death_row *death_row,
struct sock *sk);
+extern void inet_hash_register(u8 proto, struct inet_hashinfo *hashinfo); +extern struct sock *inet_lookup_proto(u8 protocol, u32 saddr, u16 sport, u32 daddr, u16 dport, int ifindex);
+
#endif /* _INET_HASHTABLES_H */

include/net/sock.h +1 -0
diff -urp davem/include/net/sock.h kelly_new/include/net/sock.h
@@ -196,6 +196,7 @@ struct sock {
 	unsigned short		sk_type;
 	int			sk_rcvbuf;
 	socket_lock_t		sk_lock;
+	struct netchannel	*sk_channel;
 	wait_queue_head_t	*sk_sleep;
 	struct dst_entry	*sk_dst_cache;
 	struct xfrm_policy	*sk_policy[2];
net/core/dev.c +86 -0

121 lines not on this page · raw message

*)&default_netchannel);
+ kthread_run(netchannel_default_thread, NULL, "nc_def");
+
rc = 0;
out:
return rc;

#1 lore raw
Quoted 4 lines · Kelly Daly

Implement finding of correct netchannel for buffer, default netchannel and attach a netchannel to a socket

Hi Kelly.

You have a typo in the code commented below.
I have a question regarsing your netchannel design - as far as I can see, you steal data in interrupts and then convert it into skb and run through usual netif_receive_skb(). Thus you dedicate one thread (one CPU) to do the whole processing for all sockets which do not have netchannels bound to them. Did you benchmarked such approach both with and without netchannel bound to the socket?

Quoted 4 lines
net/core/dev.c +4 -0
+/* Find the channel for a packet, or return default channel. */
+struct netchannel *find_netchannel(const struct netchannel_buftrailer *bp)
+{
+	struct sock *sk = NULL;

net/core/dev.c struct netchannel_buftrailer *__netchann · line 1940

Quoted 10 lines
net/core/dev.c +10 -0
+	int datalen = netchan_data_len(bp);
+
+	switch (bp->netchan_buf_proto) {
+	case __constant_htons(ETH_P_IP): {
+		struct iphdr *ip = (void *)bp - datalen;
+		int iphl = ip->ihl * 4;
+
+		/* FIXME: Do sanity checks, parse packet. */
+
+		if (datalen >+ (iphl + 4) && iphl == sizeof(struct iphdr)) {

A typo ">+" instead of ">=".

Signature · 1 line
	Evgeniy Polyakov
author
#2 lore raw
Quoted 1 line · Evgeniy Polyakov

You have a typo in the code commented below.

D'oh!!! That one completely slipped by me - thanks!

I'll resend this patch =)

Quoted 6 lines

I have a question regarsing your netchannel design - as far as I can see, you steal data in interrupts and then convert it into skb and run through usual netif_receive_skb(). Thus you dedicate one thread (one CPU) to do the whole processing for all sockets which do not have netchannels bound to them. Did you benchmarked such approach both with and without netchannel bound to the socket?

No benchmarking as of yet... Have been a bit busy of late with something else, but getting back into this V shortly and will hopefully have a whole lot more info for you soon.

Cheers,
K

author
#3 lore raw
In reply to Evgeniy Polyakov

Implement finding of correct netchannel for buffer, default netchannel and attach a netchannel to a socket

---

diff -urp davem/include/linux/netchannel.h
kelly_new/include/linux/netchannel.h
--- davem/include/linux/netchannel.h 2006-06-16 15:14:15.000000000 +1000
+++ kelly_new/include/linux/netchannel.h 2006-07-10 14:04:54.000000000
+1000

@@ -19,6 +19,7 @@ struct netchannel {
        void                    (*netchan_callb)(struct netchannel *);
        void                    *netchan_callb_data;
        unsigned long           netchan_head;

+ wait_queue_head_t wq;
};

extern void netchannel_init(struct netchannel *,
@@ -56,6 +57,11 @@ static inline unsigned char *netchan_buf

        return netchan_buf_base(bp) + bp->netchan_buf_offset;

}

+static inline int netchan_data_len(const struct netchannel_buftrailer *bp) +{
+ return bp->netchan_buf_len - bp->netchan_buf_offset;
+}
+
extern int netchannel_enqueue(struct netchannel *, struct
netchannel_buftrailer *);
extern struct netchannel_buftrailer *__netchannel_dequeue(struct netchannel
*);
static inline struct netchannel_buftrailer *netchannel_dequeue(struct
netchannel *np)
@@ -65,6 +71,10 @@ static inline struct netchannel_buftrail

        return __netchannel_dequeue(np);

}

+extern struct netchannel *find_netchannel(const struct netchannel_buftrailer *bp);
+extern int sock_add_netchannel(struct sock *sk);
extern struct sk_buff *skb_netchan_graft(struct netchannel_buftrailer *,
gfp_t);

#endif /* _LINUX_NETCHANNEL_H */
diff -urp davem/include/net/inet_hashtables.h kelly_new/include/net/inet_hashtables.h
--- davem/include/net/inet_hashtables.h 2006-06-16 14:34:20.000000000 +1000
+++ kelly_new/include/net/inet_hashtables.h 2006-06-19 10:42:45.000000000
+1000
@@ -418,4 +418,7 @@ static inline struct sock *inet_lookup(s

extern int inet_hash_connect(struct inet_timewait_death_row *death_row,

                             struct sock *sk);

+extern void inet_hash_register(u8 proto, struct inet_hashinfo *hashinfo); +extern struct sock *inet_lookup_proto(u8 protocol, u32 saddr, u16 sport, u32 daddr, u16 dport, int ifindex);
+
#endif /* _INET_HASHTABLES_H */

include/net/sock.h 2006-06-19 10:42:45.000000000 +1000 renamed from include/net/sock.h 2006-06-16 15:14:16.000000000 +1000 +1 -0
diff -urp davem/include/net/sock.h kelly_new/include/net/sock.h
@@ -196,6 +196,7 @@ struct sock {
        unsigned short          sk_type;
        int                     sk_rcvbuf;
        socket_lock_t           sk_lock;
+       struct netchannel       *sk_channel;
        wait_queue_head_t       *sk_sleep;
        struct dst_entry        *sk_dst_cache;
        struct xfrm_policy      *sk_policy[2];
net/core/dev.c 2006-07-10 14:11:22.000000000 +1000 renamed from net/core/dev.c 2006-06-16 15:14:16.000000000 +1000 +86 -0

121 lines not on this page · raw message

*)&default_netchannel);
+ kthread_run(netchannel_default_thread, NULL, "nc_def");
+

        rc = 0;
 out:
        return rc;
maintainer
#4 lore raw

From: Kelly Daly <[email protected]>
Date: Tue, 11 Jul 2006 16:17:56 +1000

Quoted 4 lines

Implement finding of correct netchannel for buffer, default netchannel and attach a netchannel to a socket

Kelly, I want to apply this, but your email client has busted up the patch by placing new lines all over. It also has turned tabs into spaces, which also corrupts the patch.

Can you configure KMail not to corrupt the patch like this and resubmit?

Thanks.

maintainer
#5 lore raw
In reply to Evgeniy Polyakov

From: Evgeniy Polyakov <[email protected]>
Date: Tue, 11 Jul 2006 09:57:08 +0400

Quoted 2 lines

Did you benchmarked such approach both with
and without netchannel bound to the socket?

It is not meant to be used in "real life" :-)
So benchmark is quite useless.

We are starting simple, and eventually all types of packets will hit some kind of channel, thus making the default channel a kind of anomaly slow path.

That code will not come immediately, therefore it would be nice if the performance were not too bad, and it can be made into a software interrupt or tasklet with some care.