pktgen.c (65d76f368295973a35d195c9b13053502a67b6bc) | pktgen.c (5447c5e401c49aba0c36bb1066f2d25b152553b7) |
---|---|
1/* 2 * Authors: 3 * Copyright 2001, 2002 by Robert Olsson <robert.olsson@its.uu.se> 4 * Uppsala University and 5 * Swedish University of Agricultural Sciences 6 * 7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 8 * Ben Greear <greearb@candelatech.com> --- 408 unchanged lines hidden (view full) --- 417static char version[] __initdata = VERSION; 418 419static int pktgen_remove_device(struct pktgen_thread *t, struct pktgen_dev *i); 420static int pktgen_add_device(struct pktgen_thread *t, const char *ifname); 421static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, 422 const char *ifname); 423static int pktgen_device_event(struct notifier_block *, unsigned long, void *); 424static void pktgen_run_all_threads(void); | 1/* 2 * Authors: 3 * Copyright 2001, 2002 by Robert Olsson <robert.olsson@its.uu.se> 4 * Uppsala University and 5 * Swedish University of Agricultural Sciences 6 * 7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 8 * Ben Greear <greearb@candelatech.com> --- 408 unchanged lines hidden (view full) --- 417static char version[] __initdata = VERSION; 418 419static int pktgen_remove_device(struct pktgen_thread *t, struct pktgen_dev *i); 420static int pktgen_add_device(struct pktgen_thread *t, const char *ifname); 421static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, 422 const char *ifname); 423static int pktgen_device_event(struct notifier_block *, unsigned long, void *); 424static void pktgen_run_all_threads(void); |
425static void pktgen_reset_all_threads(void); |
|
425static void pktgen_stop_all_threads_ifs(void); 426static int pktgen_stop_device(struct pktgen_dev *pkt_dev); 427static void pktgen_stop(struct pktgen_thread *t); 428static void pktgen_clear_counters(struct pktgen_dev *pkt_dev); 429 430static unsigned int scan_ip6(const char *s, char ip[16]); 431static unsigned int fmt_ip6(char *s, const char ip[16]); 432 --- 42 unchanged lines hidden (view full) --- 475 data[count - 1] = 0; /* Make string */ 476 477 if (!strcmp(data, "stop")) 478 pktgen_stop_all_threads_ifs(); 479 480 else if (!strcmp(data, "start")) 481 pktgen_run_all_threads(); 482 | 426static void pktgen_stop_all_threads_ifs(void); 427static int pktgen_stop_device(struct pktgen_dev *pkt_dev); 428static void pktgen_stop(struct pktgen_thread *t); 429static void pktgen_clear_counters(struct pktgen_dev *pkt_dev); 430 431static unsigned int scan_ip6(const char *s, char ip[16]); 432static unsigned int fmt_ip6(char *s, const char ip[16]); 433 --- 42 unchanged lines hidden (view full) --- 476 data[count - 1] = 0; /* Make string */ 477 478 if (!strcmp(data, "stop")) 479 pktgen_stop_all_threads_ifs(); 480 481 else if (!strcmp(data, "start")) 482 pktgen_run_all_threads(); 483 |
484 else if (!strcmp(data, "reset")) 485 pktgen_reset_all_threads(); 486 |
|
483 else 484 printk(KERN_WARNING "pktgen: Unknown command: %s\n", data); 485 486 err = count; 487 488out: 489 return err; 490} --- 13 unchanged lines hidden (view full) --- 504}; 505 506static int pktgen_if_show(struct seq_file *seq, void *v) 507{ 508 struct pktgen_dev *pkt_dev = seq->private; 509 __u64 sa; 510 __u64 stopped; 511 __u64 now = getCurUs(); | 487 else 488 printk(KERN_WARNING "pktgen: Unknown command: %s\n", data); 489 490 err = count; 491 492out: 493 return err; 494} --- 13 unchanged lines hidden (view full) --- 508}; 509 510static int pktgen_if_show(struct seq_file *seq, void *v) 511{ 512 struct pktgen_dev *pkt_dev = seq->private; 513 __u64 sa; 514 __u64 stopped; 515 __u64 now = getCurUs(); |
512 DECLARE_MAC_BUF(mac); | |
513 514 seq_printf(seq, 515 "Params: count %llu min_pkt_size: %u max_pkt_size: %u\n", 516 (unsigned long long)pkt_dev->count, pkt_dev->min_pkt_size, 517 pkt_dev->max_pkt_size); 518 519 seq_printf(seq, 520 " frags: %d delay: %u clone_skb: %d ifname: %s\n", --- 28 unchanged lines hidden (view full) --- 549 } else 550 seq_printf(seq, 551 " dst_min: %s dst_max: %s\n src_min: %s src_max: %s\n", 552 pkt_dev->dst_min, pkt_dev->dst_max, pkt_dev->src_min, 553 pkt_dev->src_max); 554 555 seq_puts(seq, " src_mac: "); 556 | 516 517 seq_printf(seq, 518 "Params: count %llu min_pkt_size: %u max_pkt_size: %u\n", 519 (unsigned long long)pkt_dev->count, pkt_dev->min_pkt_size, 520 pkt_dev->max_pkt_size); 521 522 seq_printf(seq, 523 " frags: %d delay: %u clone_skb: %d ifname: %s\n", --- 28 unchanged lines hidden (view full) --- 552 } else 553 seq_printf(seq, 554 " dst_min: %s dst_max: %s\n src_min: %s src_max: %s\n", 555 pkt_dev->dst_min, pkt_dev->dst_max, pkt_dev->src_min, 556 pkt_dev->src_max); 557 558 seq_puts(seq, " src_mac: "); 559 |
557 seq_printf(seq, "%s ", 558 print_mac(mac, is_zero_ether_addr(pkt_dev->src_mac) ? 559 pkt_dev->odev->dev_addr : pkt_dev->src_mac)); | 560 seq_printf(seq, "%pM ", 561 is_zero_ether_addr(pkt_dev->src_mac) ? 562 pkt_dev->odev->dev_addr : pkt_dev->src_mac); |
560 561 seq_printf(seq, "dst_mac: "); | 563 564 seq_printf(seq, "dst_mac: "); |
562 seq_printf(seq, "%s\n", print_mac(mac, pkt_dev->dst_mac)); | 565 seq_printf(seq, "%pM\n", pkt_dev->dst_mac); |
563 564 seq_printf(seq, 565 " udp_src_min: %d udp_src_max: %d udp_dst_min: %d udp_dst_max: %d\n", 566 pkt_dev->udp_src_min, pkt_dev->udp_src_max, 567 pkt_dev->udp_dst_min, pkt_dev->udp_dst_max); 568 569 seq_printf(seq, 570 " src_mac_count: %d dst_mac_count: %d\n", --- 1586 unchanged lines hidden (view full) --- 2157/* If there was already an IPSEC SA, we keep it as is, else 2158 * we go look for it ... 2159*/ 2160static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow) 2161{ 2162 struct xfrm_state *x = pkt_dev->flows[flow].x; 2163 if (!x) { 2164 /*slow path: we dont already have xfrm_state*/ | 566 567 seq_printf(seq, 568 " udp_src_min: %d udp_src_max: %d udp_dst_min: %d udp_dst_max: %d\n", 569 pkt_dev->udp_src_min, pkt_dev->udp_src_max, 570 pkt_dev->udp_dst_min, pkt_dev->udp_dst_max); 571 572 seq_printf(seq, 573 " src_mac_count: %d dst_mac_count: %d\n", --- 1586 unchanged lines hidden (view full) --- 2160/* If there was already an IPSEC SA, we keep it as is, else 2161 * we go look for it ... 2162*/ 2163static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow) 2164{ 2165 struct xfrm_state *x = pkt_dev->flows[flow].x; 2166 if (!x) { 2167 /*slow path: we dont already have xfrm_state*/ |
2165 x = xfrm_stateonly_find((xfrm_address_t *)&pkt_dev->cur_daddr, | 2168 x = xfrm_stateonly_find(&init_net, 2169 (xfrm_address_t *)&pkt_dev->cur_daddr, |
2166 (xfrm_address_t *)&pkt_dev->cur_saddr, 2167 AF_INET, 2168 pkt_dev->ipsmode, 2169 pkt_dev->ipsproto, 0); 2170 if (x) { 2171 pkt_dev->flows[flow].x = x; 2172 set_pkt_overhead(pkt_dev); 2173 pkt_dev->pkt_overhead+=x->props.header_len; --- 990 unchanged lines hidden (view full) --- 3164 3165 mutex_unlock(&pktgen_thread_lock); 3166 3167 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ 3168 3169 pktgen_wait_all_threads_run(); 3170} 3171 | 2170 (xfrm_address_t *)&pkt_dev->cur_saddr, 2171 AF_INET, 2172 pkt_dev->ipsmode, 2173 pkt_dev->ipsproto, 0); 2174 if (x) { 2175 pkt_dev->flows[flow].x = x; 2176 set_pkt_overhead(pkt_dev); 2177 pkt_dev->pkt_overhead+=x->props.header_len; --- 990 unchanged lines hidden (view full) --- 3168 3169 mutex_unlock(&pktgen_thread_lock); 3170 3171 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ 3172 3173 pktgen_wait_all_threads_run(); 3174} 3175 |
3176static void pktgen_reset_all_threads(void) 3177{ 3178 struct pktgen_thread *t; 3179 3180 pr_debug("pktgen: entering pktgen_reset_all_threads.\n"); 3181 3182 mutex_lock(&pktgen_thread_lock); 3183 3184 list_for_each_entry(t, &pktgen_threads, th_list) 3185 t->control |= (T_REMDEVALL); 3186 3187 mutex_unlock(&pktgen_thread_lock); 3188 3189 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ 3190 3191 pktgen_wait_all_threads_run(); 3192} 3193 |
|
3172static void show_results(struct pktgen_dev *pkt_dev, int nr_frags) 3173{ 3174 __u64 total_us, bps, mbps, pps, idle; 3175 char *p = pkt_dev->result; 3176 3177 total_us = pkt_dev->stopped_at - pkt_dev->started_at; 3178 3179 idle = pkt_dev->idle_acc; --- 146 unchanged lines hidden (view full) --- 3326 3327 list_del(&t->th_list); 3328 3329 mutex_unlock(&pktgen_thread_lock); 3330} 3331 3332static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev) 3333{ | 3194static void show_results(struct pktgen_dev *pkt_dev, int nr_frags) 3195{ 3196 __u64 total_us, bps, mbps, pps, idle; 3197 char *p = pkt_dev->result; 3198 3199 total_us = pkt_dev->stopped_at - pkt_dev->started_at; 3200 3201 idle = pkt_dev->idle_acc; --- 146 unchanged lines hidden (view full) --- 3348 3349 list_del(&t->th_list); 3350 3351 mutex_unlock(&pktgen_thread_lock); 3352} 3353 3354static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev) 3355{ |
3334 struct net_device *odev = NULL; | 3356 struct net_device *odev = pkt_dev->odev; 3357 int (*xmit)(struct sk_buff *, struct net_device *) 3358 = odev->netdev_ops->ndo_start_xmit; |
3335 struct netdev_queue *txq; 3336 __u64 idle_start = 0; 3337 u16 queue_map; 3338 int ret; 3339 | 3359 struct netdev_queue *txq; 3360 __u64 idle_start = 0; 3361 u16 queue_map; 3362 int ret; 3363 |
3340 odev = pkt_dev->odev; 3341 | |
3342 if (pkt_dev->delay_us || pkt_dev->delay_ns) { 3343 u64 now; 3344 3345 now = getCurUs(); 3346 if (now < pkt_dev->next_tx_us) 3347 spin(pkt_dev, pkt_dev->next_tx_us); 3348 3349 /* This is max DELAY, this has special meaning of --- 64 unchanged lines hidden (view full) --- 3414 txq = netdev_get_tx_queue(odev, queue_map); 3415 3416 __netif_tx_lock_bh(txq); 3417 if (!netif_tx_queue_stopped(txq) && 3418 !netif_tx_queue_frozen(txq)) { 3419 3420 atomic_inc(&(pkt_dev->skb->users)); 3421 retry_now: | 3364 if (pkt_dev->delay_us || pkt_dev->delay_ns) { 3365 u64 now; 3366 3367 now = getCurUs(); 3368 if (now < pkt_dev->next_tx_us) 3369 spin(pkt_dev, pkt_dev->next_tx_us); 3370 3371 /* This is max DELAY, this has special meaning of --- 64 unchanged lines hidden (view full) --- 3436 txq = netdev_get_tx_queue(odev, queue_map); 3437 3438 __netif_tx_lock_bh(txq); 3439 if (!netif_tx_queue_stopped(txq) && 3440 !netif_tx_queue_frozen(txq)) { 3441 3442 atomic_inc(&(pkt_dev->skb->users)); 3443 retry_now: |
3422 ret = odev->hard_start_xmit(pkt_dev->skb, odev); | 3444 ret = (*xmit)(pkt_dev->skb, odev); |
3423 if (likely(ret == NETDEV_TX_OK)) { 3424 pkt_dev->last_ok = 1; 3425 pkt_dev->sofar++; 3426 pkt_dev->seq_num++; 3427 pkt_dev->tx_bytes += pkt_dev->cur_pkt_size; 3428 3429 } else if (ret == NETDEV_TX_LOCKED 3430 && (odev->features & NETIF_F_LLTX)) { --- 429 unchanged lines hidden --- | 3445 if (likely(ret == NETDEV_TX_OK)) { 3446 pkt_dev->last_ok = 1; 3447 pkt_dev->sofar++; 3448 pkt_dev->seq_num++; 3449 pkt_dev->tx_bytes += pkt_dev->cur_pkt_size; 3450 3451 } else if (ret == NETDEV_TX_LOCKED 3452 && (odev->features & NETIF_F_LLTX)) { --- 429 unchanged lines hidden --- |