Skip to contentSkip to conversation

Rough VJ Channel Implementation - vj_ne2k.patch

PATCH In review Kelly Daly 1 participant 1 message Apr 26, 2006

Subsystems (2)
lore
Share & tools
lore

Kelly Daly

author
#0 lore raw

PATCH 2/3 Rough VJ Channel Implementation - vj_ne2k.patch

Today 11:25:13

Hacked NE2K driver using VJ Channels on receive. Takes packet data and dumps it into a VJ buffer instead of skb. Not implemented on transmit.
Useful for testing under QEMU.

-----

drivers/net/8390.c Mon Apr 24 19:50:46 2006 renamed from drivers/net/8390.c Thu Mar 23 06:32:12 2006 +22 -21
diff -r 47031a1f466c linux-2.6.16/drivers/net/8390.c
@@ -74,6 +74,8 @@
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+
+#include <linux/vjchan.h>
 
 #define NS8390_CORE
 #include "8390.h"
@@ -718,31 +720,30 @@
                }
                 else if ((pkt_stat & 0x0F) == ENRSR_RXOK) 
                {
-                       struct sk_buff *skb;
-                       
-                       skb = dev_alloc_skb(pkt_len+2);
-                       if (skb == NULL) 
-                       {
+
+//NOT make skb - make a buffer!
+                       struct vj_buffer *vjbuffer;
+                       int desc_num;
+
+                       vjbuffer = vj_get_buffer(&desc_num);
+                       if (vjbuffer == NULL) {
+//fail
                                if (ei_debug > 1)
-                                       printk(KERN_DEBUG "%s: Couldn't allocate a sk_buff of size %d.\n",
-                                                  dev->name, pkt_len);
+                                       printk(KERN_DEBUG "%s: Couldn't allocate a vj buffer.\n",
+                                                  dev->name);
                                ei_local->stat.rx_dropped++;
                                break;
                        }
-                       else
-                       {
-                               skb_reserve(skb,2);     /* IP headers on 16 byte boundaries */
-                               skb->dev = dev;
-                               skb_put(skb, pkt_len);  /* Make room */
-                               ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame));
-                               skb->protocol=eth_type_trans(skb,dev);
-                               netif_rx(skb);
-                               dev->last_rx = jiffies;
-                               ei_local->stat.rx_packets++;
-                               ei_local->stat.rx_bytes += pkt_len;
-                               if (pkt_stat & ENRSR_PHY)
-                                       ei_local->stat.multicast++;
-                       }
+                       vjbuffer->data_len = pkt_len;
+                       vjbuffer->ifindex = dev->ifindex;
+                       ei_block_input(dev, pkt_len, vjbuffer->data, current_offset + sizeof(rx_frame));
+                       vj_netif_rx(vjbuffer, desc_num, eth_vj_type_trans(vjbuffer));
+                       dev->last_rx = jiffies;
+                       ei_local->stat.rx_packets++;
+                       ei_local->stat.rx_bytes += pkt_len;
+                       if (pkt_stat & ENRSR_PHY)
+                               ei_local->stat.multicast++;
+
                } 
                else 
                {
drivers/net/8390.h Mon Apr 24 19:50:46 2006 renamed from drivers/net/8390.h Thu Mar 23 06:32:12 2006 +1 -2
diff -r 47031a1f466c linux-2.6.16/drivers/net/8390.h
@@ -10,7 +10,6 @@
 #include <linux/config.h>
 #include <linux/if_ether.h>
 #include <linux/ioport.h>
-#include <linux/skbuff.h>
 
 #define TX_PAGES 12    /* Two Tx slots */
 
@@ -49,7 +48,7 @@
        void (*reset_8390)(struct net_device *);
        void (*get_8390_hdr)(struct net_device *, struct e8390_pkt_hdr *, int);
        void (*block_output)(struct net_device *, int, const unsigned char *, int);
-       void (*block_input)(struct net_device *, int, struct sk_buff *, int);
+       void (*block_input)(struct net_device *, int, char *, int);
        unsigned long rmem_start;
        unsigned long rmem_end;
        void __iomem *mem;
drivers/net/ne2k-pci.c Mon Apr 24 19:50:46 2006 renamed from drivers/net/ne2k-pci.c Thu Mar 23 06:32:12 2006 +2 -3
diff -r 47031a1f466c linux-2.6.16/drivers/net/ne2k-pci.c
@@ -172,7 +172,7 @@
 static void ne2k_pci_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
                          int ring_page);
 static void ne2k_pci_block_input(struct net_device *dev, int count,
-                         struct sk_buff *skb, int ring_offset);
+                         char *data, int ring_offset);
 static void ne2k_pci_block_output(struct net_device *dev, const int count,
                const unsigned char *buf, const int start_page);
 static struct ethtool_ops ne2k_pci_ethtool_ops;
@@ -503,10 +503,9 @@
    the packet out through the "remote DMA" dataport using outb. */
 
 static void ne2k_pci_block_input(struct net_device *dev, int count,
-                                struct sk_buff *skb, int ring_offset)
+                                char *buf, int ring_offset)
 {
        long nic_base = dev->base_addr;
-       char *buf = skb->data;
 
        /* This *shouldn't* happen. If it does, it's the last thing you'll see */
        if (ei_status.dmaing) {