aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/pktgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/pktgen.c')
-rw-r--r--net/core/pktgen.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 6e79e96cb4f2..43923811bd6a 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -250,8 +250,7 @@ struct pktgen_dev {
250 __u64 count; /* Default No packets to send */ 250 __u64 count; /* Default No packets to send */
251 __u64 sofar; /* How many pkts we've sent so far */ 251 __u64 sofar; /* How many pkts we've sent so far */
252 __u64 tx_bytes; /* How many bytes we've transmitted */ 252 __u64 tx_bytes; /* How many bytes we've transmitted */
253 __u64 errors; /* Errors when trying to transmit, 253 __u64 errors; /* Errors when trying to transmit, */
254 pkts will be re-sent */
255 254
256 /* runtime counters relating to clone_skb */ 255 /* runtime counters relating to clone_skb */
257 256
@@ -340,6 +339,7 @@ struct pktgen_dev {
340 __u16 cur_udp_src; 339 __u16 cur_udp_src;
341 __u16 cur_queue_map; 340 __u16 cur_queue_map;
342 __u32 cur_pkt_size; 341 __u32 cur_pkt_size;
342 __u32 last_pkt_size;
343 343
344 __u8 hh[14]; 344 __u8 hh[14];
345 /* = { 345 /* = {
@@ -2051,9 +2051,8 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
2051 read_lock_bh(&idev->lock); 2051 read_lock_bh(&idev->lock);
2052 for (ifp = idev->addr_list; ifp; 2052 for (ifp = idev->addr_list; ifp;
2053 ifp = ifp->if_next) { 2053 ifp = ifp->if_next) {
2054 if (ifp->scope == IFA_LINK 2054 if (ifp->scope == IFA_LINK &&
2055 && !(ifp-> 2055 !(ifp->flags & IFA_F_TENTATIVE)) {
2056 flags & IFA_F_TENTATIVE)) {
2057 ipv6_addr_copy(&pkt_dev-> 2056 ipv6_addr_copy(&pkt_dev->
2058 cur_in6_saddr, 2057 cur_in6_saddr,
2059 &ifp->addr); 2058 &ifp->addr);
@@ -2189,12 +2188,13 @@ static inline int f_pick(struct pktgen_dev *pkt_dev)
2189/* If there was already an IPSEC SA, we keep it as is, else 2188/* If there was already an IPSEC SA, we keep it as is, else
2190 * we go look for it ... 2189 * we go look for it ...
2191*/ 2190*/
2191#define DUMMY_MARK 0
2192static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow) 2192static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow)
2193{ 2193{
2194 struct xfrm_state *x = pkt_dev->flows[flow].x; 2194 struct xfrm_state *x = pkt_dev->flows[flow].x;
2195 if (!x) { 2195 if (!x) {
2196 /*slow path: we dont already have xfrm_state*/ 2196 /*slow path: we dont already have xfrm_state*/
2197 x = xfrm_stateonly_find(&init_net, 2197 x = xfrm_stateonly_find(&init_net, DUMMY_MARK,
2198 (xfrm_address_t *)&pkt_dev->cur_daddr, 2198 (xfrm_address_t *)&pkt_dev->cur_daddr,
2199 (xfrm_address_t *)&pkt_dev->cur_saddr, 2199 (xfrm_address_t *)&pkt_dev->cur_saddr,
2200 AF_INET, 2200 AF_INET,
@@ -3436,7 +3436,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
3436 pkt_dev->clone_count--; /* back out increment, OOM */ 3436 pkt_dev->clone_count--; /* back out increment, OOM */
3437 return; 3437 return;
3438 } 3438 }
3439 3439 pkt_dev->last_pkt_size = pkt_dev->skb->len;
3440 pkt_dev->allocated_skbs++; 3440 pkt_dev->allocated_skbs++;
3441 pkt_dev->clone_count = 0; /* reset counter */ 3441 pkt_dev->clone_count = 0; /* reset counter */
3442 } 3442 }
@@ -3448,12 +3448,14 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
3448 txq = netdev_get_tx_queue(odev, queue_map); 3448 txq = netdev_get_tx_queue(odev, queue_map);
3449 3449
3450 __netif_tx_lock_bh(txq); 3450 __netif_tx_lock_bh(txq);
3451 atomic_inc(&(pkt_dev->skb->users));
3452 3451
3453 if (unlikely(netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq))) 3452 if (unlikely(netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq))) {
3454 ret = NETDEV_TX_BUSY; 3453 ret = NETDEV_TX_BUSY;
3455 else 3454 pkt_dev->last_ok = 0;
3456 ret = (*xmit)(pkt_dev->skb, odev); 3455 goto unlock;
3456 }
3457 atomic_inc(&(pkt_dev->skb->users));
3458 ret = (*xmit)(pkt_dev->skb, odev);
3457 3459
3458 switch (ret) { 3460 switch (ret) {
3459 case NETDEV_TX_OK: 3461 case NETDEV_TX_OK:
@@ -3461,7 +3463,13 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
3461 pkt_dev->last_ok = 1; 3463 pkt_dev->last_ok = 1;
3462 pkt_dev->sofar++; 3464 pkt_dev->sofar++;
3463 pkt_dev->seq_num++; 3465 pkt_dev->seq_num++;
3464 pkt_dev->tx_bytes += pkt_dev->cur_pkt_size; 3466 pkt_dev->tx_bytes += pkt_dev->last_pkt_size;
3467 break;
3468 case NET_XMIT_DROP:
3469 case NET_XMIT_CN:
3470 case NET_XMIT_POLICED:
3471 /* skb has been consumed */
3472 pkt_dev->errors++;
3465 break; 3473 break;
3466 default: /* Drivers are not supposed to return other values! */ 3474 default: /* Drivers are not supposed to return other values! */
3467 if (net_ratelimit()) 3475 if (net_ratelimit())
@@ -3475,6 +3483,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
3475 atomic_dec(&(pkt_dev->skb->users)); 3483 atomic_dec(&(pkt_dev->skb->users));
3476 pkt_dev->last_ok = 0; 3484 pkt_dev->last_ok = 0;
3477 } 3485 }
3486unlock:
3478 __netif_tx_unlock_bh(txq); 3487 __netif_tx_unlock_bh(txq);
3479 3488
3480 /* If pkt_dev->count is zero, then run forever */ 3489 /* If pkt_dev->count is zero, then run forever */
@@ -3516,6 +3525,7 @@ static int pktgen_thread_worker(void *arg)
3516 wait_event_interruptible_timeout(t->queue, 3525 wait_event_interruptible_timeout(t->queue,
3517 t->control != 0, 3526 t->control != 0,
3518 HZ/10); 3527 HZ/10);
3528 try_to_freeze();
3519 continue; 3529 continue;
3520 } 3530 }
3521 3531
@@ -3622,6 +3632,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
3622{ 3632{
3623 struct pktgen_dev *pkt_dev; 3633 struct pktgen_dev *pkt_dev;
3624 int err; 3634 int err;
3635 int node = cpu_to_node(t->cpu);
3625 3636
3626 /* We don't allow a device to be on several threads */ 3637 /* We don't allow a device to be on several threads */
3627 3638
@@ -3631,12 +3642,13 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
3631 return -EBUSY; 3642 return -EBUSY;
3632 } 3643 }
3633 3644
3634 pkt_dev = kzalloc(sizeof(struct pktgen_dev), GFP_KERNEL); 3645 pkt_dev = kzalloc_node(sizeof(struct pktgen_dev), GFP_KERNEL, node);
3635 if (!pkt_dev) 3646 if (!pkt_dev)
3636 return -ENOMEM; 3647 return -ENOMEM;
3637 3648
3638 strcpy(pkt_dev->odevname, ifname); 3649 strcpy(pkt_dev->odevname, ifname);
3639 pkt_dev->flows = vmalloc(MAX_CFLOWS * sizeof(struct flow_state)); 3650 pkt_dev->flows = vmalloc_node(MAX_CFLOWS * sizeof(struct flow_state),
3651 node);
3640 if (pkt_dev->flows == NULL) { 3652 if (pkt_dev->flows == NULL) {
3641 kfree(pkt_dev); 3653 kfree(pkt_dev);
3642 return -ENOMEM; 3654 return -ENOMEM;
@@ -3698,7 +3710,8 @@ static int __init pktgen_create_thread(int cpu)
3698 struct proc_dir_entry *pe; 3710 struct proc_dir_entry *pe;
3699 struct task_struct *p; 3711 struct task_struct *p;
3700 3712
3701 t = kzalloc(sizeof(struct pktgen_thread), GFP_KERNEL); 3713 t = kzalloc_node(sizeof(struct pktgen_thread), GFP_KERNEL,
3714 cpu_to_node(cpu));
3702 if (!t) { 3715 if (!t) {
3703 printk(KERN_ERR "pktgen: ERROR: out of memory, can't " 3716 printk(KERN_ERR "pktgen: ERROR: out of memory, can't "
3704 "create new thread.\n"); 3717 "create new thread.\n");