aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authoramit salecha <amit.salecha@qlogic.com>2011-04-22 12:22:20 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-29 14:37:35 -0400
commit7d36a991e8d36b8ae87e2aa1158d3735e656253b (patch)
tree7ed43c33f2142dcf024595ab7c087cacf892ed75 /net/core
parentb6202f97897a13ef531b822ab326dfc7eb90bdaf (diff)
pktgen: create num frags requested
Pktgen doesn't generate number of frags requested. Divide packet size by number of frags and fill that in every frags. Example: With packet size 1470, it generate only 11 frags. Initial frags get lenght 706, 353, 177....so on. Last frag get divided by 2. Now with this fix, each frags will get 78 bytes. Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/pktgen.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 2fa6fee1b46f..ff79d94b5944 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2622,6 +2622,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
2622 } else { 2622 } else {
2623 int frags = pkt_dev->nfrags; 2623 int frags = pkt_dev->nfrags;
2624 int i, len; 2624 int i, len;
2625 int frag_len;
2625 2626
2626 2627
2627 if (frags > MAX_SKB_FRAGS) 2628 if (frags > MAX_SKB_FRAGS)
@@ -2633,6 +2634,8 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
2633 } 2634 }
2634 2635
2635 i = 0; 2636 i = 0;
2637 frag_len = (datalen/frags) < PAGE_SIZE ?
2638 (datalen/frags) : PAGE_SIZE;
2636 while (datalen > 0) { 2639 while (datalen > 0) {
2637 if (unlikely(!pkt_dev->page)) { 2640 if (unlikely(!pkt_dev->page)) {
2638 int node = numa_node_id(); 2641 int node = numa_node_id();
@@ -2646,38 +2649,18 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
2646 skb_shinfo(skb)->frags[i].page = pkt_dev->page; 2649 skb_shinfo(skb)->frags[i].page = pkt_dev->page;
2647 get_page(pkt_dev->page); 2650 get_page(pkt_dev->page);
2648 skb_shinfo(skb)->frags[i].page_offset = 0; 2651 skb_shinfo(skb)->frags[i].page_offset = 0;
2649 skb_shinfo(skb)->frags[i].size = 2652 /*last fragment, fill rest of data*/
2650 (datalen < PAGE_SIZE ? datalen : PAGE_SIZE); 2653 if (i == (frags - 1))
2654 skb_shinfo(skb)->frags[i].size =
2655 (datalen < PAGE_SIZE ? datalen : PAGE_SIZE);
2656 else
2657 skb_shinfo(skb)->frags[i].size = frag_len;
2651 datalen -= skb_shinfo(skb)->frags[i].size; 2658 datalen -= skb_shinfo(skb)->frags[i].size;
2652 skb->len += skb_shinfo(skb)->frags[i].size; 2659 skb->len += skb_shinfo(skb)->frags[i].size;
2653 skb->data_len += skb_shinfo(skb)->frags[i].size; 2660 skb->data_len += skb_shinfo(skb)->frags[i].size;
2654 i++; 2661 i++;
2655 skb_shinfo(skb)->nr_frags = i; 2662 skb_shinfo(skb)->nr_frags = i;
2656 } 2663 }
2657
2658 while (i < frags) {
2659 int rem;
2660
2661 if (i == 0)
2662 break;
2663
2664 rem = skb_shinfo(skb)->frags[i - 1].size / 2;
2665 if (rem == 0)
2666 break;
2667
2668 skb_shinfo(skb)->frags[i - 1].size -= rem;
2669
2670 skb_shinfo(skb)->frags[i] =
2671 skb_shinfo(skb)->frags[i - 1];
2672 get_page(skb_shinfo(skb)->frags[i].page);
2673 skb_shinfo(skb)->frags[i].page =
2674 skb_shinfo(skb)->frags[i - 1].page;
2675 skb_shinfo(skb)->frags[i].page_offset +=
2676 skb_shinfo(skb)->frags[i - 1].size;
2677 skb_shinfo(skb)->frags[i].size = rem;
2678 i++;
2679 skb_shinfo(skb)->nr_frags = i;
2680 }
2681 } 2664 }
2682 2665
2683 /* Stamp the time, and sequence number, 2666 /* Stamp the time, and sequence number,