net_pkt: Extend packet abstraction as required by e1000e functionality
[qemu.git] / hw / net / net_tx_pkt.c
1 /*
2 * QEMU TX packets abstractions
3 *
4 * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
5 *
6 * Developed by Daynix Computing LTD (http://www.daynix.com)
7 *
8 * Authors:
9 * Dmitry Fleytman <dmitry@daynix.com>
10 * Tamir Shomer <tamirs@daynix.com>
11 * Yan Vugenfirer <yan@daynix.com>
12 *
13 * This work is licensed under the terms of the GNU GPL, version 2 or later.
14 * See the COPYING file in the top-level directory.
15 *
16 */
17
18 #include "net_tx_pkt.h"
19 #include "net/eth.h"
20 #include "net/checksum.h"
21 #include "net/tap.h"
22 #include "net/net.h"
23
24 enum {
25 NET_TX_PKT_VHDR_FRAG = 0,
26 NET_TX_PKT_L2HDR_FRAG,
27 NET_TX_PKT_L3HDR_FRAG,
28 NET_TX_PKT_PL_START_FRAG
29 };
30
31 /* TX packet private context */
32 struct NetTxPkt {
33 struct virtio_net_hdr virt_hdr;
34 bool has_virt_hdr;
35
36 struct iovec *raw;
37 uint32_t raw_frags;
38 uint32_t max_raw_frags;
39
40 struct iovec *vec;
41
42 uint8_t l2_hdr[ETH_MAX_L2_HDR_LEN];
43 uint8_t l3_hdr[ETH_MAX_IP_DGRAM_LEN];
44
45 uint32_t payload_len;
46
47 uint32_t payload_frags;
48 uint32_t max_payload_frags;
49
50 uint16_t hdr_len;
51 eth_pkt_types_e packet_type;
52 uint8_t l4proto;
53
54 bool is_loopback;
55 };
56
57 void net_tx_pkt_init(struct NetTxPkt **pkt, uint32_t max_frags,
58 bool has_virt_hdr)
59 {
60 struct NetTxPkt *p = g_malloc0(sizeof *p);
61
62 p->vec = g_malloc((sizeof *p->vec) *
63 (max_frags + NET_TX_PKT_PL_START_FRAG));
64
65 p->raw = g_malloc((sizeof *p->raw) * max_frags);
66
67 p->max_payload_frags = max_frags;
68 p->max_raw_frags = max_frags;
69 p->has_virt_hdr = has_virt_hdr;
70 p->vec[NET_TX_PKT_VHDR_FRAG].iov_base = &p->virt_hdr;
71 p->vec[NET_TX_PKT_VHDR_FRAG].iov_len =
72 p->has_virt_hdr ? sizeof p->virt_hdr : 0;
73 p->vec[NET_TX_PKT_L2HDR_FRAG].iov_base = &p->l2_hdr;
74 p->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = &p->l3_hdr;
75
76 *pkt = p;
77 }
78
79 void net_tx_pkt_uninit(struct NetTxPkt *pkt)
80 {
81 if (pkt) {
82 g_free(pkt->vec);
83 g_free(pkt->raw);
84 g_free(pkt);
85 }
86 }
87
88 void net_tx_pkt_update_ip_hdr_checksum(struct NetTxPkt *pkt)
89 {
90 uint16_t csum;
91 assert(pkt);
92 struct ip_header *ip_hdr;
93 ip_hdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
94
95 ip_hdr->ip_len = cpu_to_be16(pkt->payload_len +
96 pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len);
97
98 ip_hdr->ip_sum = 0;
99 csum = net_raw_checksum((uint8_t *)ip_hdr,
100 pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len);
101 ip_hdr->ip_sum = cpu_to_be16(csum);
102 }
103
104 void net_tx_pkt_update_ip_checksums(struct NetTxPkt *pkt)
105 {
106 uint16_t csum;
107 uint32_t cntr, cso;
108 assert(pkt);
109 uint8_t gso_type = pkt->virt_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN;
110 void *ip_hdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
111
112 if (pkt->payload_len + pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len >
113 ETH_MAX_IP_DGRAM_LEN) {
114 return;
115 }
116
117 if (gso_type == VIRTIO_NET_HDR_GSO_TCPV4 ||
118 gso_type == VIRTIO_NET_HDR_GSO_UDP) {
119 /* Calculate IP header checksum */
120 net_tx_pkt_update_ip_hdr_checksum(pkt);
121
122 /* Calculate IP pseudo header checksum */
123 cntr = eth_calc_ip4_pseudo_hdr_csum(ip_hdr, pkt->payload_len, &cso);
124 csum = cpu_to_be16(~net_checksum_finish(cntr));
125 } else if (gso_type == VIRTIO_NET_HDR_GSO_TCPV6) {
126 /* Calculate IP pseudo header checksum */
127 cntr = eth_calc_ip6_pseudo_hdr_csum(ip_hdr, pkt->payload_len,
128 IP_PROTO_TCP, &cso);
129 csum = cpu_to_be16(~net_checksum_finish(cntr));
130 } else {
131 return;
132 }
133
134 iov_from_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags,
135 pkt->virt_hdr.csum_offset, &csum, sizeof(csum));
136 }
137
138 static void net_tx_pkt_calculate_hdr_len(struct NetTxPkt *pkt)
139 {
140 pkt->hdr_len = pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len +
141 pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len;
142 }
143
144 static bool net_tx_pkt_parse_headers(struct NetTxPkt *pkt)
145 {
146 struct iovec *l2_hdr, *l3_hdr;
147 size_t bytes_read;
148 size_t full_ip6hdr_len;
149 uint16_t l3_proto;
150
151 assert(pkt);
152
153 l2_hdr = &pkt->vec[NET_TX_PKT_L2HDR_FRAG];
154 l3_hdr = &pkt->vec[NET_TX_PKT_L3HDR_FRAG];
155
156 bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, 0, l2_hdr->iov_base,
157 ETH_MAX_L2_HDR_LEN);
158 if (bytes_read < sizeof(struct eth_header)) {
159 l2_hdr->iov_len = 0;
160 return false;
161 }
162
163 l2_hdr->iov_len = sizeof(struct eth_header);
164 switch (be16_to_cpu(PKT_GET_ETH_HDR(l2_hdr->iov_base)->h_proto)) {
165 case ETH_P_VLAN:
166 l2_hdr->iov_len += sizeof(struct vlan_header);
167 break;
168 case ETH_P_DVLAN:
169 l2_hdr->iov_len += 2 * sizeof(struct vlan_header);
170 break;
171 }
172
173 if (bytes_read < l2_hdr->iov_len) {
174 l2_hdr->iov_len = 0;
175 l3_hdr->iov_len = 0;
176 pkt->packet_type = ETH_PKT_UCAST;
177 return false;
178 } else {
179 l2_hdr->iov_len = ETH_MAX_L2_HDR_LEN;
180 l2_hdr->iov_len = eth_get_l2_hdr_length(l2_hdr->iov_base);
181 pkt->packet_type = get_eth_packet_type(l2_hdr->iov_base);
182 }
183
184 l3_proto = eth_get_l3_proto(l2_hdr, 1, l2_hdr->iov_len);
185
186 switch (l3_proto) {
187 case ETH_P_IP:
188 bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,
189 l3_hdr->iov_base, sizeof(struct ip_header));
190
191 if (bytes_read < sizeof(struct ip_header)) {
192 l3_hdr->iov_len = 0;
193 return false;
194 }
195
196 l3_hdr->iov_len = IP_HDR_GET_LEN(l3_hdr->iov_base);
197
198 if (l3_hdr->iov_len < sizeof(struct ip_header)) {
199 l3_hdr->iov_len = 0;
200 return false;
201 }
202
203 pkt->l4proto = ((struct ip_header *) l3_hdr->iov_base)->ip_p;
204
205 if (IP_HDR_GET_LEN(l3_hdr->iov_base) != sizeof(struct ip_header)) {
206 /* copy optional IPv4 header data if any*/
207 bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags,
208 l2_hdr->iov_len + sizeof(struct ip_header),
209 l3_hdr->iov_base + sizeof(struct ip_header),
210 l3_hdr->iov_len - sizeof(struct ip_header));
211 if (bytes_read < l3_hdr->iov_len - sizeof(struct ip_header)) {
212 l3_hdr->iov_len = 0;
213 return false;
214 }
215 }
216
217 break;
218
219 case ETH_P_IPV6:
220 {
221 eth_ip6_hdr_info hdrinfo;
222
223 if (!eth_parse_ipv6_hdr(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,
224 &hdrinfo)) {
225 l3_hdr->iov_len = 0;
226 return false;
227 }
228
229 pkt->l4proto = hdrinfo.l4proto;
230 full_ip6hdr_len = hdrinfo.full_hdr_len;
231
232 if (full_ip6hdr_len > ETH_MAX_IP_DGRAM_LEN) {
233 l3_hdr->iov_len = 0;
234 return false;
235 }
236
237 bytes_read = iov_to_buf(pkt->raw, pkt->raw_frags, l2_hdr->iov_len,
238 l3_hdr->iov_base, full_ip6hdr_len);
239
240 if (bytes_read < full_ip6hdr_len) {
241 l3_hdr->iov_len = 0;
242 return false;
243 } else {
244 l3_hdr->iov_len = full_ip6hdr_len;
245 }
246 break;
247 }
248 default:
249 l3_hdr->iov_len = 0;
250 break;
251 }
252
253 net_tx_pkt_calculate_hdr_len(pkt);
254 return true;
255 }
256
257 static void net_tx_pkt_rebuild_payload(struct NetTxPkt *pkt)
258 {
259 pkt->payload_len = iov_size(pkt->raw, pkt->raw_frags) - pkt->hdr_len;
260 pkt->payload_frags = iov_copy(&pkt->vec[NET_TX_PKT_PL_START_FRAG],
261 pkt->max_payload_frags,
262 pkt->raw, pkt->raw_frags,
263 pkt->hdr_len, pkt->payload_len);
264 }
265
266 bool net_tx_pkt_parse(struct NetTxPkt *pkt)
267 {
268 if (net_tx_pkt_parse_headers(pkt)) {
269 net_tx_pkt_rebuild_payload(pkt);
270 return true;
271 } else {
272 return false;
273 }
274 }
275
276 struct virtio_net_hdr *net_tx_pkt_get_vhdr(struct NetTxPkt *pkt)
277 {
278 assert(pkt);
279 return &pkt->virt_hdr;
280 }
281
282 static uint8_t net_tx_pkt_get_gso_type(struct NetTxPkt *pkt,
283 bool tso_enable)
284 {
285 uint8_t rc = VIRTIO_NET_HDR_GSO_NONE;
286 uint16_t l3_proto;
287
288 l3_proto = eth_get_l3_proto(&pkt->vec[NET_TX_PKT_L2HDR_FRAG], 1,
289 pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len);
290
291 if (!tso_enable) {
292 goto func_exit;
293 }
294
295 rc = eth_get_gso_type(l3_proto, pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base,
296 pkt->l4proto);
297
298 func_exit:
299 return rc;
300 }
301
302 void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable,
303 bool csum_enable, uint32_t gso_size)
304 {
305 struct tcp_hdr l4hdr;
306 assert(pkt);
307
308 /* csum has to be enabled if tso is. */
309 assert(csum_enable || !tso_enable);
310
311 pkt->virt_hdr.gso_type = net_tx_pkt_get_gso_type(pkt, tso_enable);
312
313 switch (pkt->virt_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
314 case VIRTIO_NET_HDR_GSO_NONE:
315 pkt->virt_hdr.hdr_len = 0;
316 pkt->virt_hdr.gso_size = 0;
317 break;
318
319 case VIRTIO_NET_HDR_GSO_UDP:
320 pkt->virt_hdr.gso_size = gso_size;
321 pkt->virt_hdr.hdr_len = pkt->hdr_len + sizeof(struct udp_header);
322 break;
323
324 case VIRTIO_NET_HDR_GSO_TCPV4:
325 case VIRTIO_NET_HDR_GSO_TCPV6:
326 iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags,
327 0, &l4hdr, sizeof(l4hdr));
328 pkt->virt_hdr.hdr_len = pkt->hdr_len + l4hdr.th_off * sizeof(uint32_t);
329 pkt->virt_hdr.gso_size = gso_size;
330 break;
331
332 default:
333 g_assert_not_reached();
334 }
335
336 if (csum_enable) {
337 switch (pkt->l4proto) {
338 case IP_PROTO_TCP:
339 pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
340 pkt->virt_hdr.csum_start = pkt->hdr_len;
341 pkt->virt_hdr.csum_offset = offsetof(struct tcp_hdr, th_sum);
342 break;
343 case IP_PROTO_UDP:
344 pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
345 pkt->virt_hdr.csum_start = pkt->hdr_len;
346 pkt->virt_hdr.csum_offset = offsetof(struct udp_hdr, uh_sum);
347 break;
348 default:
349 break;
350 }
351 }
352 }
353
354 void net_tx_pkt_setup_vlan_header_ex(struct NetTxPkt *pkt,
355 uint16_t vlan, uint16_t vlan_ethtype)
356 {
357 bool is_new;
358 assert(pkt);
359
360 eth_setup_vlan_headers_ex(pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_base,
361 vlan, vlan_ethtype, &is_new);
362
363 /* update l2hdrlen */
364 if (is_new) {
365 pkt->hdr_len += sizeof(struct vlan_header);
366 pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len +=
367 sizeof(struct vlan_header);
368 }
369 }
370
371 bool net_tx_pkt_add_raw_fragment(struct NetTxPkt *pkt, hwaddr pa,
372 size_t len)
373 {
374 hwaddr mapped_len = 0;
375 struct iovec *ventry;
376 assert(pkt);
377 assert(pkt->max_raw_frags > pkt->raw_frags);
378
379 if (!len) {
380 return true;
381 }
382
383 ventry = &pkt->raw[pkt->raw_frags];
384 mapped_len = len;
385
386 ventry->iov_base = cpu_physical_memory_map(pa, &mapped_len, false);
387
388 if ((ventry->iov_base != NULL) && (len == mapped_len)) {
389 ventry->iov_len = mapped_len;
390 pkt->raw_frags++;
391 return true;
392 } else {
393 return false;
394 }
395 }
396
397 bool net_tx_pkt_has_fragments(struct NetTxPkt *pkt)
398 {
399 return pkt->raw_frags > 0;
400 }
401
402 eth_pkt_types_e net_tx_pkt_get_packet_type(struct NetTxPkt *pkt)
403 {
404 assert(pkt);
405
406 return pkt->packet_type;
407 }
408
409 size_t net_tx_pkt_get_total_len(struct NetTxPkt *pkt)
410 {
411 assert(pkt);
412
413 return pkt->hdr_len + pkt->payload_len;
414 }
415
416 void net_tx_pkt_dump(struct NetTxPkt *pkt)
417 {
418 #ifdef NET_TX_PKT_DEBUG
419 assert(pkt);
420
421 printf("TX PKT: hdr_len: %d, pkt_type: 0x%X, l2hdr_len: %lu, "
422 "l3hdr_len: %lu, payload_len: %u\n", pkt->hdr_len, pkt->packet_type,
423 pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len,
424 pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len, pkt->payload_len);
425 #endif
426 }
427
428 void net_tx_pkt_reset(struct NetTxPkt *pkt)
429 {
430 int i;
431
432 /* no assert, as reset can be called before tx_pkt_init */
433 if (!pkt) {
434 return;
435 }
436
437 memset(&pkt->virt_hdr, 0, sizeof(pkt->virt_hdr));
438
439 assert(pkt->vec);
440
441 pkt->payload_len = 0;
442 pkt->payload_frags = 0;
443
444 assert(pkt->raw);
445 for (i = 0; i < pkt->raw_frags; i++) {
446 assert(pkt->raw[i].iov_base);
447 cpu_physical_memory_unmap(pkt->raw[i].iov_base, pkt->raw[i].iov_len,
448 false, pkt->raw[i].iov_len);
449 }
450 pkt->raw_frags = 0;
451
452 pkt->hdr_len = 0;
453 pkt->l4proto = 0;
454 }
455
456 static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt)
457 {
458 struct iovec *iov = &pkt->vec[NET_TX_PKT_L2HDR_FRAG];
459 uint32_t csum_cntr;
460 uint16_t csum = 0;
461 uint32_t cso;
462 /* num of iovec without vhdr */
463 uint32_t iov_len = pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1;
464 uint16_t csl;
465 struct ip_header *iphdr;
466 size_t csum_offset = pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_offset;
467
468 /* Put zero to checksum field */
469 iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);
470
471 /* Calculate L4 TCP/UDP checksum */
472 csl = pkt->payload_len;
473
474 /* add pseudo header to csum */
475 iphdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
476 csum_cntr = eth_calc_ip4_pseudo_hdr_csum(iphdr, csl, &cso);
477
478 /* data checksum */
479 csum_cntr +=
480 net_checksum_add_iov(iov, iov_len, pkt->virt_hdr.csum_start, csl, cso);
481
482 /* Put the checksum obtained into the packet */
483 csum = cpu_to_be16(net_checksum_finish(csum_cntr));
484 iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);
485 }
486
487 enum {
488 NET_TX_PKT_FRAGMENT_L2_HDR_POS = 0,
489 NET_TX_PKT_FRAGMENT_L3_HDR_POS,
490 NET_TX_PKT_FRAGMENT_HEADER_NUM
491 };
492
493 #define NET_MAX_FRAG_SG_LIST (64)
494
495 static size_t net_tx_pkt_fetch_fragment(struct NetTxPkt *pkt,
496 int *src_idx, size_t *src_offset, struct iovec *dst, int *dst_idx)
497 {
498 size_t fetched = 0;
499 struct iovec *src = pkt->vec;
500
501 *dst_idx = NET_TX_PKT_FRAGMENT_HEADER_NUM;
502
503 while (fetched < IP_FRAG_ALIGN_SIZE(pkt->virt_hdr.gso_size)) {
504
505 /* no more place in fragment iov */
506 if (*dst_idx == NET_MAX_FRAG_SG_LIST) {
507 break;
508 }
509
510 /* no more data in iovec */
511 if (*src_idx == (pkt->payload_frags + NET_TX_PKT_PL_START_FRAG)) {
512 break;
513 }
514
515
516 dst[*dst_idx].iov_base = src[*src_idx].iov_base + *src_offset;
517 dst[*dst_idx].iov_len = MIN(src[*src_idx].iov_len - *src_offset,
518 IP_FRAG_ALIGN_SIZE(pkt->virt_hdr.gso_size) - fetched);
519
520 *src_offset += dst[*dst_idx].iov_len;
521 fetched += dst[*dst_idx].iov_len;
522
523 if (*src_offset == src[*src_idx].iov_len) {
524 *src_offset = 0;
525 (*src_idx)++;
526 }
527
528 (*dst_idx)++;
529 }
530
531 return fetched;
532 }
533
534 static inline void net_tx_pkt_sendv(struct NetTxPkt *pkt,
535 NetClientState *nc, const struct iovec *iov, int iov_cnt)
536 {
537 if (pkt->is_loopback) {
538 nc->info->receive_iov(nc, iov, iov_cnt);
539 } else {
540 qemu_sendv_packet(nc, iov, iov_cnt);
541 }
542 }
543
544 static bool net_tx_pkt_do_sw_fragmentation(struct NetTxPkt *pkt,
545 NetClientState *nc)
546 {
547 struct iovec fragment[NET_MAX_FRAG_SG_LIST];
548 size_t fragment_len = 0;
549 bool more_frags = false;
550
551 /* some pointers for shorter code */
552 void *l2_iov_base, *l3_iov_base;
553 size_t l2_iov_len, l3_iov_len;
554 int src_idx = NET_TX_PKT_PL_START_FRAG, dst_idx;
555 size_t src_offset = 0;
556 size_t fragment_offset = 0;
557
558 l2_iov_base = pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_base;
559 l2_iov_len = pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len;
560 l3_iov_base = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
561 l3_iov_len = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len;
562
563 /* Copy headers */
564 fragment[NET_TX_PKT_FRAGMENT_L2_HDR_POS].iov_base = l2_iov_base;
565 fragment[NET_TX_PKT_FRAGMENT_L2_HDR_POS].iov_len = l2_iov_len;
566 fragment[NET_TX_PKT_FRAGMENT_L3_HDR_POS].iov_base = l3_iov_base;
567 fragment[NET_TX_PKT_FRAGMENT_L3_HDR_POS].iov_len = l3_iov_len;
568
569
570 /* Put as much data as possible and send */
571 do {
572 fragment_len = net_tx_pkt_fetch_fragment(pkt, &src_idx, &src_offset,
573 fragment, &dst_idx);
574
575 more_frags = (fragment_offset + fragment_len < pkt->payload_len);
576
577 eth_setup_ip4_fragmentation(l2_iov_base, l2_iov_len, l3_iov_base,
578 l3_iov_len, fragment_len, fragment_offset, more_frags);
579
580 eth_fix_ip4_checksum(l3_iov_base, l3_iov_len);
581
582 net_tx_pkt_sendv(pkt, nc, fragment, dst_idx);
583
584 fragment_offset += fragment_len;
585
586 } while (more_frags);
587
588 return true;
589 }
590
591 bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientState *nc)
592 {
593 assert(pkt);
594
595 if (!pkt->has_virt_hdr &&
596 pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
597 net_tx_pkt_do_sw_csum(pkt);
598 }
599
600 /*
601 * Since underlying infrastructure does not support IP datagrams longer
602 * than 64K we should drop such packets and don't even try to send
603 */
604 if (VIRTIO_NET_HDR_GSO_NONE != pkt->virt_hdr.gso_type) {
605 if (pkt->payload_len >
606 ETH_MAX_IP_DGRAM_LEN -
607 pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len) {
608 return false;
609 }
610 }
611
612 if (pkt->has_virt_hdr ||
613 pkt->virt_hdr.gso_type == VIRTIO_NET_HDR_GSO_NONE) {
614 net_tx_pkt_sendv(pkt, nc, pkt->vec,
615 pkt->payload_frags + NET_TX_PKT_PL_START_FRAG);
616 return true;
617 }
618
619 return net_tx_pkt_do_sw_fragmentation(pkt, nc);
620 }
621
622 bool net_tx_pkt_send_loopback(struct NetTxPkt *pkt, NetClientState *nc)
623 {
624 bool res;
625
626 pkt->is_loopback = true;
627 res = net_tx_pkt_send(pkt, nc);
628 pkt->is_loopback = false;
629
630 return res;
631 }