pktgen.c (046e9ceefab985a137fbd15b946497a88e5a6513) | pktgen.c (0967f2445963b63269d7dd2f5b6f234ea57dd10e) |
---|---|
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> --- 199 unchanged lines hidden (view full) --- 208#define T_STOP (1<<0) /* Stop run */ 209#define T_RUN (1<<1) /* Start run */ 210#define T_REMDEVALL (1<<2) /* Remove all devs */ 211#define T_REMDEV (1<<3) /* Remove one dev */ 212 213/* Xmit modes */ 214#define M_START_XMIT 0 /* Default normal TX */ 215#define M_NETIF_RECEIVE 1 /* Inject packets into stack */ | 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> --- 199 unchanged lines hidden (view full) --- 208#define T_STOP (1<<0) /* Stop run */ 209#define T_RUN (1<<1) /* Start run */ 210#define T_REMDEVALL (1<<2) /* Remove all devs */ 211#define T_REMDEV (1<<3) /* Remove one dev */ 212 213/* Xmit modes */ 214#define M_START_XMIT 0 /* Default normal TX */ 215#define M_NETIF_RECEIVE 1 /* Inject packets into stack */ |
216#define M_QUEUE_XMIT 2 /* Inject packet into qdisc */ |
|
216 217/* If lock -- protects updating of if_list */ 218#define if_lock(t) spin_lock(&(t->if_lock)); 219#define if_unlock(t) spin_unlock(&(t->if_lock)); 220 221/* Used to help with determining the pkts on receive */ 222#define PKTGEN_MAGIC 0xbe9be955 223#define PG_PROC_DIR "pktgen" --- 397 unchanged lines hidden (view full) --- 621 if (pkt_dev->burst > 1) 622 seq_printf(seq, " burst: %d\n", pkt_dev->burst); 623 624 if (pkt_dev->node >= 0) 625 seq_printf(seq, " node: %d\n", pkt_dev->node); 626 627 if (pkt_dev->xmit_mode == M_NETIF_RECEIVE) 628 seq_puts(seq, " xmit_mode: netif_receive\n"); | 217 218/* If lock -- protects updating of if_list */ 219#define if_lock(t) spin_lock(&(t->if_lock)); 220#define if_unlock(t) spin_unlock(&(t->if_lock)); 221 222/* Used to help with determining the pkts on receive */ 223#define PKTGEN_MAGIC 0xbe9be955 224#define PG_PROC_DIR "pktgen" --- 397 unchanged lines hidden (view full) --- 622 if (pkt_dev->burst > 1) 623 seq_printf(seq, " burst: %d\n", pkt_dev->burst); 624 625 if (pkt_dev->node >= 0) 626 seq_printf(seq, " node: %d\n", pkt_dev->node); 627 628 if (pkt_dev->xmit_mode == M_NETIF_RECEIVE) 629 seq_puts(seq, " xmit_mode: netif_receive\n"); |
630 else if (pkt_dev->xmit_mode == M_QUEUE_XMIT) 631 seq_puts(seq, " xmit_mode: xmit_queue\n"); |
|
629 630 seq_puts(seq, " Flags: "); 631 632 if (pkt_dev->flags & F_IPV6) 633 seq_puts(seq, "IPV6 "); 634 635 if (pkt_dev->flags & F_IPSRC_RND) 636 seq_puts(seq, "IPSRC_RND "); --- 500 unchanged lines hidden (view full) --- 1137 return count; 1138 } 1139 if (!strcmp(name, "burst")) { 1140 len = num_arg(&user_buffer[i], 10, &value); 1141 if (len < 0) 1142 return len; 1143 1144 i += len; | 632 633 seq_puts(seq, " Flags: "); 634 635 if (pkt_dev->flags & F_IPV6) 636 seq_puts(seq, "IPV6 "); 637 638 if (pkt_dev->flags & F_IPSRC_RND) 639 seq_puts(seq, "IPSRC_RND "); --- 500 unchanged lines hidden (view full) --- 1140 return count; 1141 } 1142 if (!strcmp(name, "burst")) { 1143 len = num_arg(&user_buffer[i], 10, &value); 1144 if (len < 0) 1145 return len; 1146 1147 i += len; |
1145 if ((value > 1) && (pkt_dev->xmit_mode == M_START_XMIT) && 1146 (!(pkt_dev->odev->priv_flags & IFF_TX_SKB_SHARING))) | 1148 if ((value > 1) && 1149 ((pkt_dev->xmit_mode == M_QUEUE_XMIT) || 1150 ((pkt_dev->xmit_mode == M_START_XMIT) && 1151 (!(pkt_dev->odev->priv_flags & IFF_TX_SKB_SHARING))))) |
1147 return -ENOTSUPP; 1148 pkt_dev->burst = value < 1 ? 1 : value; 1149 sprintf(pg_result, "OK: burst=%d", pkt_dev->burst); 1150 return count; 1151 } 1152 if (!strcmp(name, "node")) { 1153 len = num_arg(&user_buffer[i], 10, &value); 1154 if (len < 0) --- 38 unchanged lines hidden (view full) --- 1193 * pktgen_xmit() is called 1194 */ 1195 pkt_dev->last_ok = 1; 1196 1197 /* override clone_skb if user passed default value 1198 * at module loading time 1199 */ 1200 pkt_dev->clone_skb = 0; | 1152 return -ENOTSUPP; 1153 pkt_dev->burst = value < 1 ? 1 : value; 1154 sprintf(pg_result, "OK: burst=%d", pkt_dev->burst); 1155 return count; 1156 } 1157 if (!strcmp(name, "node")) { 1158 len = num_arg(&user_buffer[i], 10, &value); 1159 if (len < 0) --- 38 unchanged lines hidden (view full) --- 1198 * pktgen_xmit() is called 1199 */ 1200 pkt_dev->last_ok = 1; 1201 1202 /* override clone_skb if user passed default value 1203 * at module loading time 1204 */ 1205 pkt_dev->clone_skb = 0; |
1206 } else if (strcmp(f, "queue_xmit") == 0) { 1207 pkt_dev->xmit_mode = M_QUEUE_XMIT; 1208 pkt_dev->last_ok = 1; |
|
1201 } else { 1202 sprintf(pg_result, 1203 "xmit_mode -:%s:- unknown\nAvailable modes: %s", 1204 f, "start_xmit, netif_receive\n"); 1205 return count; 1206 } 1207 sprintf(pg_result, "OK: xmit_mode=%s", f); 1208 return count; --- 2220 unchanged lines hidden (view full) --- 3429 /* skb was 'freed' by stack, so clean few 3430 * bits and reuse it 3431 */ 3432#ifdef CONFIG_NET_CLS_ACT 3433 skb->tc_verd = 0; /* reset reclass/redir ttl */ 3434#endif 3435 } while (--burst > 0); 3436 goto out; /* Skips xmit_mode M_START_XMIT */ | 1209 } else { 1210 sprintf(pg_result, 1211 "xmit_mode -:%s:- unknown\nAvailable modes: %s", 1212 f, "start_xmit, netif_receive\n"); 1213 return count; 1214 } 1215 sprintf(pg_result, "OK: xmit_mode=%s", f); 1216 return count; --- 2220 unchanged lines hidden (view full) --- 3437 /* skb was 'freed' by stack, so clean few 3438 * bits and reuse it 3439 */ 3440#ifdef CONFIG_NET_CLS_ACT 3441 skb->tc_verd = 0; /* reset reclass/redir ttl */ 3442#endif 3443 } while (--burst > 0); 3444 goto out; /* Skips xmit_mode M_START_XMIT */ |
3445 } else if (pkt_dev->xmit_mode == M_QUEUE_XMIT) { 3446 local_bh_disable(); 3447 atomic_inc(&pkt_dev->skb->users); 3448 3449 ret = dev_queue_xmit(pkt_dev->skb); 3450 switch (ret) { 3451 case NET_XMIT_SUCCESS: 3452 pkt_dev->sofar++; 3453 pkt_dev->seq_num++; 3454 pkt_dev->tx_bytes += pkt_dev->last_pkt_size; 3455 break; 3456 case NET_XMIT_DROP: 3457 case NET_XMIT_CN: 3458 /* These are all valid return codes for a qdisc but 3459 * indicate packets are being dropped or will likely 3460 * be dropped soon. 3461 */ 3462 case NETDEV_TX_BUSY: 3463 /* qdisc may call dev_hard_start_xmit directly in cases 3464 * where no queues exist e.g. loopback device, virtual 3465 * devices, etc. In this case we need to handle 3466 * NETDEV_TX_ codes. 3467 */ 3468 default: 3469 pkt_dev->errors++; 3470 net_info_ratelimited("%s xmit error: %d\n", 3471 pkt_dev->odevname, ret); 3472 break; 3473 } 3474 goto out; |
|
3437 } 3438 3439 txq = skb_get_tx_queue(odev, pkt_dev->skb); 3440 3441 local_bh_disable(); 3442 3443 HARD_TX_LOCK(odev, txq, smp_processor_id()); 3444 --- 13 unchanged lines hidden (view full) --- 3458 pkt_dev->sofar++; 3459 pkt_dev->seq_num++; 3460 pkt_dev->tx_bytes += pkt_dev->last_pkt_size; 3461 if (burst > 0 && !netif_xmit_frozen_or_drv_stopped(txq)) 3462 goto xmit_more; 3463 break; 3464 case NET_XMIT_DROP: 3465 case NET_XMIT_CN: | 3475 } 3476 3477 txq = skb_get_tx_queue(odev, pkt_dev->skb); 3478 3479 local_bh_disable(); 3480 3481 HARD_TX_LOCK(odev, txq, smp_processor_id()); 3482 --- 13 unchanged lines hidden (view full) --- 3496 pkt_dev->sofar++; 3497 pkt_dev->seq_num++; 3498 pkt_dev->tx_bytes += pkt_dev->last_pkt_size; 3499 if (burst > 0 && !netif_xmit_frozen_or_drv_stopped(txq)) 3500 goto xmit_more; 3501 break; 3502 case NET_XMIT_DROP: 3503 case NET_XMIT_CN: |
3466 case NET_XMIT_POLICED: | |
3467 /* skb has been consumed */ 3468 pkt_dev->errors++; 3469 break; 3470 default: /* Drivers are not supposed to return other values! */ 3471 net_info_ratelimited("%s xmit error: %d\n", 3472 pkt_dev->odevname, ret); 3473 pkt_dev->errors++; 3474 /* fallthru */ --- 462 unchanged lines hidden --- | 3504 /* skb has been consumed */ 3505 pkt_dev->errors++; 3506 break; 3507 default: /* Drivers are not supposed to return other values! */ 3508 net_info_ratelimited("%s xmit error: %d\n", 3509 pkt_dev->odevname, ret); 3510 pkt_dev->errors++; 3511 /* fallthru */ --- 462 unchanged lines hidden --- |