Lines Matching +full:max +full:- +full:burst +full:- +full:len
1 // SPDX-License-Identifier: GPL-2.0-or-later
23 * MAC address typo fixed. 010417 --ro
24 * Integrated. 020301 --DaveM
25 * Added multiskb option 020301 --DaveM
26 * Scaling of results. 020417--sigurdur@linpro.no
27 * Significant re-work of the module:
31 * * Allow configuration of ranges, like min/max IP address, MACs,
32 * and UDP-ports, for both source and destination, and can
35 * * Place 12-byte packet in UDP payload with magic number,
37 * * Add receiver code that detects dropped pkts, re-ordered pkts, and
38 * latencies (with micro-second) precision.
40 * --Ben Greear <greearb@candelatech.com>
50 * --ro
52 * Sept 10: Fixed threading/locking. Lots of bone-headed and more clever
53 * mistakes. Also merged in DaveM's patch in the -pre6 patch.
54 * --Ben Greear <greearb@candelatech.com>
56 * Integrated to 2.5.x 021029 --Lucio Maciel (luciomaciel@zipmail.com.br)
64 * also the thread checks the thread->control which is used for inter-process
76 * /proc/irq/XX/smp_affinity so TX-interrupts gets bound to the same CPU.
77 * --ro
80 * memleak 030710- KJP
82 * First "ranges" functionality for ipv6 030726 --ro
86 * Fixed unaligned access on IA-64 Grant Grundler <grundler@parisc-linux.org>
107 * 802.1Q/Q-in-Q support by Francesco Fondelli (FF) <francesco.fondelli@gmail.com>
176 #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */
178 /* Max number of internet mix entries that can be specified in imix_weights. */
186 pf(IPSRC_RND) /* IP-Src Random */ \
187 pf(IPDST_RND) /* IP-Dst Random */ \
189 pf(UDPSRC_RND) /* UDP-Src Random */ \
190 pf(UDPDST_RND) /* UDP-Dst Random */ \
198 pf(MACSRC_RND) /* MAC-Src Random */ \
199 pf(MACDST_RND) /* MAC-Dst Random */ \
235 /* If lock -- protects updating of if_list */
236 #define if_lock(t) mutex_lock(&(t->if_lock));
237 #define if_unlock(t) mutex_unlock(&(t->if_lock));
246 #define VLAN_TAG_SIZE(x) ((x)->vlan_id == 0xffff ? 0 : 4)
247 #define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4)
273 struct list_head list; /* chaining in the thread's run-queue */
278 /* If min != max, then we will either do a linear iteration, or
287 int removal_mark; /* non-zero => the device is marked for
291 u64 delay; /* nano-seconds */
308 u64 idle_acc; /* nano-seconds */
338 * defines the min/max for those ranges.
359 /* Maps 0-IMIX_PRECISION range to imix_entry based on probability*/
366 /* VLAN/SVLAN (802.1Q/Q-in-Q) */
406 struct net_device *odev; /* The out-going device.
410 * Set when the user specifies the out-going
425 unsigned int burst; /* number of duplicated packets to burst */ member
520 struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id); in pgctrl_write()
523 return -EPERM; in pgctrl_write()
526 return -EINVAL; in pgctrl_write()
532 return -EFAULT; in pgctrl_write()
534 data[count - 1] = 0; /* Strip trailing '\n' and terminate string */ in pgctrl_write()
543 return -EINVAL; in pgctrl_write()
563 const struct pktgen_dev *pkt_dev = seq->private; in pktgen_if_show()
570 (unsigned long long)pkt_dev->count, pkt_dev->min_pkt_size, in pktgen_if_show()
571 pkt_dev->max_pkt_size); in pktgen_if_show()
573 if (pkt_dev->n_imix_entries > 0) { in pktgen_if_show()
575 for (i = 0; i < pkt_dev->n_imix_entries; i++) { in pktgen_if_show()
577 pkt_dev->imix_entries[i].size, in pktgen_if_show()
578 pkt_dev->imix_entries[i].weight); in pktgen_if_show()
585 pkt_dev->nfrags, (unsigned long long) pkt_dev->delay, in pktgen_if_show()
586 pkt_dev->clone_skb, pkt_dev->odevname); in pktgen_if_show()
588 seq_printf(seq, " flows: %u flowlen: %u\n", pkt_dev->cflows, in pktgen_if_show()
589 pkt_dev->lflow); in pktgen_if_show()
593 pkt_dev->queue_map_min, in pktgen_if_show()
594 pkt_dev->queue_map_max); in pktgen_if_show()
596 if (pkt_dev->skb_priority) in pktgen_if_show()
598 pkt_dev->skb_priority); in pktgen_if_show()
600 if (pkt_dev->flags & F_IPV6) { in pktgen_if_show()
604 &pkt_dev->in6_saddr, in pktgen_if_show()
605 &pkt_dev->min_in6_saddr, &pkt_dev->max_in6_saddr, in pktgen_if_show()
606 &pkt_dev->in6_daddr, in pktgen_if_show()
607 &pkt_dev->min_in6_daddr, &pkt_dev->max_in6_daddr); in pktgen_if_show()
611 pkt_dev->dst_min, pkt_dev->dst_max); in pktgen_if_show()
614 pkt_dev->src_min, pkt_dev->src_max); in pktgen_if_show()
620 is_zero_ether_addr(pkt_dev->src_mac) ? in pktgen_if_show()
621 pkt_dev->odev->dev_addr : pkt_dev->src_mac); in pktgen_if_show()
624 seq_printf(seq, "%pM\n", pkt_dev->dst_mac); in pktgen_if_show()
629 pkt_dev->udp_src_min, pkt_dev->udp_src_max, in pktgen_if_show()
630 pkt_dev->udp_dst_min, pkt_dev->udp_dst_max); in pktgen_if_show()
634 pkt_dev->src_mac_count, pkt_dev->dst_mac_count); in pktgen_if_show()
636 if (pkt_dev->nr_labels) { in pktgen_if_show()
638 for (i = 0; i < pkt_dev->nr_labels; i++) in pktgen_if_show()
639 seq_printf(seq, "%08x%s", ntohl(pkt_dev->labels[i]), in pktgen_if_show()
640 i == pkt_dev->nr_labels-1 ? "\n" : ", "); in pktgen_if_show()
643 if (pkt_dev->vlan_id != 0xffff) in pktgen_if_show()
645 pkt_dev->vlan_id, pkt_dev->vlan_p, in pktgen_if_show()
646 pkt_dev->vlan_cfi); in pktgen_if_show()
648 if (pkt_dev->svlan_id != 0xffff) in pktgen_if_show()
650 pkt_dev->svlan_id, pkt_dev->svlan_p, in pktgen_if_show()
651 pkt_dev->svlan_cfi); in pktgen_if_show()
653 if (pkt_dev->tos) in pktgen_if_show()
654 seq_printf(seq, " tos: 0x%02x\n", pkt_dev->tos); in pktgen_if_show()
656 if (pkt_dev->traffic_class) in pktgen_if_show()
657 seq_printf(seq, " traffic_class: 0x%02x\n", pkt_dev->traffic_class); in pktgen_if_show()
659 if (pkt_dev->burst > 1) in pktgen_if_show()
660 seq_printf(seq, " burst: %d\n", pkt_dev->burst); in pktgen_if_show()
662 if (pkt_dev->node >= 0) in pktgen_if_show()
663 seq_printf(seq, " node: %d\n", pkt_dev->node); in pktgen_if_show()
665 if (pkt_dev->xmit_mode == M_NETIF_RECEIVE) in pktgen_if_show()
667 else if (pkt_dev->xmit_mode == M_QUEUE_XMIT) in pktgen_if_show()
674 if (!pkt_dev->cflows) in pktgen_if_show()
677 if (pkt_dev->flags & (1 << i)) { in pktgen_if_show()
680 if (i == IPSEC_SHIFT && pkt_dev->spi) in pktgen_if_show()
681 seq_printf(seq, "spi:%u ", pkt_dev->spi); in pktgen_if_show()
690 /* not really stopped, more like last-running-at */ in pktgen_if_show()
691 stopped = pkt_dev->running ? ktime_get() : pkt_dev->stopped_at; in pktgen_if_show()
692 idle = pkt_dev->idle_acc; in pktgen_if_show()
696 "Current:\n pkts-sofar: %llu errors: %llu\n", in pktgen_if_show()
697 (unsigned long long)pkt_dev->sofar, in pktgen_if_show()
698 (unsigned long long)pkt_dev->errors); in pktgen_if_show()
700 if (pkt_dev->n_imix_entries > 0) { in pktgen_if_show()
704 for (i = 0; i < pkt_dev->n_imix_entries; i++) { in pktgen_if_show()
706 pkt_dev->imix_entries[i].size, in pktgen_if_show()
707 pkt_dev->imix_entries[i].count_so_far); in pktgen_if_show()
714 (unsigned long long) ktime_to_us(pkt_dev->started_at), in pktgen_if_show()
720 pkt_dev->seq_num, pkt_dev->cur_dst_mac_offset, in pktgen_if_show()
721 pkt_dev->cur_src_mac_offset); in pktgen_if_show()
723 if (pkt_dev->flags & F_IPV6) { in pktgen_if_show()
725 &pkt_dev->cur_in6_saddr, in pktgen_if_show()
726 &pkt_dev->cur_in6_daddr); in pktgen_if_show()
729 &pkt_dev->cur_saddr, &pkt_dev->cur_daddr); in pktgen_if_show()
732 pkt_dev->cur_udp_dst, pkt_dev->cur_udp_src); in pktgen_if_show()
734 seq_printf(seq, " cur_queue_map: %u\n", pkt_dev->cur_queue_map); in pktgen_if_show()
736 seq_printf(seq, " flows: %u\n", pkt_dev->nflows); in pktgen_if_show()
738 if (pkt_dev->result[0]) in pktgen_if_show()
739 seq_printf(seq, "Result: %s\n", pkt_dev->result); in pktgen_if_show()
758 return -EFAULT; in hex32_arg()
776 return -EFAULT; in count_trail_chars()
802 return -EFAULT; in num_arg()
805 *num += c - '0'; in num_arg()
819 return -EFAULT; in strn_len()
845 long len; in get_imix_entries() local
848 pkt_dev->n_imix_entries = 0; in get_imix_entries()
854 len = num_arg(&buffer[i], max_digits, &size); in get_imix_entries()
855 if (len < 0) in get_imix_entries()
856 return len; in get_imix_entries()
857 i += len; in get_imix_entries()
859 return -EFAULT; in get_imix_entries()
862 return -EINVAL; in get_imix_entries()
868 len = num_arg(&buffer[i], max_digits, &weight); in get_imix_entries()
869 if (len < 0) in get_imix_entries()
870 return len; in get_imix_entries()
872 return -EINVAL; in get_imix_entries()
874 pkt_dev->imix_entries[pkt_dev->n_imix_entries].size = size; in get_imix_entries()
875 pkt_dev->imix_entries[pkt_dev->n_imix_entries].weight = weight; in get_imix_entries()
877 i += len; in get_imix_entries()
879 return -EFAULT; in get_imix_entries()
882 pkt_dev->n_imix_entries++; in get_imix_entries()
884 if (pkt_dev->n_imix_entries > MAX_IMIX_ENTRIES) in get_imix_entries()
885 return -E2BIG; in get_imix_entries()
896 int len; in get_labels() local
898 pkt_dev->nr_labels = 0; in get_labels()
901 len = hex32_arg(&buffer[i], 8, &tmp); in get_labels()
902 if (len <= 0) in get_labels()
903 return len; in get_labels()
904 pkt_dev->labels[n] = htonl(tmp); in get_labels()
905 if (pkt_dev->labels[n] & MPLS_STACK_BOTTOM) in get_labels()
906 pkt_dev->flags |= F_MPLS_RND; in get_labels()
907 i += len; in get_labels()
909 return -EFAULT; in get_labels()
913 return -E2BIG; in get_labels()
916 pkt_dev->nr_labels = n; in get_labels()
953 struct seq_file *seq = file->private_data; in pktgen_if_write()
954 struct pktgen_dev *pkt_dev = seq->private; in pktgen_if_write()
955 int i, max, len; in pktgen_if_write() local
962 pg_result = &(pkt_dev->result[0]); in pktgen_if_write()
966 return -EINVAL; in pktgen_if_write()
969 max = count; in pktgen_if_write()
970 tmp = count_trail_chars(user_buffer, max); in pktgen_if_write()
979 len = strn_len(&user_buffer[i], sizeof(name) - 1); in pktgen_if_write()
980 if (len < 0) in pktgen_if_write()
981 return len; in pktgen_if_write()
984 if (copy_from_user(name, &user_buffer[i], len)) in pktgen_if_write()
985 return -EFAULT; in pktgen_if_write()
986 i += len; in pktgen_if_write()
988 max = count - i; in pktgen_if_write()
989 len = count_trail_chars(&user_buffer[i], max); in pktgen_if_write()
990 if (len < 0) in pktgen_if_write()
991 return len; in pktgen_if_write()
993 i += len; in pktgen_if_write()
1002 pr_debug("%s,%zu buffer -:%s:-\n", name, count, tp); in pktgen_if_write()
1007 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1008 if (len < 0) in pktgen_if_write()
1009 return len; in pktgen_if_write()
1011 i += len; in pktgen_if_write()
1014 if (value != pkt_dev->min_pkt_size) { in pktgen_if_write()
1015 pkt_dev->min_pkt_size = value; in pktgen_if_write()
1016 pkt_dev->cur_pkt_size = value; in pktgen_if_write()
1019 pkt_dev->min_pkt_size); in pktgen_if_write()
1024 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1025 if (len < 0) in pktgen_if_write()
1026 return len; in pktgen_if_write()
1028 i += len; in pktgen_if_write()
1031 if (value != pkt_dev->max_pkt_size) { in pktgen_if_write()
1032 pkt_dev->max_pkt_size = value; in pktgen_if_write()
1033 pkt_dev->cur_pkt_size = value; in pktgen_if_write()
1036 pkt_dev->max_pkt_size); in pktgen_if_write()
1040 /* Shortcut for min = max */ in pktgen_if_write()
1043 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1044 if (len < 0) in pktgen_if_write()
1045 return len; in pktgen_if_write()
1047 i += len; in pktgen_if_write()
1050 if (value != pkt_dev->min_pkt_size) { in pktgen_if_write()
1051 pkt_dev->min_pkt_size = value; in pktgen_if_write()
1052 pkt_dev->max_pkt_size = value; in pktgen_if_write()
1053 pkt_dev->cur_pkt_size = value; in pktgen_if_write()
1055 sprintf(pg_result, "OK: pkt_size=%d", pkt_dev->min_pkt_size); in pktgen_if_write()
1060 if (pkt_dev->clone_skb > 0) in pktgen_if_write()
1061 return -EINVAL; in pktgen_if_write()
1063 len = get_imix_entries(&user_buffer[i], pkt_dev); in pktgen_if_write()
1064 if (len < 0) in pktgen_if_write()
1065 return len; in pktgen_if_write()
1069 i += len; in pktgen_if_write()
1074 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1075 if (len < 0) in pktgen_if_write()
1076 return len; in pktgen_if_write()
1078 i += len; in pktgen_if_write()
1085 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1086 if (len < 0) in pktgen_if_write()
1087 return len; in pktgen_if_write()
1089 i += len; in pktgen_if_write()
1090 pkt_dev->nfrags = value; in pktgen_if_write()
1091 sprintf(pg_result, "OK: frags=%d", pkt_dev->nfrags); in pktgen_if_write()
1095 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1096 if (len < 0) in pktgen_if_write()
1097 return len; in pktgen_if_write()
1099 i += len; in pktgen_if_write()
1101 pkt_dev->delay = ULLONG_MAX; in pktgen_if_write()
1103 pkt_dev->delay = (u64)value; in pktgen_if_write()
1106 (unsigned long long) pkt_dev->delay); in pktgen_if_write()
1110 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1111 if (len < 0) in pktgen_if_write()
1112 return len; in pktgen_if_write()
1114 i += len; in pktgen_if_write()
1116 return len; in pktgen_if_write()
1117 pkt_dev->delay = pkt_dev->min_pkt_size*8*NSEC_PER_USEC/value; in pktgen_if_write()
1119 pr_info("Delay set at: %llu ns\n", pkt_dev->delay); in pktgen_if_write()
1125 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1126 if (len < 0) in pktgen_if_write()
1127 return len; in pktgen_if_write()
1129 i += len; in pktgen_if_write()
1131 return len; in pktgen_if_write()
1132 pkt_dev->delay = NSEC_PER_SEC/value; in pktgen_if_write()
1134 pr_info("Delay set at: %llu ns\n", pkt_dev->delay); in pktgen_if_write()
1140 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1141 if (len < 0) in pktgen_if_write()
1142 return len; in pktgen_if_write()
1144 i += len; in pktgen_if_write()
1145 if (value != pkt_dev->udp_src_min) { in pktgen_if_write()
1146 pkt_dev->udp_src_min = value; in pktgen_if_write()
1147 pkt_dev->cur_udp_src = value; in pktgen_if_write()
1149 sprintf(pg_result, "OK: udp_src_min=%u", pkt_dev->udp_src_min); in pktgen_if_write()
1153 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1154 if (len < 0) in pktgen_if_write()
1155 return len; in pktgen_if_write()
1157 i += len; in pktgen_if_write()
1158 if (value != pkt_dev->udp_dst_min) { in pktgen_if_write()
1159 pkt_dev->udp_dst_min = value; in pktgen_if_write()
1160 pkt_dev->cur_udp_dst = value; in pktgen_if_write()
1162 sprintf(pg_result, "OK: udp_dst_min=%u", pkt_dev->udp_dst_min); in pktgen_if_write()
1166 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1167 if (len < 0) in pktgen_if_write()
1168 return len; in pktgen_if_write()
1170 i += len; in pktgen_if_write()
1171 if (value != pkt_dev->udp_src_max) { in pktgen_if_write()
1172 pkt_dev->udp_src_max = value; in pktgen_if_write()
1173 pkt_dev->cur_udp_src = value; in pktgen_if_write()
1175 sprintf(pg_result, "OK: udp_src_max=%u", pkt_dev->udp_src_max); in pktgen_if_write()
1179 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1180 if (len < 0) in pktgen_if_write()
1181 return len; in pktgen_if_write()
1183 i += len; in pktgen_if_write()
1184 if (value != pkt_dev->udp_dst_max) { in pktgen_if_write()
1185 pkt_dev->udp_dst_max = value; in pktgen_if_write()
1186 pkt_dev->cur_udp_dst = value; in pktgen_if_write()
1188 sprintf(pg_result, "OK: udp_dst_max=%u", pkt_dev->udp_dst_max); in pktgen_if_write()
1192 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1193 if (len < 0) in pktgen_if_write()
1194 return len; in pktgen_if_write()
1199 ((pkt_dev->xmit_mode == M_NETIF_RECEIVE) || in pktgen_if_write()
1200 !(pkt_dev->odev->priv_flags & IFF_TX_SKB_SHARING))) in pktgen_if_write()
1201 return -ENOTSUPP; in pktgen_if_write()
1202 if (value > 0 && (pkt_dev->n_imix_entries > 0 || in pktgen_if_write()
1203 !(pkt_dev->flags & F_SHARED))) in pktgen_if_write()
1204 return -EINVAL; in pktgen_if_write()
1206 i += len; in pktgen_if_write()
1207 pkt_dev->clone_skb = value; in pktgen_if_write()
1209 sprintf(pg_result, "OK: clone_skb=%d", pkt_dev->clone_skb); in pktgen_if_write()
1213 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1214 if (len < 0) in pktgen_if_write()
1215 return len; in pktgen_if_write()
1217 i += len; in pktgen_if_write()
1218 pkt_dev->count = value; in pktgen_if_write()
1220 (unsigned long long)pkt_dev->count); in pktgen_if_write()
1224 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1225 if (len < 0) in pktgen_if_write()
1226 return len; in pktgen_if_write()
1228 i += len; in pktgen_if_write()
1229 if (pkt_dev->src_mac_count != value) { in pktgen_if_write()
1230 pkt_dev->src_mac_count = value; in pktgen_if_write()
1231 pkt_dev->cur_src_mac_offset = 0; in pktgen_if_write()
1234 pkt_dev->src_mac_count); in pktgen_if_write()
1238 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1239 if (len < 0) in pktgen_if_write()
1240 return len; in pktgen_if_write()
1242 i += len; in pktgen_if_write()
1243 if (pkt_dev->dst_mac_count != value) { in pktgen_if_write()
1244 pkt_dev->dst_mac_count = value; in pktgen_if_write()
1245 pkt_dev->cur_dst_mac_offset = 0; in pktgen_if_write()
1248 pkt_dev->dst_mac_count); in pktgen_if_write()
1251 if (!strcmp(name, "burst")) { in pktgen_if_write()
1252 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1253 if (len < 0) in pktgen_if_write()
1254 return len; in pktgen_if_write()
1256 i += len; in pktgen_if_write()
1258 ((pkt_dev->xmit_mode == M_QUEUE_XMIT) || in pktgen_if_write()
1259 ((pkt_dev->xmit_mode == M_START_XMIT) && in pktgen_if_write()
1260 (!(pkt_dev->odev->priv_flags & IFF_TX_SKB_SHARING))))) in pktgen_if_write()
1261 return -ENOTSUPP; in pktgen_if_write()
1263 if (value > 1 && !(pkt_dev->flags & F_SHARED)) in pktgen_if_write()
1264 return -EINVAL; in pktgen_if_write()
1266 pkt_dev->burst = value < 1 ? 1 : value; in pktgen_if_write()
1267 sprintf(pg_result, "OK: burst=%u", pkt_dev->burst); in pktgen_if_write()
1271 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1272 if (len < 0) in pktgen_if_write()
1273 return len; in pktgen_if_write()
1275 i += len; in pktgen_if_write()
1278 pkt_dev->node = value; in pktgen_if_write()
1279 sprintf(pg_result, "OK: node=%d", pkt_dev->node); in pktgen_if_write()
1280 if (pkt_dev->page) { in pktgen_if_write()
1281 put_page(pkt_dev->page); in pktgen_if_write()
1282 pkt_dev->page = NULL; in pktgen_if_write()
1293 len = strn_len(&user_buffer[i], sizeof(f) - 1); in pktgen_if_write()
1294 if (len < 0) in pktgen_if_write()
1295 return len; in pktgen_if_write()
1297 if (copy_from_user(f, &user_buffer[i], len)) in pktgen_if_write()
1298 return -EFAULT; in pktgen_if_write()
1299 i += len; in pktgen_if_write()
1302 pkt_dev->xmit_mode = M_START_XMIT; in pktgen_if_write()
1305 if (pkt_dev->clone_skb > 0) in pktgen_if_write()
1306 return -ENOTSUPP; in pktgen_if_write()
1308 pkt_dev->xmit_mode = M_NETIF_RECEIVE; in pktgen_if_write()
1313 pkt_dev->last_ok = 1; in pktgen_if_write()
1315 pkt_dev->xmit_mode = M_QUEUE_XMIT; in pktgen_if_write()
1316 pkt_dev->last_ok = 1; in pktgen_if_write()
1319 "xmit_mode -:%s:- unknown\nAvailable modes: %s", in pktgen_if_write()
1333 len = strn_len(&user_buffer[i], sizeof(f) - 1); in pktgen_if_write()
1334 if (len < 0) in pktgen_if_write()
1335 return len; in pktgen_if_write()
1337 if (copy_from_user(f, &user_buffer[i], len)) in pktgen_if_write()
1338 return -EFAULT; in pktgen_if_write()
1339 i += len; in pktgen_if_write()
1344 /* If "clone_skb", or "burst" parameters are in pktgen_if_write()
1349 if (flag == F_SHARED && (pkt_dev->clone_skb || in pktgen_if_write()
1350 pkt_dev->burst > 1)) in pktgen_if_write()
1351 return -EINVAL; in pktgen_if_write()
1352 pkt_dev->flags &= ~flag; in pktgen_if_write()
1354 pkt_dev->flags |= flag; in pktgen_if_write()
1357 sprintf(pg_result, "OK: flags=0x%x", pkt_dev->flags); in pktgen_if_write()
1362 end = pkt_dev->result + sizeof(pkt_dev->result); in pktgen_if_write()
1364 "Flag -:%s:- unknown\n" in pktgen_if_write()
1365 "Available flags, (prepend ! to un-set flag):\n", f); in pktgen_if_write()
1370 pg_result += snprintf(pg_result, end - pg_result, in pktgen_if_write()
1375 *(pg_result - 2) = '\0'; in pktgen_if_write()
1381 len = strn_len(&user_buffer[i], sizeof(pkt_dev->dst_min) - 1); in pktgen_if_write()
1382 if (len < 0) in pktgen_if_write()
1383 return len; in pktgen_if_write()
1385 if (copy_from_user(buf, &user_buffer[i], len)) in pktgen_if_write()
1386 return -EFAULT; in pktgen_if_write()
1387 buf[len] = 0; in pktgen_if_write()
1388 if (strcmp(buf, pkt_dev->dst_min) != 0) { in pktgen_if_write()
1389 memset(pkt_dev->dst_min, 0, sizeof(pkt_dev->dst_min)); in pktgen_if_write()
1390 strcpy(pkt_dev->dst_min, buf); in pktgen_if_write()
1391 pkt_dev->daddr_min = in_aton(pkt_dev->dst_min); in pktgen_if_write()
1392 pkt_dev->cur_daddr = pkt_dev->daddr_min; in pktgen_if_write()
1395 pr_debug("dst_min set to: %s\n", pkt_dev->dst_min); in pktgen_if_write()
1396 i += len; in pktgen_if_write()
1397 sprintf(pg_result, "OK: dst_min=%s", pkt_dev->dst_min); in pktgen_if_write()
1401 len = strn_len(&user_buffer[i], sizeof(pkt_dev->dst_max) - 1); in pktgen_if_write()
1402 if (len < 0) in pktgen_if_write()
1403 return len; in pktgen_if_write()
1405 if (copy_from_user(buf, &user_buffer[i], len)) in pktgen_if_write()
1406 return -EFAULT; in pktgen_if_write()
1407 buf[len] = 0; in pktgen_if_write()
1408 if (strcmp(buf, pkt_dev->dst_max) != 0) { in pktgen_if_write()
1409 memset(pkt_dev->dst_max, 0, sizeof(pkt_dev->dst_max)); in pktgen_if_write()
1410 strcpy(pkt_dev->dst_max, buf); in pktgen_if_write()
1411 pkt_dev->daddr_max = in_aton(pkt_dev->dst_max); in pktgen_if_write()
1412 pkt_dev->cur_daddr = pkt_dev->daddr_max; in pktgen_if_write()
1415 pr_debug("dst_max set to: %s\n", pkt_dev->dst_max); in pktgen_if_write()
1416 i += len; in pktgen_if_write()
1417 sprintf(pg_result, "OK: dst_max=%s", pkt_dev->dst_max); in pktgen_if_write()
1421 len = strn_len(&user_buffer[i], sizeof(buf) - 1); in pktgen_if_write()
1422 if (len < 0) in pktgen_if_write()
1423 return len; in pktgen_if_write()
1425 pkt_dev->flags |= F_IPV6; in pktgen_if_write()
1427 if (copy_from_user(buf, &user_buffer[i], len)) in pktgen_if_write()
1428 return -EFAULT; in pktgen_if_write()
1429 buf[len] = 0; in pktgen_if_write()
1431 in6_pton(buf, -1, pkt_dev->in6_daddr.s6_addr, -1, NULL); in pktgen_if_write()
1432 snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->in6_daddr); in pktgen_if_write()
1434 pkt_dev->cur_in6_daddr = pkt_dev->in6_daddr; in pktgen_if_write()
1439 i += len; in pktgen_if_write()
1444 len = strn_len(&user_buffer[i], sizeof(buf) - 1); in pktgen_if_write()
1445 if (len < 0) in pktgen_if_write()
1446 return len; in pktgen_if_write()
1448 pkt_dev->flags |= F_IPV6; in pktgen_if_write()
1450 if (copy_from_user(buf, &user_buffer[i], len)) in pktgen_if_write()
1451 return -EFAULT; in pktgen_if_write()
1452 buf[len] = 0; in pktgen_if_write()
1454 in6_pton(buf, -1, pkt_dev->min_in6_daddr.s6_addr, -1, NULL); in pktgen_if_write()
1455 snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->min_in6_daddr); in pktgen_if_write()
1457 pkt_dev->cur_in6_daddr = pkt_dev->min_in6_daddr; in pktgen_if_write()
1461 i += len; in pktgen_if_write()
1466 len = strn_len(&user_buffer[i], sizeof(buf) - 1); in pktgen_if_write()
1467 if (len < 0) in pktgen_if_write()
1468 return len; in pktgen_if_write()
1470 pkt_dev->flags |= F_IPV6; in pktgen_if_write()
1472 if (copy_from_user(buf, &user_buffer[i], len)) in pktgen_if_write()
1473 return -EFAULT; in pktgen_if_write()
1474 buf[len] = 0; in pktgen_if_write()
1476 in6_pton(buf, -1, pkt_dev->max_in6_daddr.s6_addr, -1, NULL); in pktgen_if_write()
1477 snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->max_in6_daddr); in pktgen_if_write()
1482 i += len; in pktgen_if_write()
1487 len = strn_len(&user_buffer[i], sizeof(buf) - 1); in pktgen_if_write()
1488 if (len < 0) in pktgen_if_write()
1489 return len; in pktgen_if_write()
1491 pkt_dev->flags |= F_IPV6; in pktgen_if_write()
1493 if (copy_from_user(buf, &user_buffer[i], len)) in pktgen_if_write()
1494 return -EFAULT; in pktgen_if_write()
1495 buf[len] = 0; in pktgen_if_write()
1497 in6_pton(buf, -1, pkt_dev->in6_saddr.s6_addr, -1, NULL); in pktgen_if_write()
1498 snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->in6_saddr); in pktgen_if_write()
1500 pkt_dev->cur_in6_saddr = pkt_dev->in6_saddr; in pktgen_if_write()
1505 i += len; in pktgen_if_write()
1510 len = strn_len(&user_buffer[i], sizeof(pkt_dev->src_min) - 1); in pktgen_if_write()
1511 if (len < 0) in pktgen_if_write()
1512 return len; in pktgen_if_write()
1514 if (copy_from_user(buf, &user_buffer[i], len)) in pktgen_if_write()
1515 return -EFAULT; in pktgen_if_write()
1516 buf[len] = 0; in pktgen_if_write()
1517 if (strcmp(buf, pkt_dev->src_min) != 0) { in pktgen_if_write()
1518 memset(pkt_dev->src_min, 0, sizeof(pkt_dev->src_min)); in pktgen_if_write()
1519 strcpy(pkt_dev->src_min, buf); in pktgen_if_write()
1520 pkt_dev->saddr_min = in_aton(pkt_dev->src_min); in pktgen_if_write()
1521 pkt_dev->cur_saddr = pkt_dev->saddr_min; in pktgen_if_write()
1524 pr_debug("src_min set to: %s\n", pkt_dev->src_min); in pktgen_if_write()
1525 i += len; in pktgen_if_write()
1526 sprintf(pg_result, "OK: src_min=%s", pkt_dev->src_min); in pktgen_if_write()
1530 len = strn_len(&user_buffer[i], sizeof(pkt_dev->src_max) - 1); in pktgen_if_write()
1531 if (len < 0) in pktgen_if_write()
1532 return len; in pktgen_if_write()
1534 if (copy_from_user(buf, &user_buffer[i], len)) in pktgen_if_write()
1535 return -EFAULT; in pktgen_if_write()
1536 buf[len] = 0; in pktgen_if_write()
1537 if (strcmp(buf, pkt_dev->src_max) != 0) { in pktgen_if_write()
1538 memset(pkt_dev->src_max, 0, sizeof(pkt_dev->src_max)); in pktgen_if_write()
1539 strcpy(pkt_dev->src_max, buf); in pktgen_if_write()
1540 pkt_dev->saddr_max = in_aton(pkt_dev->src_max); in pktgen_if_write()
1541 pkt_dev->cur_saddr = pkt_dev->saddr_max; in pktgen_if_write()
1544 pr_debug("src_max set to: %s\n", pkt_dev->src_max); in pktgen_if_write()
1545 i += len; in pktgen_if_write()
1546 sprintf(pg_result, "OK: src_max=%s", pkt_dev->src_max); in pktgen_if_write()
1550 len = strn_len(&user_buffer[i], sizeof(valstr) - 1); in pktgen_if_write()
1551 if (len < 0) in pktgen_if_write()
1552 return len; in pktgen_if_write()
1555 if (copy_from_user(valstr, &user_buffer[i], len)) in pktgen_if_write()
1556 return -EFAULT; in pktgen_if_write()
1558 if (!mac_pton(valstr, pkt_dev->dst_mac)) in pktgen_if_write()
1559 return -EINVAL; in pktgen_if_write()
1561 ether_addr_copy(&pkt_dev->hh[0], pkt_dev->dst_mac); in pktgen_if_write()
1563 sprintf(pg_result, "OK: dstmac %pM", pkt_dev->dst_mac); in pktgen_if_write()
1567 len = strn_len(&user_buffer[i], sizeof(valstr) - 1); in pktgen_if_write()
1568 if (len < 0) in pktgen_if_write()
1569 return len; in pktgen_if_write()
1572 if (copy_from_user(valstr, &user_buffer[i], len)) in pktgen_if_write()
1573 return -EFAULT; in pktgen_if_write()
1575 if (!mac_pton(valstr, pkt_dev->src_mac)) in pktgen_if_write()
1576 return -EINVAL; in pktgen_if_write()
1578 ether_addr_copy(&pkt_dev->hh[6], pkt_dev->src_mac); in pktgen_if_write()
1580 sprintf(pg_result, "OK: srcmac %pM", pkt_dev->src_mac); in pktgen_if_write()
1591 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1592 if (len < 0) in pktgen_if_write()
1593 return len; in pktgen_if_write()
1595 i += len; in pktgen_if_write()
1599 pkt_dev->cflows = value; in pktgen_if_write()
1600 sprintf(pg_result, "OK: flows=%u", pkt_dev->cflows); in pktgen_if_write()
1605 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1606 if (len < 0) in pktgen_if_write()
1607 return len; in pktgen_if_write()
1609 i += len; in pktgen_if_write()
1610 pkt_dev->spi = value; in pktgen_if_write()
1611 sprintf(pg_result, "OK: spi=%u", pkt_dev->spi); in pktgen_if_write()
1616 len = num_arg(&user_buffer[i], 10, &value); in pktgen_if_write()
1617 if (len < 0) in pktgen_if_write()
1618 return len; in pktgen_if_write()
1620 i += len; in pktgen_if_write()
1621 pkt_dev->lflow = value; in pktgen_if_write()
1622 sprintf(pg_result, "OK: flowlen=%u", pkt_dev->lflow); in pktgen_if_write()
1627 len = num_arg(&user_buffer[i], 5, &value); in pktgen_if_write()
1628 if (len < 0) in pktgen_if_write()
1629 return len; in pktgen_if_write()
1631 i += len; in pktgen_if_write()
1632 pkt_dev->queue_map_min = value; in pktgen_if_write()
1633 sprintf(pg_result, "OK: queue_map_min=%u", pkt_dev->queue_map_min); in pktgen_if_write()
1638 len = num_arg(&user_buffer[i], 5, &value); in pktgen_if_write()
1639 if (len < 0) in pktgen_if_write()
1640 return len; in pktgen_if_write()
1642 i += len; in pktgen_if_write()
1643 pkt_dev->queue_map_max = value; in pktgen_if_write()
1644 sprintf(pg_result, "OK: queue_map_max=%u", pkt_dev->queue_map_max); in pktgen_if_write()
1651 len = get_labels(&user_buffer[i], pkt_dev); in pktgen_if_write()
1652 if (len < 0) in pktgen_if_write()
1653 return len; in pktgen_if_write()
1654 i += len; in pktgen_if_write()
1656 for (n = 0; n < pkt_dev->nr_labels; n++) in pktgen_if_write()
1658 "%08x%s", ntohl(pkt_dev->labels[n]), in pktgen_if_write()
1659 n == pkt_dev->nr_labels-1 ? "" : ","); in pktgen_if_write()
1661 if (pkt_dev->nr_labels && pkt_dev->vlan_id != 0xffff) { in pktgen_if_write()
1662 pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */ in pktgen_if_write()
1663 pkt_dev->svlan_id = 0xffff; in pktgen_if_write()
1672 len = num_arg(&user_buffer[i], 4, &value); in pktgen_if_write()
1673 if (len < 0) in pktgen_if_write()
1674 return len; in pktgen_if_write()
1676 i += len; in pktgen_if_write()
1678 pkt_dev->vlan_id = value; /* turn on VLAN */ in pktgen_if_write()
1683 if (debug && pkt_dev->nr_labels) in pktgen_if_write()
1686 pkt_dev->nr_labels = 0; /* turn off MPLS */ in pktgen_if_write()
1687 sprintf(pg_result, "OK: vlan_id=%u", pkt_dev->vlan_id); in pktgen_if_write()
1689 pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */ in pktgen_if_write()
1690 pkt_dev->svlan_id = 0xffff; in pktgen_if_write()
1699 len = num_arg(&user_buffer[i], 1, &value); in pktgen_if_write()
1700 if (len < 0) in pktgen_if_write()
1701 return len; in pktgen_if_write()
1703 i += len; in pktgen_if_write()
1704 if ((value <= 7) && (pkt_dev->vlan_id != 0xffff)) { in pktgen_if_write()
1705 pkt_dev->vlan_p = value; in pktgen_if_write()
1706 sprintf(pg_result, "OK: vlan_p=%u", pkt_dev->vlan_p); in pktgen_if_write()
1708 sprintf(pg_result, "ERROR: vlan_p must be 0-7"); in pktgen_if_write()
1714 len = num_arg(&user_buffer[i], 1, &value); in pktgen_if_write()
1715 if (len < 0) in pktgen_if_write()
1716 return len; in pktgen_if_write()
1718 i += len; in pktgen_if_write()
1719 if ((value <= 1) && (pkt_dev->vlan_id != 0xffff)) { in pktgen_if_write()
1720 pkt_dev->vlan_cfi = value; in pktgen_if_write()
1721 sprintf(pg_result, "OK: vlan_cfi=%u", pkt_dev->vlan_cfi); in pktgen_if_write()
1723 sprintf(pg_result, "ERROR: vlan_cfi must be 0-1"); in pktgen_if_write()
1729 len = num_arg(&user_buffer[i], 4, &value); in pktgen_if_write()
1730 if (len < 0) in pktgen_if_write()
1731 return len; in pktgen_if_write()
1733 i += len; in pktgen_if_write()
1734 if ((value <= 4095) && ((pkt_dev->vlan_id != 0xffff))) { in pktgen_if_write()
1735 pkt_dev->svlan_id = value; /* turn on SVLAN */ in pktgen_if_write()
1740 if (debug && pkt_dev->nr_labels) in pktgen_if_write()
1743 pkt_dev->nr_labels = 0; /* turn off MPLS */ in pktgen_if_write()
1744 sprintf(pg_result, "OK: svlan_id=%u", pkt_dev->svlan_id); in pktgen_if_write()
1746 pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */ in pktgen_if_write()
1747 pkt_dev->svlan_id = 0xffff; in pktgen_if_write()
1756 len = num_arg(&user_buffer[i], 1, &value); in pktgen_if_write()
1757 if (len < 0) in pktgen_if_write()
1758 return len; in pktgen_if_write()
1760 i += len; in pktgen_if_write()
1761 if ((value <= 7) && (pkt_dev->svlan_id != 0xffff)) { in pktgen_if_write()
1762 pkt_dev->svlan_p = value; in pktgen_if_write()
1763 sprintf(pg_result, "OK: svlan_p=%u", pkt_dev->svlan_p); in pktgen_if_write()
1765 sprintf(pg_result, "ERROR: svlan_p must be 0-7"); in pktgen_if_write()
1771 len = num_arg(&user_buffer[i], 1, &value); in pktgen_if_write()
1772 if (len < 0) in pktgen_if_write()
1773 return len; in pktgen_if_write()
1775 i += len; in pktgen_if_write()
1776 if ((value <= 1) && (pkt_dev->svlan_id != 0xffff)) { in pktgen_if_write()
1777 pkt_dev->svlan_cfi = value; in pktgen_if_write()
1778 sprintf(pg_result, "OK: svlan_cfi=%u", pkt_dev->svlan_cfi); in pktgen_if_write()
1780 sprintf(pg_result, "ERROR: svlan_cfi must be 0-1"); in pktgen_if_write()
1787 len = hex32_arg(&user_buffer[i], 2, &tmp_value); in pktgen_if_write()
1788 if (len < 0) in pktgen_if_write()
1789 return len; in pktgen_if_write()
1791 i += len; in pktgen_if_write()
1792 if (len == 2) { in pktgen_if_write()
1793 pkt_dev->tos = tmp_value; in pktgen_if_write()
1794 sprintf(pg_result, "OK: tos=0x%02x", pkt_dev->tos); in pktgen_if_write()
1796 sprintf(pg_result, "ERROR: tos must be 00-ff"); in pktgen_if_write()
1803 len = hex32_arg(&user_buffer[i], 2, &tmp_value); in pktgen_if_write()
1804 if (len < 0) in pktgen_if_write()
1805 return len; in pktgen_if_write()
1807 i += len; in pktgen_if_write()
1808 if (len == 2) { in pktgen_if_write()
1809 pkt_dev->traffic_class = tmp_value; in pktgen_if_write()
1810 sprintf(pg_result, "OK: traffic_class=0x%02x", pkt_dev->traffic_class); in pktgen_if_write()
1812 sprintf(pg_result, "ERROR: traffic_class must be 00-ff"); in pktgen_if_write()
1818 len = num_arg(&user_buffer[i], 9, &value); in pktgen_if_write()
1819 if (len < 0) in pktgen_if_write()
1820 return len; in pktgen_if_write()
1822 i += len; in pktgen_if_write()
1823 pkt_dev->skb_priority = value; in pktgen_if_write()
1825 pkt_dev->skb_priority); in pktgen_if_write()
1829 sprintf(pkt_dev->result, "No such parameter \"%s\"", name); in pktgen_if_write()
1830 return -EINVAL; in pktgen_if_write()
1848 struct pktgen_thread *t = seq->private; in pktgen_thread_show()
1856 list_for_each_entry_rcu(pkt_dev, &t->if_list, list) in pktgen_thread_show()
1857 if (pkt_dev->running) in pktgen_thread_show()
1858 seq_printf(seq, "%s ", pkt_dev->odevname); in pktgen_thread_show()
1862 list_for_each_entry_rcu(pkt_dev, &t->if_list, list) in pktgen_thread_show()
1863 if (!pkt_dev->running) in pktgen_thread_show()
1864 seq_printf(seq, "%s ", pkt_dev->odevname); in pktgen_thread_show()
1866 if (t->result[0]) in pktgen_thread_show()
1867 seq_printf(seq, "\nResult: %s\n", t->result); in pktgen_thread_show()
1880 struct seq_file *seq = file->private_data; in pktgen_thread_write()
1881 struct pktgen_thread *t = seq->private; in pktgen_thread_write()
1882 int i, max, len, ret; in pktgen_thread_write() local
1888 return -EINVAL; in pktgen_thread_write()
1891 max = count; in pktgen_thread_write()
1892 len = count_trail_chars(user_buffer, max); in pktgen_thread_write()
1893 if (len < 0) in pktgen_thread_write()
1894 return len; in pktgen_thread_write()
1896 i = len; in pktgen_thread_write()
1900 len = strn_len(&user_buffer[i], sizeof(name) - 1); in pktgen_thread_write()
1901 if (len < 0) in pktgen_thread_write()
1902 return len; in pktgen_thread_write()
1905 if (copy_from_user(name, &user_buffer[i], len)) in pktgen_thread_write()
1906 return -EFAULT; in pktgen_thread_write()
1907 i += len; in pktgen_thread_write()
1909 max = count - i; in pktgen_thread_write()
1910 len = count_trail_chars(&user_buffer[i], max); in pktgen_thread_write()
1911 if (len < 0) in pktgen_thread_write()
1912 return len; in pktgen_thread_write()
1914 i += len; in pktgen_thread_write()
1921 ret = -EINVAL; in pktgen_thread_write()
1925 pg_result = &(t->result[0]); in pktgen_thread_write()
1930 len = strn_len(&user_buffer[i], sizeof(f) - 1); in pktgen_thread_write()
1931 if (len < 0) { in pktgen_thread_write()
1932 ret = len; in pktgen_thread_write()
1935 if (copy_from_user(f, &user_buffer[i], len)) in pktgen_thread_write()
1936 return -EFAULT; in pktgen_thread_write()
1937 i += len; in pktgen_thread_write()
1951 t->control |= T_REMDEVALL; in pktgen_thread_write()
1953 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ in pktgen_thread_write()
1960 sprintf(pg_result, "OK: Note! max_before_softirq is obsoleted -- Do not use"); in pktgen_thread_write()
1965 ret = -EINVAL; in pktgen_thread_write()
1991 list_for_each_entry(t, &pn->pktgen_threads, th_list) { in __pktgen_NN_threads()
1995 pkt_dev->removal_mark = 1; in __pktgen_NN_threads()
1996 t->control |= T_REMDEV; in __pktgen_NN_threads()
2045 list_for_each_entry(t, &pn->pktgen_threads, th_list) { in pktgen_change_name()
2049 list_for_each_entry(pkt_dev, &t->if_list, list) { in pktgen_change_name()
2050 if (pkt_dev->odev != dev) in pktgen_change_name()
2053 proc_remove(pkt_dev->entry); in pktgen_change_name()
2055 pkt_dev->entry = proc_create_data(dev->name, 0600, in pktgen_change_name()
2056 pn->proc_dir, in pktgen_change_name()
2059 if (!pkt_dev->entry) in pktgen_change_name()
2061 dev->name); in pktgen_change_name()
2075 if (pn->pktgen_exiting) in pktgen_device_event()
2088 pktgen_mark_device(pn, dev->name); in pktgen_device_event()
2110 return dev_get_by_name(pn->net, b); in pktgen_dev_get_by_name()
2123 if (pkt_dev->odev) { in pktgen_setup_dev()
2124 netdev_put(pkt_dev->odev, &pkt_dev->dev_tracker); in pktgen_setup_dev()
2125 pkt_dev->odev = NULL; in pktgen_setup_dev()
2131 return -ENODEV; in pktgen_setup_dev()
2134 if (odev->type != ARPHRD_ETHER && odev->type != ARPHRD_LOOPBACK) { in pktgen_setup_dev()
2136 err = -EINVAL; in pktgen_setup_dev()
2139 err = -ENETDOWN; in pktgen_setup_dev()
2141 pkt_dev->odev = odev; in pktgen_setup_dev()
2142 netdev_tracker_alloc(odev, &pkt_dev->dev_tracker, GFP_KERNEL); in pktgen_setup_dev()
2157 if (!pkt_dev->odev) { in pktgen_setup_inject()
2158 pr_err("ERROR: pkt_dev->odev == NULL in setup_inject\n"); in pktgen_setup_inject()
2159 sprintf(pkt_dev->result, in pktgen_setup_inject()
2160 "ERROR: pkt_dev->odev == NULL in setup_inject.\n"); in pktgen_setup_inject()
2164 /* make sure that we don't pick a non-existing transmit queue */ in pktgen_setup_inject()
2165 ntxq = pkt_dev->odev->real_num_tx_queues; in pktgen_setup_inject()
2167 if (ntxq <= pkt_dev->queue_map_min) { in pktgen_setup_inject()
2168 …pr_warn("WARNING: Requested queue_map_min (zero-based) (%d) exceeds valid range [0 - %d] for (%d) … in pktgen_setup_inject()
2169 pkt_dev->queue_map_min, (ntxq ?: 1) - 1, ntxq, in pktgen_setup_inject()
2170 pkt_dev->odevname); in pktgen_setup_inject()
2171 pkt_dev->queue_map_min = (ntxq ?: 1) - 1; in pktgen_setup_inject()
2173 if (pkt_dev->queue_map_max >= ntxq) { in pktgen_setup_inject()
2174 …pr_warn("WARNING: Requested queue_map_max (zero-based) (%d) exceeds valid range [0 - %d] for (%d) … in pktgen_setup_inject()
2175 pkt_dev->queue_map_max, (ntxq ?: 1) - 1, ntxq, in pktgen_setup_inject()
2176 pkt_dev->odevname); in pktgen_setup_inject()
2177 pkt_dev->queue_map_max = (ntxq ?: 1) - 1; in pktgen_setup_inject()
2182 if (is_zero_ether_addr(pkt_dev->src_mac)) in pktgen_setup_inject()
2183 ether_addr_copy(&(pkt_dev->hh[6]), pkt_dev->odev->dev_addr); in pktgen_setup_inject()
2186 ether_addr_copy(&(pkt_dev->hh[0]), pkt_dev->dst_mac); in pktgen_setup_inject()
2188 if (pkt_dev->flags & F_IPV6) { in pktgen_setup_inject()
2192 if (pkt_dev->min_pkt_size == 0) { in pktgen_setup_inject()
2193 pkt_dev->min_pkt_size = 14 + sizeof(struct ipv6hdr) in pktgen_setup_inject()
2196 + pkt_dev->pkt_overhead; in pktgen_setup_inject()
2200 if (pkt_dev->cur_in6_saddr.s6_addr[i]) { in pktgen_setup_inject()
2214 idev = __in6_dev_get(pkt_dev->odev); in pktgen_setup_inject()
2218 read_lock_bh(&idev->lock); in pktgen_setup_inject()
2219 list_for_each_entry(ifp, &idev->addr_list, if_list) { in pktgen_setup_inject()
2220 if ((ifp->scope & IFA_LINK) && in pktgen_setup_inject()
2221 !(ifp->flags & IFA_F_TENTATIVE)) { in pktgen_setup_inject()
2222 pkt_dev->cur_in6_saddr = ifp->addr; in pktgen_setup_inject()
2227 read_unlock_bh(&idev->lock); in pktgen_setup_inject()
2234 if (pkt_dev->min_pkt_size == 0) { in pktgen_setup_inject()
2235 pkt_dev->min_pkt_size = 14 + sizeof(struct iphdr) in pktgen_setup_inject()
2238 + pkt_dev->pkt_overhead; in pktgen_setup_inject()
2241 pkt_dev->saddr_min = 0; in pktgen_setup_inject()
2242 pkt_dev->saddr_max = 0; in pktgen_setup_inject()
2243 if (strlen(pkt_dev->src_min) == 0) { in pktgen_setup_inject()
2248 in_dev = __in_dev_get_rcu(pkt_dev->odev); in pktgen_setup_inject()
2252 ifa = rcu_dereference(in_dev->ifa_list); in pktgen_setup_inject()
2254 pkt_dev->saddr_min = ifa->ifa_address; in pktgen_setup_inject()
2255 pkt_dev->saddr_max = pkt_dev->saddr_min; in pktgen_setup_inject()
2260 pkt_dev->saddr_min = in_aton(pkt_dev->src_min); in pktgen_setup_inject()
2261 pkt_dev->saddr_max = in_aton(pkt_dev->src_max); in pktgen_setup_inject()
2264 pkt_dev->daddr_min = in_aton(pkt_dev->dst_min); in pktgen_setup_inject()
2265 pkt_dev->daddr_max = in_aton(pkt_dev->dst_max); in pktgen_setup_inject()
2268 pkt_dev->cur_pkt_size = pkt_dev->min_pkt_size; in pktgen_setup_inject()
2269 if (pkt_dev->min_pkt_size > pkt_dev->max_pkt_size) in pktgen_setup_inject()
2270 pkt_dev->max_pkt_size = pkt_dev->min_pkt_size; in pktgen_setup_inject()
2272 pkt_dev->cur_dst_mac_offset = 0; in pktgen_setup_inject()
2273 pkt_dev->cur_src_mac_offset = 0; in pktgen_setup_inject()
2274 pkt_dev->cur_saddr = pkt_dev->saddr_min; in pktgen_setup_inject()
2275 pkt_dev->cur_daddr = pkt_dev->daddr_min; in pktgen_setup_inject()
2276 pkt_dev->cur_udp_dst = pkt_dev->udp_dst_min; in pktgen_setup_inject()
2277 pkt_dev->cur_udp_src = pkt_dev->udp_src_min; in pktgen_setup_inject()
2278 pkt_dev->nflows = 0; in pktgen_setup_inject()
2310 } while (t.task && pkt_dev->running && !signal_pending(current)); in spin()
2315 pkt_dev->idle_acc += ktime_to_ns(ktime_sub(end_time, start_time)); in spin()
2317 pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay); in spin()
2323 pkt_dev->pkt_overhead = 0; in set_pkt_overhead()
2324 pkt_dev->pkt_overhead += pkt_dev->nr_labels*sizeof(u32); in set_pkt_overhead()
2325 pkt_dev->pkt_overhead += VLAN_TAG_SIZE(pkt_dev); in set_pkt_overhead()
2326 pkt_dev->pkt_overhead += SVLAN_TAG_SIZE(pkt_dev); in set_pkt_overhead()
2331 return !!(pkt_dev->flows[flow].flags & F_INIT); in f_seen()
2336 int flow = pkt_dev->curfl; in f_pick()
2338 if (pkt_dev->flags & F_FLOW_SEQ) { in f_pick()
2339 if (pkt_dev->flows[flow].count >= pkt_dev->lflow) { in f_pick()
2341 pkt_dev->flows[flow].count = 0; in f_pick()
2342 pkt_dev->flows[flow].flags = 0; in f_pick()
2343 pkt_dev->curfl += 1; in f_pick()
2344 if (pkt_dev->curfl >= pkt_dev->cflows) in f_pick()
2345 pkt_dev->curfl = 0; /*reset */ in f_pick()
2348 flow = get_random_u32_below(pkt_dev->cflows); in f_pick()
2349 pkt_dev->curfl = flow; in f_pick()
2351 if (pkt_dev->flows[flow].count > pkt_dev->lflow) { in f_pick()
2352 pkt_dev->flows[flow].count = 0; in f_pick()
2353 pkt_dev->flows[flow].flags = 0; in f_pick()
2357 return pkt_dev->curfl; in f_pick()
2368 struct xfrm_state *x = pkt_dev->flows[flow].x; in get_ipsec_sa()
2369 struct pktgen_net *pn = net_generic(dev_net(pkt_dev->odev), pg_net_id); in get_ipsec_sa()
2372 if (pkt_dev->spi) { in get_ipsec_sa()
2376 x = xfrm_state_lookup_byspi(pn->net, htonl(pkt_dev->spi), AF_INET); in get_ipsec_sa()
2379 x = xfrm_stateonly_find(pn->net, DUMMY_MARK, 0, in get_ipsec_sa()
2380 (xfrm_address_t *)&pkt_dev->cur_daddr, in get_ipsec_sa()
2381 (xfrm_address_t *)&pkt_dev->cur_saddr, in get_ipsec_sa()
2383 pkt_dev->ipsmode, in get_ipsec_sa()
2384 pkt_dev->ipsproto, 0); in get_ipsec_sa()
2387 pkt_dev->flows[flow].x = x; in get_ipsec_sa()
2389 pkt_dev->pkt_overhead += x->props.header_len; in get_ipsec_sa()
2398 if (pkt_dev->flags & F_QUEUE_MAP_CPU) in set_cur_queue_map()
2399 pkt_dev->cur_queue_map = smp_processor_id(); in set_cur_queue_map()
2401 else if (pkt_dev->queue_map_min <= pkt_dev->queue_map_max) { in set_cur_queue_map()
2403 if (pkt_dev->flags & F_QUEUE_MAP_RND) { in set_cur_queue_map()
2404 t = get_random_u32_inclusive(pkt_dev->queue_map_min, in set_cur_queue_map()
2405 pkt_dev->queue_map_max); in set_cur_queue_map()
2407 t = pkt_dev->cur_queue_map + 1; in set_cur_queue_map()
2408 if (t > pkt_dev->queue_map_max) in set_cur_queue_map()
2409 t = pkt_dev->queue_map_min; in set_cur_queue_map()
2411 pkt_dev->cur_queue_map = t; in set_cur_queue_map()
2413 pkt_dev->cur_queue_map = pkt_dev->cur_queue_map % pkt_dev->odev->real_num_tx_queues; in set_cur_queue_map()
2417 * for IP src/dest, UDP src/dst port, MAC-Addr src/dst
2425 if (pkt_dev->cflows) in mod_cur_headers()
2429 if (pkt_dev->src_mac_count > 1) { in mod_cur_headers()
2433 if (pkt_dev->flags & F_MACSRC_RND) in mod_cur_headers()
2434 mc = get_random_u32_below(pkt_dev->src_mac_count); in mod_cur_headers()
2436 mc = pkt_dev->cur_src_mac_offset++; in mod_cur_headers()
2437 if (pkt_dev->cur_src_mac_offset >= in mod_cur_headers()
2438 pkt_dev->src_mac_count) in mod_cur_headers()
2439 pkt_dev->cur_src_mac_offset = 0; in mod_cur_headers()
2442 tmp = pkt_dev->src_mac[5] + (mc & 0xFF); in mod_cur_headers()
2443 pkt_dev->hh[11] = tmp; in mod_cur_headers()
2444 tmp = (pkt_dev->src_mac[4] + ((mc >> 8) & 0xFF) + (tmp >> 8)); in mod_cur_headers()
2445 pkt_dev->hh[10] = tmp; in mod_cur_headers()
2446 tmp = (pkt_dev->src_mac[3] + ((mc >> 16) & 0xFF) + (tmp >> 8)); in mod_cur_headers()
2447 pkt_dev->hh[9] = tmp; in mod_cur_headers()
2448 tmp = (pkt_dev->src_mac[2] + ((mc >> 24) & 0xFF) + (tmp >> 8)); in mod_cur_headers()
2449 pkt_dev->hh[8] = tmp; in mod_cur_headers()
2450 tmp = (pkt_dev->src_mac[1] + (tmp >> 8)); in mod_cur_headers()
2451 pkt_dev->hh[7] = tmp; in mod_cur_headers()
2455 if (pkt_dev->dst_mac_count > 1) { in mod_cur_headers()
2459 if (pkt_dev->flags & F_MACDST_RND) in mod_cur_headers()
2460 mc = get_random_u32_below(pkt_dev->dst_mac_count); in mod_cur_headers()
2463 mc = pkt_dev->cur_dst_mac_offset++; in mod_cur_headers()
2464 if (pkt_dev->cur_dst_mac_offset >= in mod_cur_headers()
2465 pkt_dev->dst_mac_count) { in mod_cur_headers()
2466 pkt_dev->cur_dst_mac_offset = 0; in mod_cur_headers()
2470 tmp = pkt_dev->dst_mac[5] + (mc & 0xFF); in mod_cur_headers()
2471 pkt_dev->hh[5] = tmp; in mod_cur_headers()
2472 tmp = (pkt_dev->dst_mac[4] + ((mc >> 8) & 0xFF) + (tmp >> 8)); in mod_cur_headers()
2473 pkt_dev->hh[4] = tmp; in mod_cur_headers()
2474 tmp = (pkt_dev->dst_mac[3] + ((mc >> 16) & 0xFF) + (tmp >> 8)); in mod_cur_headers()
2475 pkt_dev->hh[3] = tmp; in mod_cur_headers()
2476 tmp = (pkt_dev->dst_mac[2] + ((mc >> 24) & 0xFF) + (tmp >> 8)); in mod_cur_headers()
2477 pkt_dev->hh[2] = tmp; in mod_cur_headers()
2478 tmp = (pkt_dev->dst_mac[1] + (tmp >> 8)); in mod_cur_headers()
2479 pkt_dev->hh[1] = tmp; in mod_cur_headers()
2482 if (pkt_dev->flags & F_MPLS_RND) { in mod_cur_headers()
2484 for (i = 0; i < pkt_dev->nr_labels; i++) in mod_cur_headers()
2485 if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) in mod_cur_headers()
2486 pkt_dev->labels[i] = MPLS_STACK_BOTTOM | in mod_cur_headers()
2491 if ((pkt_dev->flags & F_VID_RND) && (pkt_dev->vlan_id != 0xffff)) { in mod_cur_headers()
2492 pkt_dev->vlan_id = get_random_u32_below(4096); in mod_cur_headers()
2495 if ((pkt_dev->flags & F_SVID_RND) && (pkt_dev->svlan_id != 0xffff)) { in mod_cur_headers()
2496 pkt_dev->svlan_id = get_random_u32_below(4096); in mod_cur_headers()
2499 if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) { in mod_cur_headers()
2500 if (pkt_dev->flags & F_UDPSRC_RND) in mod_cur_headers()
2501 pkt_dev->cur_udp_src = get_random_u32_inclusive(pkt_dev->udp_src_min, in mod_cur_headers()
2502 pkt_dev->udp_src_max - 1); in mod_cur_headers()
2505 pkt_dev->cur_udp_src++; in mod_cur_headers()
2506 if (pkt_dev->cur_udp_src >= pkt_dev->udp_src_max) in mod_cur_headers()
2507 pkt_dev->cur_udp_src = pkt_dev->udp_src_min; in mod_cur_headers()
2511 if (pkt_dev->udp_dst_min < pkt_dev->udp_dst_max) { in mod_cur_headers()
2512 if (pkt_dev->flags & F_UDPDST_RND) { in mod_cur_headers()
2513 pkt_dev->cur_udp_dst = get_random_u32_inclusive(pkt_dev->udp_dst_min, in mod_cur_headers()
2514 pkt_dev->udp_dst_max - 1); in mod_cur_headers()
2516 pkt_dev->cur_udp_dst++; in mod_cur_headers()
2517 if (pkt_dev->cur_udp_dst >= pkt_dev->udp_dst_max) in mod_cur_headers()
2518 pkt_dev->cur_udp_dst = pkt_dev->udp_dst_min; in mod_cur_headers()
2522 if (!(pkt_dev->flags & F_IPV6)) { in mod_cur_headers()
2524 imn = ntohl(pkt_dev->saddr_min); in mod_cur_headers()
2525 imx = ntohl(pkt_dev->saddr_max); in mod_cur_headers()
2528 if (pkt_dev->flags & F_IPSRC_RND) in mod_cur_headers()
2529 t = get_random_u32_inclusive(imn, imx - 1); in mod_cur_headers()
2531 t = ntohl(pkt_dev->cur_saddr); in mod_cur_headers()
2537 pkt_dev->cur_saddr = htonl(t); in mod_cur_headers()
2540 if (pkt_dev->cflows && f_seen(pkt_dev, flow)) { in mod_cur_headers()
2541 pkt_dev->cur_daddr = pkt_dev->flows[flow].cur_daddr; in mod_cur_headers()
2543 imn = ntohl(pkt_dev->daddr_min); in mod_cur_headers()
2544 imx = ntohl(pkt_dev->daddr_max); in mod_cur_headers()
2548 if (pkt_dev->flags & F_IPDST_RND) { in mod_cur_headers()
2551 t = get_random_u32_inclusive(imn, imx - 1); in mod_cur_headers()
2558 pkt_dev->cur_daddr = s; in mod_cur_headers()
2560 t = ntohl(pkt_dev->cur_daddr); in mod_cur_headers()
2565 pkt_dev->cur_daddr = htonl(t); in mod_cur_headers()
2568 if (pkt_dev->cflows) { in mod_cur_headers()
2569 pkt_dev->flows[flow].flags |= F_INIT; in mod_cur_headers()
2570 pkt_dev->flows[flow].cur_daddr = in mod_cur_headers()
2571 pkt_dev->cur_daddr; in mod_cur_headers()
2573 if (pkt_dev->flags & F_IPSEC) in mod_cur_headers()
2576 pkt_dev->nflows++; in mod_cur_headers()
2581 if (!ipv6_addr_any(&pkt_dev->min_in6_daddr)) { in mod_cur_headers()
2587 pkt_dev->cur_in6_daddr.s6_addr32[i] = in mod_cur_headers()
2589 pkt_dev->min_in6_daddr.s6_addr32[i]) & in mod_cur_headers()
2590 pkt_dev->max_in6_daddr.s6_addr32[i]); in mod_cur_headers()
2595 if (pkt_dev->min_pkt_size < pkt_dev->max_pkt_size) { in mod_cur_headers()
2597 if (pkt_dev->flags & F_TXSIZE_RND) { in mod_cur_headers()
2598 t = get_random_u32_inclusive(pkt_dev->min_pkt_size, in mod_cur_headers()
2599 pkt_dev->max_pkt_size - 1); in mod_cur_headers()
2601 t = pkt_dev->cur_pkt_size + 1; in mod_cur_headers()
2602 if (t > pkt_dev->max_pkt_size) in mod_cur_headers()
2603 t = pkt_dev->min_pkt_size; in mod_cur_headers()
2605 pkt_dev->cur_pkt_size = t; in mod_cur_headers()
2606 } else if (pkt_dev->n_imix_entries > 0) { in mod_cur_headers()
2609 __u8 entry_index = pkt_dev->imix_distribution[t]; in mod_cur_headers()
2611 entry = &pkt_dev->imix_entries[entry_index]; in mod_cur_headers()
2612 entry->count_so_far++; in mod_cur_headers()
2613 pkt_dev->cur_pkt_size = entry->size; in mod_cur_headers()
2618 pkt_dev->flows[flow].count++; in mod_cur_headers()
2629 for (i = 0; i < pkt_dev->n_imix_entries; i++) in fill_imix_distribution()
2630 total_weight += pkt_dev->imix_entries[i].weight; in fill_imix_distribution()
2633 for (i = 0; i < pkt_dev->n_imix_entries - 1; i++) { in fill_imix_distribution()
2634 cumulative_prob += div64_u64(pkt_dev->imix_entries[i].weight * in fill_imix_distribution()
2639 cumulative_probabilites[pkt_dev->n_imix_entries - 1] = 100; in fill_imix_distribution()
2644 pkt_dev->imix_distribution[i] = j; in fill_imix_distribution()
2656 struct xfrm_state *x = pkt_dev->flows[pkt_dev->curfl].x; in pktgen_output_ipsec()
2658 struct net *net = dev_net(pkt_dev->odev); in pktgen_output_ipsec()
2664 if ((x->props.mode != XFRM_MODE_TRANSPORT) && (pkt_dev->spi == 0)) in pktgen_output_ipsec()
2670 if ((x->props.mode == XFRM_MODE_TUNNEL) && (pkt_dev->spi != 0)) in pktgen_output_ipsec()
2671 skb->_skb_refdst = (unsigned long)&pkt_dev->xdst.u.dst | SKB_DST_NOREF; in pktgen_output_ipsec()
2680 err = x->type->output(x, skb); in pktgen_output_ipsec()
2685 spin_lock_bh(&x->lock); in pktgen_output_ipsec()
2686 x->curlft.bytes += skb->len; in pktgen_output_ipsec()
2687 x->curlft.packets++; in pktgen_output_ipsec()
2688 spin_unlock_bh(&x->lock); in pktgen_output_ipsec()
2695 if (pkt_dev->cflows) { in free_SAs()
2698 for (i = 0; i < pkt_dev->cflows; i++) { in free_SAs()
2699 struct xfrm_state *x = pkt_dev->flows[i].x; in free_SAs()
2702 pkt_dev->flows[i].x = NULL; in free_SAs()
2711 if (pkt_dev->flags & F_IPSEC) { in process_ipsec()
2712 struct xfrm_state *x = pkt_dev->flows[pkt_dev->curfl].x; in process_ipsec()
2719 nhead = x->props.header_len - skb_headroom(skb); in process_ipsec()
2738 memcpy(eth, pkt_dev->hh, 2 * ETH_ALEN); in process_ipsec()
2739 eth->h_proto = protocol; in process_ipsec()
2741 /* Update IPv4 header len as well as checksum value */ in process_ipsec()
2743 iph->tot_len = htons(skb->len - ETH_HLEN); in process_ipsec()
2757 for (i = 0; i < pkt_dev->nr_labels; i++) in mpls_push()
2758 *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM; in mpls_push()
2760 mpls--; in mpls_push()
2777 datalen -= sizeof(*pgh); in pktgen_finalize_skb()
2779 if (pkt_dev->nfrags <= 0) { in pktgen_finalize_skb()
2782 int frags = pkt_dev->nfrags; in pktgen_finalize_skb()
2783 int i, len; in pktgen_finalize_skb() local
2789 len = datalen - frags * PAGE_SIZE; in pktgen_finalize_skb()
2790 if (len > 0) { in pktgen_finalize_skb()
2791 skb_put_zero(skb, len); in pktgen_finalize_skb()
2799 if (unlikely(!pkt_dev->page)) { in pktgen_finalize_skb()
2802 if (pkt_dev->node >= 0 && (pkt_dev->flags & F_NODE)) in pktgen_finalize_skb()
2803 node = pkt_dev->node; in pktgen_finalize_skb()
2804 pkt_dev->page = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0); in pktgen_finalize_skb()
2805 if (!pkt_dev->page) in pktgen_finalize_skb()
2808 get_page(pkt_dev->page); in pktgen_finalize_skb()
2811 if (i == (frags - 1)) in pktgen_finalize_skb()
2812 skb_frag_fill_page_desc(&skb_shinfo(skb)->frags[i], in pktgen_finalize_skb()
2813 pkt_dev->page, 0, in pktgen_finalize_skb()
2817 skb_frag_fill_page_desc(&skb_shinfo(skb)->frags[i], in pktgen_finalize_skb()
2818 pkt_dev->page, 0, frag_len); in pktgen_finalize_skb()
2820 datalen -= skb_frag_size(&skb_shinfo(skb)->frags[i]); in pktgen_finalize_skb()
2821 skb->len += skb_frag_size(&skb_shinfo(skb)->frags[i]); in pktgen_finalize_skb()
2822 skb->data_len += skb_frag_size(&skb_shinfo(skb)->frags[i]); in pktgen_finalize_skb()
2824 skb_shinfo(skb)->nr_frags = i; in pktgen_finalize_skb()
2831 pgh->pgh_magic = htonl(PKTGEN_MAGIC); in pktgen_finalize_skb()
2832 pgh->seq_num = htonl(pkt_dev->seq_num); in pktgen_finalize_skb()
2834 if (pkt_dev->flags & F_NO_TIMESTAMP) { in pktgen_finalize_skb()
2835 pgh->tv_sec = 0; in pktgen_finalize_skb()
2836 pgh->tv_usec = 0; in pktgen_finalize_skb()
2839 * pgh->tv_sec wraps in y2106 when interpreted as unsigned in pktgen_finalize_skb()
2842 * it, we could introduce a variant that puts 64-bit nanoseconds in pktgen_finalize_skb()
2847 pgh->tv_sec = htonl(timestamp.tv_sec); in pktgen_finalize_skb()
2848 pgh->tv_usec = htonl(timestamp.tv_nsec / NSEC_PER_USEC); in pktgen_finalize_skb()
2859 size = pkt_dev->cur_pkt_size + 64 + extralen + pkt_dev->pkt_overhead; in pktgen_alloc_skb()
2860 if (pkt_dev->flags & F_NODE) { in pktgen_alloc_skb()
2861 int node = pkt_dev->node >= 0 ? pkt_dev->node : numa_node_id(); in pktgen_alloc_skb()
2866 skb->dev = dev; in pktgen_alloc_skb()
2872 /* the caller pre-fetches from skb->data and reserves for the mac hdr */ in pktgen_alloc_skb()
2874 skb_reserve(skb, extralen - 16); in pktgen_alloc_skb()
2890 __be16 *vlan_encapsulated_proto = NULL; /* packet type ID field (or len) for VLAN tag */ in fill_packet_ipv4()
2892 __be16 *svlan_encapsulated_proto = NULL; /* packet type ID field (or len) for SVLAN tag */ in fill_packet_ipv4()
2895 if (pkt_dev->nr_labels) in fill_packet_ipv4()
2898 if (pkt_dev->vlan_id != 0xffff) in fill_packet_ipv4()
2905 queue_map = pkt_dev->cur_queue_map; in fill_packet_ipv4()
2909 sprintf(pkt_dev->result, "No memory"); in fill_packet_ipv4()
2913 prefetchw(skb->data); in fill_packet_ipv4()
2918 mpls = skb_put(skb, pkt_dev->nr_labels * sizeof(__u32)); in fill_packet_ipv4()
2919 if (pkt_dev->nr_labels) in fill_packet_ipv4()
2922 if (pkt_dev->vlan_id != 0xffff) { in fill_packet_ipv4()
2923 if (pkt_dev->svlan_id != 0xffff) { in fill_packet_ipv4()
2925 *svlan_tci = build_tci(pkt_dev->svlan_id, in fill_packet_ipv4()
2926 pkt_dev->svlan_cfi, in fill_packet_ipv4()
2927 pkt_dev->svlan_p); in fill_packet_ipv4()
2933 *vlan_tci = build_tci(pkt_dev->vlan_id, in fill_packet_ipv4()
2934 pkt_dev->vlan_cfi, in fill_packet_ipv4()
2935 pkt_dev->vlan_p); in fill_packet_ipv4()
2941 skb_set_network_header(skb, skb->len); in fill_packet_ipv4()
2944 skb_set_transport_header(skb, skb->len); in fill_packet_ipv4()
2947 skb->priority = pkt_dev->skb_priority; in fill_packet_ipv4()
2949 memcpy(eth, pkt_dev->hh, 12); in fill_packet_ipv4()
2953 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 - in fill_packet_ipv4()
2954 pkt_dev->pkt_overhead; in fill_packet_ipv4()
2958 udph->source = htons(pkt_dev->cur_udp_src); in fill_packet_ipv4()
2959 udph->dest = htons(pkt_dev->cur_udp_dst); in fill_packet_ipv4()
2960 udph->len = htons(datalen + 8); /* DATA + udphdr */ in fill_packet_ipv4()
2961 udph->check = 0; in fill_packet_ipv4()
2963 iph->ihl = 5; in fill_packet_ipv4()
2964 iph->version = 4; in fill_packet_ipv4()
2965 iph->ttl = 32; in fill_packet_ipv4()
2966 iph->tos = pkt_dev->tos; in fill_packet_ipv4()
2967 iph->protocol = IPPROTO_UDP; /* UDP */ in fill_packet_ipv4()
2968 iph->saddr = pkt_dev->cur_saddr; in fill_packet_ipv4()
2969 iph->daddr = pkt_dev->cur_daddr; in fill_packet_ipv4()
2970 iph->id = htons(pkt_dev->ip_id); in fill_packet_ipv4()
2971 pkt_dev->ip_id++; in fill_packet_ipv4()
2972 iph->frag_off = 0; in fill_packet_ipv4()
2974 iph->tot_len = htons(iplen); in fill_packet_ipv4()
2976 skb->protocol = protocol; in fill_packet_ipv4()
2977 skb->dev = odev; in fill_packet_ipv4()
2978 skb->pkt_type = PACKET_HOST; in fill_packet_ipv4()
2982 if (!(pkt_dev->flags & F_UDPCSUM)) { in fill_packet_ipv4()
2983 skb->ip_summed = CHECKSUM_NONE; in fill_packet_ipv4()
2984 } else if (odev->features & (NETIF_F_HW_CSUM | NETIF_F_IP_CSUM)) { in fill_packet_ipv4()
2985 skb->ip_summed = CHECKSUM_PARTIAL; in fill_packet_ipv4()
2986 skb->csum = 0; in fill_packet_ipv4()
2987 udp4_hwcsum(skb, iph->saddr, iph->daddr); in fill_packet_ipv4()
2991 /* add protocol-dependent pseudo-header */ in fill_packet_ipv4()
2992 udph->check = csum_tcpudp_magic(iph->saddr, iph->daddr, in fill_packet_ipv4()
2995 if (udph->check == 0) in fill_packet_ipv4()
2996 udph->check = CSUM_MANGLED_0; in fill_packet_ipv4()
3018 __be16 *vlan_encapsulated_proto = NULL; /* packet type ID field (or len) for VLAN tag */ in fill_packet_ipv6()
3020 __be16 *svlan_encapsulated_proto = NULL; /* packet type ID field (or len) for SVLAN tag */ in fill_packet_ipv6()
3023 if (pkt_dev->nr_labels) in fill_packet_ipv6()
3026 if (pkt_dev->vlan_id != 0xffff) in fill_packet_ipv6()
3033 queue_map = pkt_dev->cur_queue_map; in fill_packet_ipv6()
3037 sprintf(pkt_dev->result, "No memory"); in fill_packet_ipv6()
3041 prefetchw(skb->data); in fill_packet_ipv6()
3046 mpls = skb_put(skb, pkt_dev->nr_labels * sizeof(__u32)); in fill_packet_ipv6()
3047 if (pkt_dev->nr_labels) in fill_packet_ipv6()
3050 if (pkt_dev->vlan_id != 0xffff) { in fill_packet_ipv6()
3051 if (pkt_dev->svlan_id != 0xffff) { in fill_packet_ipv6()
3053 *svlan_tci = build_tci(pkt_dev->svlan_id, in fill_packet_ipv6()
3054 pkt_dev->svlan_cfi, in fill_packet_ipv6()
3055 pkt_dev->svlan_p); in fill_packet_ipv6()
3061 *vlan_tci = build_tci(pkt_dev->vlan_id, in fill_packet_ipv6()
3062 pkt_dev->vlan_cfi, in fill_packet_ipv6()
3063 pkt_dev->vlan_p); in fill_packet_ipv6()
3069 skb_set_network_header(skb, skb->len); in fill_packet_ipv6()
3072 skb_set_transport_header(skb, skb->len); in fill_packet_ipv6()
3075 skb->priority = pkt_dev->skb_priority; in fill_packet_ipv6()
3077 memcpy(eth, pkt_dev->hh, 12); in fill_packet_ipv6()
3081 datalen = pkt_dev->cur_pkt_size - 14 - in fill_packet_ipv6()
3082 sizeof(struct ipv6hdr) - sizeof(struct udphdr) - in fill_packet_ipv6()
3083 pkt_dev->pkt_overhead; in fill_packet_ipv6()
3091 udph->source = htons(pkt_dev->cur_udp_src); in fill_packet_ipv6()
3092 udph->dest = htons(pkt_dev->cur_udp_dst); in fill_packet_ipv6()
3093 udph->len = htons(udplen); in fill_packet_ipv6()
3094 udph->check = 0; in fill_packet_ipv6()
3098 if (pkt_dev->traffic_class) { in fill_packet_ipv6()
3100 *(__be32 *)iph |= htonl(0x60000000 | (pkt_dev->traffic_class << 20)); in fill_packet_ipv6()
3103 iph->hop_limit = 32; in fill_packet_ipv6()
3105 iph->payload_len = htons(udplen); in fill_packet_ipv6()
3106 iph->nexthdr = IPPROTO_UDP; in fill_packet_ipv6()
3108 iph->daddr = pkt_dev->cur_in6_daddr; in fill_packet_ipv6()
3109 iph->saddr = pkt_dev->cur_in6_saddr; in fill_packet_ipv6()
3111 skb->protocol = protocol; in fill_packet_ipv6()
3112 skb->dev = odev; in fill_packet_ipv6()
3113 skb->pkt_type = PACKET_HOST; in fill_packet_ipv6()
3117 if (!(pkt_dev->flags & F_UDPCSUM)) { in fill_packet_ipv6()
3118 skb->ip_summed = CHECKSUM_NONE; in fill_packet_ipv6()
3119 } else if (odev->features & (NETIF_F_HW_CSUM | NETIF_F_IPV6_CSUM)) { in fill_packet_ipv6()
3120 skb->ip_summed = CHECKSUM_PARTIAL; in fill_packet_ipv6()
3121 skb->csum_start = skb_transport_header(skb) - skb->head; in fill_packet_ipv6()
3122 skb->csum_offset = offsetof(struct udphdr, check); in fill_packet_ipv6()
3123 udph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, udplen, IPPROTO_UDP, 0); in fill_packet_ipv6()
3127 /* add protocol-dependent pseudo-header */ in fill_packet_ipv6()
3128 udph->check = csum_ipv6_magic(&iph->saddr, &iph->daddr, udplen, IPPROTO_UDP, csum); in fill_packet_ipv6()
3130 if (udph->check == 0) in fill_packet_ipv6()
3131 udph->check = CSUM_MANGLED_0; in fill_packet_ipv6()
3140 if (pkt_dev->flags & F_IPV6) in fill_packet()
3148 pkt_dev->seq_num = 1; in pktgen_clear_counters()
3149 pkt_dev->idle_acc = 0; in pktgen_clear_counters()
3150 pkt_dev->sofar = 0; in pktgen_clear_counters()
3151 pkt_dev->tx_bytes = 0; in pktgen_clear_counters()
3152 pkt_dev->errors = 0; in pktgen_clear_counters()
3165 list_for_each_entry_rcu(pkt_dev, &t->if_list, list) { in pktgen_run()
3172 if (pkt_dev->odev) { in pktgen_run()
3174 pkt_dev->skb = NULL; in pktgen_run()
3175 pkt_dev->started_at = pkt_dev->next_tx = ktime_get(); in pktgen_run()
3179 strcpy(pkt_dev->result, "Starting"); in pktgen_run()
3180 pkt_dev->running = 1; /* Cranke yeself! */ in pktgen_run()
3183 strcpy(pkt_dev->result, "Error starting"); in pktgen_run()
3187 t->control &= ~(T_STOP); in pktgen_run()
3196 list_for_each_entry(t, &pn->pktgen_threads, th_list) in pktgen_handle_all_threads()
3197 t->control |= (flags); in pktgen_handle_all_threads()
3214 list_for_each_entry_rcu(pkt_dev, &t->if_list, list) in thread_is_running()
3215 if (pkt_dev->running) { in thread_is_running()
3254 list_for_each_entry(t, &pn->pktgen_threads, th_list) { in pktgen_wait_all_threads_run()
3261 list_for_each_entry(t, &pn->pktgen_threads, th_list) in pktgen_wait_all_threads_run()
3262 t->control |= (T_STOP); in pktgen_wait_all_threads_run()
3275 /* Propagate thread->control */ in pktgen_run_all_threads()
3287 /* Propagate thread->control */ in pktgen_reset_all_threads()
3296 char *p = pkt_dev->result; in show_results()
3297 ktime_t elapsed = ktime_sub(pkt_dev->stopped_at, in show_results()
3298 pkt_dev->started_at); in show_results()
3299 ktime_t idle = ns_to_ktime(pkt_dev->idle_acc); in show_results()
3305 (unsigned long long)pkt_dev->sofar, in show_results()
3306 pkt_dev->cur_pkt_size, nr_frags); in show_results()
3308 pps = div64_u64(pkt_dev->sofar * NSEC_PER_SEC, in show_results()
3311 if (pkt_dev->n_imix_entries > 0) { in show_results()
3316 for (i = 0; i < pkt_dev->n_imix_entries; i++) { in show_results()
3317 entry = &pkt_dev->imix_entries[i]; in show_results()
3318 bps += entry->size * entry->count_so_far; in show_results()
3322 bps = pps * 8 * pkt_dev->cur_pkt_size; in show_results()
3331 (unsigned long long)pkt_dev->errors); in show_results()
3334 /* Set stopped-at timer, remove from running list, do counters & statistics */
3337 int nr_frags = pkt_dev->skb ? skb_shinfo(pkt_dev->skb)->nr_frags : -1; in pktgen_stop_device()
3339 if (!pkt_dev->running) { in pktgen_stop_device()
3341 pkt_dev->odevname); in pktgen_stop_device()
3342 return -EINVAL; in pktgen_stop_device()
3345 pkt_dev->running = 0; in pktgen_stop_device()
3346 kfree_skb(pkt_dev->skb); in pktgen_stop_device()
3347 pkt_dev->skb = NULL; in pktgen_stop_device()
3348 pkt_dev->stopped_at = ktime_get(); in pktgen_stop_device()
3360 list_for_each_entry_rcu(pkt_dev, &t->if_list, list) { in next_to_run()
3361 if (!pkt_dev->running) in next_to_run()
3365 else if (ktime_compare(pkt_dev->next_tx, best->next_tx) < 0) in next_to_run()
3381 list_for_each_entry_rcu(pkt_dev, &t->if_list, list) { in pktgen_stop()
3389 * one of our devices needs to be removed - find it
3399 list_for_each_safe(q, n, &t->if_list) { in pktgen_rem_one_if()
3402 if (!cur->removal_mark) in pktgen_rem_one_if()
3405 kfree_skb(cur->skb); in pktgen_rem_one_if()
3406 cur->skb = NULL; in pktgen_rem_one_if()
3423 list_for_each_safe(q, n, &t->if_list) { in pktgen_rem_all_ifs()
3426 kfree_skb(cur->skb); in pktgen_rem_all_ifs()
3427 cur->skb = NULL; in pktgen_rem_all_ifs()
3436 remove_proc_entry(t->tsk->comm, t->net->proc_dir); in pktgen_rem_thread()
3443 pkt_dev->idle_acc += ktime_to_ns(ktime_sub(ktime_get(), idle_start)); in pktgen_resched()
3450 while (refcount_read(&(pkt_dev->skb->users)) != 1) { in pktgen_wait_for_skb()
3459 pkt_dev->idle_acc += ktime_to_ns(ktime_sub(ktime_get(), idle_start)); in pktgen_wait_for_skb()
3464 bool skb_shared = !!(READ_ONCE(pkt_dev->flags) & F_SHARED); in pktgen_xmit()
3465 struct net_device *odev = pkt_dev->odev; in pktgen_xmit()
3467 unsigned int burst = 1; in pktgen_xmit() local
3473 * new values (if any) for 'burst' and 'clone_skb' will be skipped to in pktgen_xmit()
3478 burst = READ_ONCE(pkt_dev->burst); in pktgen_xmit()
3479 clone_skb = READ_ONCE(pkt_dev->clone_skb); in pktgen_xmit()
3488 /* This is max DELAY, this has special meaning of in pktgen_xmit()
3491 if (unlikely(pkt_dev->delay == ULLONG_MAX)) { in pktgen_xmit()
3492 pkt_dev->next_tx = ktime_add_ns(ktime_get(), ULONG_MAX); in pktgen_xmit()
3497 if (!pkt_dev->skb || (pkt_dev->last_ok && in pktgen_xmit()
3498 ++pkt_dev->clone_count >= clone_skb)) { in pktgen_xmit()
3500 kfree_skb(pkt_dev->skb); in pktgen_xmit()
3502 pkt_dev->skb = fill_packet(odev, pkt_dev); in pktgen_xmit()
3503 if (pkt_dev->skb == NULL) { in pktgen_xmit()
3506 pkt_dev->clone_count--; /* back out increment, OOM */ in pktgen_xmit()
3509 pkt_dev->last_pkt_size = pkt_dev->skb->len; in pktgen_xmit()
3510 pkt_dev->clone_count = 0; /* reset counter */ in pktgen_xmit()
3513 if (pkt_dev->delay && pkt_dev->last_ok) in pktgen_xmit()
3514 spin(pkt_dev, pkt_dev->next_tx); in pktgen_xmit()
3516 if (pkt_dev->xmit_mode == M_NETIF_RECEIVE) { in pktgen_xmit()
3517 skb = pkt_dev->skb; in pktgen_xmit()
3518 skb->protocol = eth_type_trans(skb, skb->dev); in pktgen_xmit()
3520 refcount_add(burst, &skb->users); in pktgen_xmit()
3525 pkt_dev->errors++; in pktgen_xmit()
3526 pkt_dev->sofar++; in pktgen_xmit()
3527 pkt_dev->seq_num++; in pktgen_xmit()
3529 pkt_dev->skb = NULL; in pktgen_xmit()
3532 if (refcount_read(&skb->users) != burst) { in pktgen_xmit()
3536 WARN_ON(refcount_sub_and_test(burst - 1, &skb->users)); in pktgen_xmit()
3546 } while (--burst > 0); in pktgen_xmit()
3548 } else if (pkt_dev->xmit_mode == M_QUEUE_XMIT) { in pktgen_xmit()
3551 refcount_inc(&pkt_dev->skb->users); in pktgen_xmit()
3553 ret = dev_queue_xmit(pkt_dev->skb); in pktgen_xmit()
3556 pkt_dev->skb = NULL; in pktgen_xmit()
3560 pkt_dev->sofar++; in pktgen_xmit()
3561 pkt_dev->seq_num++; in pktgen_xmit()
3562 pkt_dev->tx_bytes += pkt_dev->last_pkt_size; in pktgen_xmit()
3577 pkt_dev->errors++; in pktgen_xmit()
3579 pkt_dev->odevname, ret); in pktgen_xmit()
3585 txq = skb_get_tx_queue(odev, pkt_dev->skb); in pktgen_xmit()
3592 pkt_dev->last_ok = 0; in pktgen_xmit()
3596 refcount_add(burst, &pkt_dev->skb->users); in pktgen_xmit()
3599 ret = netdev_start_xmit(pkt_dev->skb, odev, txq, --burst > 0); in pktgen_xmit()
3602 pkt_dev->skb = NULL; in pktgen_xmit()
3606 pkt_dev->last_ok = 1; in pktgen_xmit()
3607 pkt_dev->sofar++; in pktgen_xmit()
3608 pkt_dev->seq_num++; in pktgen_xmit()
3609 pkt_dev->tx_bytes += pkt_dev->last_pkt_size; in pktgen_xmit()
3610 if (burst > 0 && !netif_xmit_frozen_or_drv_stopped(txq)) in pktgen_xmit()
3616 pkt_dev->errors++; in pktgen_xmit()
3620 pkt_dev->odevname, ret); in pktgen_xmit()
3621 pkt_dev->errors++; in pktgen_xmit()
3626 refcount_dec(&pkt_dev->skb->users); in pktgen_xmit()
3627 pkt_dev->last_ok = 0; in pktgen_xmit()
3629 if (unlikely(burst)) in pktgen_xmit()
3630 WARN_ON(refcount_sub_and_test(burst, &pkt_dev->skb->users)); in pktgen_xmit()
3637 /* If pkt_dev->count is zero, then run forever */ in pktgen_xmit()
3638 if ((pkt_dev->count != 0) && (pkt_dev->sofar >= pkt_dev->count)) { in pktgen_xmit()
3639 if (pkt_dev->skb) in pktgen_xmit()
3655 int cpu = t->cpu; in pktgen_thread_worker()
3659 init_waitqueue_head(&t->queue); in pktgen_thread_worker()
3660 complete(&t->start_done); in pktgen_thread_worker()
3669 if (unlikely(!pkt_dev && t->control == 0)) { in pktgen_thread_worker()
3670 if (t->net->pktgen_exiting) in pktgen_thread_worker()
3672 wait_event_freezable_timeout(t->queue, in pktgen_thread_worker()
3673 t->control != 0, HZ / 10); in pktgen_thread_worker()
3686 if (t->control & T_STOP) { in pktgen_thread_worker()
3688 t->control &= ~(T_STOP); in pktgen_thread_worker()
3691 if (t->control & T_RUN) { in pktgen_thread_worker()
3693 t->control &= ~(T_RUN); in pktgen_thread_worker()
3696 if (t->control & T_REMDEVALL) { in pktgen_thread_worker()
3698 t->control &= ~(T_REMDEVALL); in pktgen_thread_worker()
3701 if (t->control & T_REMDEV) { in pktgen_thread_worker()
3703 t->control &= ~(T_REMDEV); in pktgen_thread_worker()
3709 pr_debug("%s stopping all device\n", t->tsk->comm); in pktgen_thread_worker()
3712 pr_debug("%s removing all device\n", t->tsk->comm); in pktgen_thread_worker()
3715 pr_debug("%s removing thread\n", t->tsk->comm); in pktgen_thread_worker()
3725 size_t len = strlen(ifname); in pktgen_find_dev() local
3728 list_for_each_entry_rcu(p, &t->if_list, list) in pktgen_find_dev()
3729 if (strncmp(p->odevname, ifname, len) == 0) { in pktgen_find_dev()
3730 if (p->odevname[len]) { in pktgen_find_dev()
3731 if (exact || p->odevname[len] != '@') in pktgen_find_dev()
3760 if (pkt_dev->pg_thread) { in add_dev_to_thread()
3762 rv = -EBUSY; in add_dev_to_thread()
3766 pkt_dev->running = 0; in add_dev_to_thread()
3767 pkt_dev->pg_thread = t; in add_dev_to_thread()
3768 list_add_rcu(&pkt_dev->list, &t->if_list); in add_dev_to_thread()
3781 int node = cpu_to_node(t->cpu); in pktgen_add_device()
3785 pkt_dev = __pktgen_NN_threads(t->net, ifname, FIND); in pktgen_add_device()
3788 return -EBUSY; in pktgen_add_device()
3793 return -ENOMEM; in pktgen_add_device()
3795 strcpy(pkt_dev->odevname, ifname); in pktgen_add_device()
3796 pkt_dev->flows = vzalloc_node(array_size(MAX_CFLOWS, in pktgen_add_device()
3799 if (pkt_dev->flows == NULL) { in pktgen_add_device()
3801 return -ENOMEM; in pktgen_add_device()
3804 pkt_dev->removal_mark = 0; in pktgen_add_device()
3805 pkt_dev->nfrags = 0; in pktgen_add_device()
3806 pkt_dev->delay = pg_delay_d; in pktgen_add_device()
3807 pkt_dev->count = pg_count_d; in pktgen_add_device()
3808 pkt_dev->sofar = 0; in pktgen_add_device()
3809 pkt_dev->udp_src_min = 9; /* sink port */ in pktgen_add_device()
3810 pkt_dev->udp_src_max = 9; in pktgen_add_device()
3811 pkt_dev->udp_dst_min = 9; in pktgen_add_device()
3812 pkt_dev->udp_dst_max = 9; in pktgen_add_device()
3813 pkt_dev->vlan_p = 0; in pktgen_add_device()
3814 pkt_dev->vlan_cfi = 0; in pktgen_add_device()
3815 pkt_dev->vlan_id = 0xffff; in pktgen_add_device()
3816 pkt_dev->svlan_p = 0; in pktgen_add_device()
3817 pkt_dev->svlan_cfi = 0; in pktgen_add_device()
3818 pkt_dev->svlan_id = 0xffff; in pktgen_add_device()
3819 pkt_dev->burst = 1; in pktgen_add_device()
3820 pkt_dev->node = NUMA_NO_NODE; in pktgen_add_device()
3821 pkt_dev->flags = F_SHARED; /* SKB shared by default */ in pktgen_add_device()
3823 err = pktgen_setup_dev(t->net, pkt_dev, ifname); in pktgen_add_device()
3826 if (pkt_dev->odev->priv_flags & IFF_TX_SKB_SHARING) in pktgen_add_device()
3827 pkt_dev->clone_skb = pg_clone_skb_d; in pktgen_add_device()
3829 pkt_dev->entry = proc_create_data(ifname, 0600, t->net->proc_dir, in pktgen_add_device()
3831 if (!pkt_dev->entry) { in pktgen_add_device()
3834 err = -EINVAL; in pktgen_add_device()
3838 pkt_dev->ipsmode = XFRM_MODE_TRANSPORT; in pktgen_add_device()
3839 pkt_dev->ipsproto = IPPROTO_ESP; in pktgen_add_device()
3846 pkt_dev->dstops.family = AF_INET; in pktgen_add_device()
3847 pkt_dev->xdst.u.dst.dev = pkt_dev->odev; in pktgen_add_device()
3848 dst_init_metrics(&pkt_dev->xdst.u.dst, pktgen_dst_metrics, false); in pktgen_add_device()
3849 pkt_dev->xdst.child = &pkt_dev->xdst.u.dst; in pktgen_add_device()
3850 pkt_dev->xdst.u.dst.ops = &pkt_dev->dstops; in pktgen_add_device()
3855 netdev_put(pkt_dev->odev, &pkt_dev->dev_tracker); in pktgen_add_device()
3860 vfree(pkt_dev->flows); in pktgen_add_device()
3875 return -ENOMEM; in pktgen_create_thread()
3878 mutex_init(&t->if_lock); in pktgen_create_thread()
3879 t->cpu = cpu; in pktgen_create_thread()
3881 INIT_LIST_HEAD(&t->if_list); in pktgen_create_thread()
3883 list_add_tail(&t->th_list, &pn->pktgen_threads); in pktgen_create_thread()
3884 init_completion(&t->start_done); in pktgen_create_thread()
3891 pr_err("kthread_create_on_node() failed for cpu %d\n", t->cpu); in pktgen_create_thread()
3892 list_del(&t->th_list); in pktgen_create_thread()
3897 t->tsk = p; in pktgen_create_thread()
3899 pe = proc_create_data(t->tsk->comm, 0600, pn->proc_dir, in pktgen_create_thread()
3903 PG_PROC_DIR, t->tsk->comm); in pktgen_create_thread()
3905 list_del(&t->th_list); in pktgen_create_thread()
3907 return -EINVAL; in pktgen_create_thread()
3910 t->net = pn; in pktgen_create_thread()
3913 wait_for_completion(&t->start_done); in pktgen_create_thread()
3928 list_for_each_safe(q, n, &t->if_list) { in _rem_dev_from_if_list()
3931 list_del_rcu(&p->list); in _rem_dev_from_if_list()
3941 if (pkt_dev->running) { in pktgen_remove_device()
3946 /* Dis-associate from the interface */ in pktgen_remove_device()
3948 if (pkt_dev->odev) { in pktgen_remove_device()
3949 netdev_put(pkt_dev->odev, &pkt_dev->dev_tracker); in pktgen_remove_device()
3950 pkt_dev->odev = NULL; in pktgen_remove_device()
3956 proc_remove(pkt_dev->entry); in pktgen_remove_device()
3964 vfree(pkt_dev->flows); in pktgen_remove_device()
3965 if (pkt_dev->page) in pktgen_remove_device()
3966 put_page(pkt_dev->page); in pktgen_remove_device()
3977 pn->net = net; in pg_net_init()
3978 INIT_LIST_HEAD(&pn->pktgen_threads); in pg_net_init()
3979 pn->pktgen_exiting = false; in pg_net_init()
3980 pn->proc_dir = proc_mkdir(PG_PROC_DIR, pn->net->proc_net); in pg_net_init()
3981 if (!pn->proc_dir) { in pg_net_init()
3983 return -ENODEV; in pg_net_init()
3985 pe = proc_create(PGCTRL, 0600, pn->proc_dir, &pktgen_proc_ops); in pg_net_init()
3988 ret = -EINVAL; in pg_net_init()
4003 if (list_empty(&pn->pktgen_threads)) { in pg_net_init()
4005 ret = -ENODEV; in pg_net_init()
4012 remove_proc_entry(PGCTRL, pn->proc_dir); in pg_net_init()
4014 remove_proc_entry(PG_PROC_DIR, pn->net->proc_net); in pg_net_init()
4026 pn->pktgen_exiting = true; in pg_net_exit()
4029 list_splice_init(&pn->pktgen_threads, &list); in pg_net_exit()
4034 list_del(&t->th_list); in pg_net_exit()
4035 kthread_stop_put(t->tsk); in pg_net_exit()
4039 remove_proc_entry(PGCTRL, pn->proc_dir); in pg_net_exit()
4040 remove_proc_entry(PG_PROC_DIR, pn->net->proc_net); in pg_net_exit()