@@ -94,7 +94,7 @@
#include <linux/pf_ring.h>
-// #define RING_DEBUG
+#define RING_DEBUG
#ifndef SVN_REV
#define SVN_REV ""
@@ -334,7 +334,7 @@
struct pfring_pkthdr *hdr;
u_int32_t real_slot_size;
- smp_rmb();
+ // smp_rmb();
hdr = (struct pfring_pkthdr*)get_slot(pfr, off);
real_slot_size = pfr->slot_header_len + hdr->extended_hdr.parsed_header_len + hdr->caplen;
@@ -352,7 +352,7 @@
static inline u_int32_t num_queued_pkts(struct ring_opt *pfr)
{
- smp_rmb();
+ // smp_rmb();
if(pfr->ring_slots != NULL) {
u_int32_t tot_insert = pfr->slots_info->tot_insert, tot_read = pfr->slots_info->tot_read;
@@ -371,18 +371,25 @@
return(0);
}
+/* ************************************* */
+
+inline u_int get_num_ring_free_slots(struct ring_opt * pfr)
+{
+ return(pfr->slots_info->min_num_slots - num_queued_pkts(pfr));
+}
+
/* ********************************** */
static inline int check_and_init_free_slot(struct ring_opt *pfr, int off)
{
- smp_rmb();
+ // smp_rmb();
if(pfr->slots_info->insert_off == pfr->slots_info->remove_off) {
/*
Both insert and remove offset are set on the same slot.
We need to find out whether the memory is full or empty
*/
-
+
if(num_queued_pkts(pfr) >= min_num_slots)
return(0); /* Memory is full */
} else {
@@ -474,24 +481,19 @@
if(ring_proc_dir != NULL) {
char name[64];
-
+
snprintf(name, sizeof(name), "%d-%s.%d",
pfr->ring_pid, pfr->ring_netdev->name,
pfr->ring_id);
+ printk("[PF_RING] Removing /proc/net/pf_ring/%s\n", name);
+
remove_proc_entry(name, ring_proc_dir);
if(debug) printk("[PF_RING] Removed /proc/net/pf_ring/%s\n", name);
}
}
-/* ************************************* */
-
-inline u_int get_num_ring_free_slots(struct ring_opt * pfr)
-{
- return(pfr->slots_info->min_num_slots - num_queued_pkts(pfr));
-}
-
/* ********************************** */
static int ring_proc_dev_get_info(char *buf, char **start, off_t offset,
@@ -730,22 +732,14 @@
if(data == NULL) {
/* /proc/net/pf_ring/info */
- rlen = sprintf(buf, "PF_RING Version : %s ($Revision: %s$)\n",
- RING_VERSION, SVN_REV);
- rlen += sprintf(buf + rlen, "Ring slots : %d\n",
- min_num_slots);
- rlen += sprintf(buf + rlen, "Slot version : %d\n",
- RING_FLOWSLOT_VERSION);
- rlen += sprintf(buf + rlen, "Capture TX : %s\n",
- enable_tx_capture ? "Yes [RX+TX]" : "No [RX only]");
- rlen += sprintf(buf + rlen, "IP Defragment : %s\n",
- enable_ip_defrag ? "Yes" : "No");
- rlen += sprintf(buf + rlen, "Transparent mode : %s\n",
- (transparent_mode != driver2pf_ring_non_transparent) ? "Yes" : "No");
- rlen += sprintf(buf + rlen, "Total rings : %d\n",
- ring_table_size);
- rlen += sprintf(buf + rlen, "Total plugins : %d\n",
- plugin_registration_size);
+ rlen = sprintf(buf, "PF_RING Version : %s ($Revision: %s$)\n", RING_VERSION, SVN_REV);
+ rlen += sprintf(buf + rlen, "Ring slots : %d\n", min_num_slots);
+ rlen += sprintf(buf + rlen, "Slot version : %d\n", RING_FLOWSLOT_VERSION);
+ rlen += sprintf(buf + rlen, "Capture TX : %s\n", enable_tx_capture ? "Yes [RX+TX]" : "No [RX only]");
+ rlen += sprintf(buf + rlen, "IP Defragment : %s\n", enable_ip_defrag ? "Yes" : "No");
+ rlen += sprintf(buf + rlen, "Transparent mode : %s\n", (transparent_mode != driver2pf_ring_non_transparent) ? "Yes" : "No");
+ rlen += sprintf(buf + rlen, "Total rings : %d\n", ring_table_size);
+ rlen += sprintf(buf + rlen, "Total plugins : %d\n", plugin_registration_size);
} else {
/* detailed statistics about a PF_RING */
pfr = (struct ring_opt *)data;
@@ -754,43 +748,29 @@
fsi = pfr->slots_info;
if(fsi) {
- rlen = sprintf(buf, "Bound Device : %s\n",
- pfr->ring_netdev->name);
- rlen += sprintf(buf + rlen, "Slot Version : %d [%s]\n",
- fsi->version, RING_VERSION);
- rlen += sprintf(buf + rlen, "Active : %d\n",
- pfr->ring_active);
- rlen += sprintf(buf + rlen, "Sampling Rate : %d\n",
- pfr->sample_rate);
- rlen += sprintf(buf + rlen, "Appl. Name : %s\n",
- pfr->appl_name ? pfr->appl_name : "<unknown>");
- rlen += sprintf(buf + rlen, "IP Defragment : %s\n",
- enable_ip_defrag ? "Yes" : "No");
- rlen += sprintf(buf + rlen, "BPF Filtering : %s\n",
- pfr->bpfFilter ? "Enabled" : "Disabled");
- rlen += sprintf(buf + rlen, "# Filt. Rules : %d\n",
- pfr->num_filtering_rules);
+ rlen = sprintf(buf, "Bound Device : %s\n", pfr->ring_netdev->name);
+ rlen += sprintf(buf + rlen, "Slot Version : %d [%s]\n", fsi->version, RING_VERSION);
+ rlen += sprintf(buf + rlen, "Active : %d\n", pfr->ring_active);
+ rlen += sprintf(buf + rlen, "Sampling Rate : %d\n", pfr->sample_rate);
+ rlen += sprintf(buf + rlen, "Appl. Name : %s\n", pfr->appl_name ? pfr->appl_name : "<unknown>");
+ rlen += sprintf(buf + rlen, "IP Defragment : %s\n", enable_ip_defrag ? "Yes" : "No");
+ rlen += sprintf(buf + rlen, "BPF Filtering : %s\n", pfr->bpfFilter ? "Enabled" : "Disabled");
+ rlen += sprintf(buf + rlen, "# Filt. Rules : %d\n", pfr->num_filtering_rules);
rlen += sprintf(buf + rlen, "Cluster Id : %d\n", pfr->cluster_id);
rlen += sprintf(buf + rlen, "Channel Id : %d\n", pfr->channel_id);
rlen += sprintf(buf + rlen, "Min Num Slots : %d\n", fsi->min_num_slots);
rlen += sprintf(buf + rlen, "Bucket Len : %d\n", fsi->data_len);
- rlen += sprintf(buf + rlen, "Slot Len : %d [bucket+header]\n",
- fsi->slot_len);
+ rlen += sprintf(buf + rlen, "Slot Len : %d [bucket+header]\n", fsi->slot_len);
rlen += sprintf(buf + rlen, "Tot Memory : %d\n", fsi->tot_mem);
- rlen += sprintf(buf + rlen, "Tot Packets : %lu\n",
- (unsigned long)fsi->tot_pkts);
- rlen += sprintf(buf + rlen, "Tot Pkt Lost : %lu\n",
- (unsigned long)fsi->tot_lost);
- rlen += sprintf(buf + rlen, "Tot Insert : %lu\n",
- (unsigned long)fsi->tot_insert);
- rlen += sprintf(buf + rlen, "Tot Read : %lu\n",
- (unsigned long)fsi->tot_read);
- rlen += sprintf(buf + rlen, "Tot Fwd Ok : %lu\n",
- (unsigned long)fsi->tot_fwd_ok);
- rlen += sprintf(buf + rlen, "Tot Fwd Errors : %lu\n",
- (unsigned long)fsi->tot_fwd_notok);
- rlen += sprintf(buf + rlen, "Num Free Slots : %u\n",
- get_num_ring_free_slots(pfr));
+ rlen += sprintf(buf + rlen, "Tot Packets : %lu\n", (unsigned long)fsi->tot_pkts);
+ rlen += sprintf(buf + rlen, "Tot Pkt Lost : %lu\n", (unsigned long)fsi->tot_lost);
+ rlen += sprintf(buf + rlen, "Tot Insert : %lu\n", (unsigned long)fsi->tot_insert);
+ rlen += sprintf(buf + rlen, "Tot Read : %lu\n", (unsigned long)fsi->tot_read);
+ rlen += sprintf(buf + rlen, "Insert Offset : %lu\n", (unsigned long)fsi->insert_off);
+ rlen += sprintf(buf + rlen, "Remove Offset : %lu\n", (unsigned long)fsi->remove_off);
+ rlen += sprintf(buf + rlen, "Tot Fwd Ok : %lu\n", (unsigned long)fsi->tot_fwd_ok);
+ rlen += sprintf(buf + rlen, "Tot Fwd Errors : %lu\n", (unsigned long)fsi->tot_fwd_notok);
+ rlen += sprintf(buf + rlen, "Num Free Slots : %u\n", get_num_ring_free_slots(pfr));
} else
rlen = sprintf(buf, "WARNING fsi == NULL\n");
} else
@@ -1629,7 +1609,7 @@
if(pfr->ring_slots == NULL) return;
write_lock_bh(&pfr->ring_index_lock);
- smp_rmb();
+ // smp_rmb();
off = pfr->slots_info->insert_off;
pfr->slots_info->tot_pkts++;
@@ -1695,10 +1675,10 @@
pfr->slots_info->tot_insert++;
/* Flush data to mmap-ed memory area */
- smp_wmb();
- flush_packet_memory(ring_bucket, bytes_to_flush);
- flush_packet_memory((u8*)pfr->slots_info, sizeof(FlowSlotInfo));
- smp_mb();
+ // smp_wmb();
+ //flush_packet_memory(ring_bucket, bytes_to_flush);
+ //flush_packet_memory((u8*)pfr->slots_info, sizeof(FlowSlotInfo));
+ // smp_mb();
write_unlock_bh(&pfr->ring_index_lock);
@@ -2322,11 +2302,10 @@
#endif
#if defined(RING_DEBUG)
- printk("[PF_RING] --> skb_ring_handler() [channel_id=%d/%d]\n", channel_id, num_rx_channels);
+ // printk("[PF_RING] --> skb_ring_handler() [channel_id=%d/%d]\n", channel_id, num_rx_channels);
#endif
- if((!skb) /* Invalid skb */
- ||((!enable_tx_capture) && (!recv_packet))) {
+ if((!skb) /* Invalid skb */ ||((!enable_tx_capture) && (!recv_packet))) {
/*
An outgoing packet is about to be sent out
but we decided not to handle transmitted
@@ -3158,6 +3137,8 @@
start = vma->vm_start;
+ printk("[PF_RING] do_memory_mmap(mode=%d, size=%lu, ptr=%p)\n", mode, size, ptr);
+
while(size > 0) {
int rc;
@@ -3168,11 +3149,9 @@
rc = remap_pfn_range(vma, start, kvirt_to_pa((unsigned long)ptr), PAGE_SIZE, PAGE_SHARED);
#endif
} else if(mode == 1) {
- rc = remap_pfn_range(vma, start, __pa(ptr) >> PAGE_SHIFT,
- PAGE_SIZE, PAGE_SHARED);
+ rc = remap_pfn_range(vma, start, __pa(ptr) >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED);
} else {
- rc = remap_pfn_range(vma, start, ((unsigned long)ptr) >> PAGE_SHIFT,
- PAGE_SIZE, PAGE_SHARED);
+ rc = remap_pfn_range(vma, start, ((unsigned long)ptr) >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED);
}
if(rc) {
@@ -3215,11 +3194,11 @@
if(size % PAGE_SIZE) {
#if defined(RING_DEBUG)
- printk("[PF_RING] ring_mmap() failed: "
- "len is not multiple of PAGE_SIZE\n");
+ printk("[PF_RING] ring_mmap() failed: len is not multiple of PAGE_SIZE\n");
#endif
return(-EINVAL);
}
+
#if defined(RING_DEBUG)
printk("[PF_RING] ring_mmap() called, size: %ld bytes [bucket_len=%d]\n",
size, pfr->bucket_len);
@@ -3253,37 +3232,37 @@
if((rc = do_memory_mmap(vma, size, pfr->ring_memory, VM_LOCKED, 0)) < 0)
return(rc);
} else {
+ int count = pfr->mmap_count;
/* DNA Device */
if(pfr->dna_device == NULL)
return(-EAGAIN);
- switch (pfr->mmap_count) {
+ printk("[PF_RING] mmap count(%d)\n", count);
+
+ pfr->mmap_count++;
+
+ switch(count) {
case 0:
if((rc = do_memory_mmap(vma, size,
- (void *)pfr->dna_device->packet_memory,
- VM_LOCKED, 1)) < 0)
+ (void *)pfr->dna_device->packet_memory, VM_LOCKED, 1)) < 0)
return(rc);
break;
case 1:
if((rc = do_memory_mmap(vma, size,
- (void *)pfr->dna_device->descr_packet_memory,
- VM_LOCKED, 1)) < 0)
+ (void *)pfr->dna_device->descr_packet_memory, VM_LOCKED, 1)) < 0)
return(rc);
break;
case 2:
if((rc = do_memory_mmap(vma, size,
- (void *)pfr->dna_device->phys_card_memory,
- (VM_RESERVED | VM_IO), 2)) < 0)
+ (void *)pfr->dna_device->phys_card_memory, (VM_RESERVED | VM_IO), 2)) < 0)
return(rc);
break;
default:
return(-EAGAIN);
}
-
- pfr->mmap_count++;
}
#if defined(RING_DEBUG)
@@ -3322,13 +3301,6 @@
}
}
-#if defined(RING_DEBUG)
- if(slot != NULL)
- printk("[PF_RING] ring_recvmsg is returning "
- "[queued_pkts=%d][num_loops=%d]\n",
- queued_pkts, num_loops);
-#endif
-
return(queued_pkts);
}
@@ -3462,7 +3434,7 @@
#endif
pfr->ring_active = 1;
- smp_rmb();
+ // smp_rmb();
if(pfr->slots_info->tot_read == pfr->slots_info->tot_insert) {
poll_wait(file, &pfr->ring_slots_waitqueue, wait);
@@ -3703,7 +3675,7 @@
static int ring_map_dna_device(struct ring_opt *pfr,
dna_device_mapping * mapping)
{
- int debug = 0;
+ int debug = 1;
if(mapping->operation == remove_device_mapping) {
pfr->dna_device = NULL;
@@ -3725,8 +3697,8 @@
pfr->dna_device = &entry->dev, pfr->ring_netdev = entry->dev.netdev;
if(debug)
- printk("[PF_RING] ring_map_dna_device(%s): added mapping\n",
- mapping->device_name);
+ printk("[PF_RING] ring_map_dna_device(%s, %u): added mapping\n",
+ mapping->device_name, mapping->channel_id);
ring_proc_add(pfr);
return(0);
@@ -3734,8 +3706,8 @@
}
}
- printk("[PF_RING] ring_map_dna_device(%s): mapping failed\n",
- mapping->device_name);
+ printk("[PF_RING] ring_map_dna_device(%s, %u): mapping failed\n",
+ mapping->device_name, mapping->channel_id);
return(-1);
}
@@ -4749,12 +4721,9 @@
packet_memory_slot_len;
next->dev.packet_memory_tot_len = packet_memory_tot_len;
next->dev.descr_packet_memory = descr_packet_memory;
- next->dev.descr_packet_memory_num_slots =
- descr_packet_memory_num_slots;
- next->dev.descr_packet_memory_slot_len =
- descr_packet_memory_slot_len;
- next->dev.descr_packet_memory_tot_len =
- descr_packet_memory_tot_len;
+ next->dev.descr_packet_memory_num_slots = descr_packet_memory_num_slots;
+ next->dev.descr_packet_memory_slot_len = descr_packet_memory_slot_len;
+ next->dev.descr_packet_memory_tot_len = descr_packet_memory_tot_len;
next->dev.phys_card_memory = phys_card_memory;
next->dev.phys_card_memory_len = phys_card_memory_len;
next->dev.channel_id = channel_id;
|