---
name: "rte_gso_segment"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_gso.h"
---

# rte\_gso\_segment(3)

Part of [rte\_gso.h(3)](/rte_gso.h/3.md).

## NAME

rte\_gso.h

## SYNOPSIS

`#include <stdint.h>`\
 `#include <rte_mbuf.h>`\

### Data Structures

struct **rte\_gso\_ctx**\

### Macros

\#define **RTE\_GSO\_FLAG\_IPID\_FIXED**   (1ULL \<\< 0)\

### Functions

int **rte\_gso\_segment** (struct **rte\_mbuf** \*pkt, const struct **rte\_gso\_ctx** \*ctx, struct **rte\_mbuf** \*\*pkts\_out, uint16\_t nb\_pkts\_out)\

## Detailed Description

Interface to GSO library

Definition in file **rte\_gso.h**.

## Macro Definition Documentation

### #define RTE\_GSO\_FLAG\_IPID\_FIXED (1ULL \<\< 0)

Use fixed IP ids for output GSO segments. Setting 0 indicates using incremental IP ids.

Definition at line **32** of file **rte\_gso.h**.

## Function Documentation

### int rte\_gso\_segment (struct rte\_mbuf \* pkt, const struct rte\_gso\_ctx \* ctx, struct rte\_mbuf \*\* pkts\_out, uint16\_t nb\_pkts\_out)

Segmentation function, which supports processing of both single- and multi- MBUF packets.

Note that we refer to the packets that are segmented from the input packet as 'GSO segments'. **rte\_gso\_segment()** doesn't check if the input packet has correct checksums, and doesn't update checksums for output GSO segments. Additionally, it doesn't process IP fragment packets.

Before calling **rte\_gso\_segment()**, applications must set proper ol\_flags for the packet. The GSO library uses the same macros as that of TSO. For example, set RTE\_MBUF\_F\_TX\_TCP\_SEG and RTE\_MBUF\_F\_TX\_IPV4 in ol\_flags to segment a TCP/IPv4 packet. If **rte\_gso\_segment()** succeeds, the RTE\_MBUF\_F\_TX\_TCP\_SEG flag is removed for all GSO segments and the input packet.

Each of the newly-created GSO segments is organized as a two-segment MBUF, where the first segment is a standard MBUF, which stores a copy of packet header, and the second is an indirect MBUF which points to a section of data in the input packet. Since each GSO segment has multiple MBUFs (i.e. typically 2 MBUFs), the driver of the interface which the GSO segments are sent to should support transmission of multi-segment packets.

If the input packet is GSO'd, all the indirect segments are attached to the input packet.

**rte\_gso\_segment()** will not free the input packet no matter whether it is GSO'd or not, the application should free it after calling **rte\_gso\_segment()**.

If the memory space in pkts\_out or MBUF pools is insufficient, this function fails, and it returns (-1) \* errno. Otherwise, GSO succeeds, and this function returns the number of output GSO segments filled in pkts\_out.

**Parameters**

*pkt* The packet mbuf to segment. \
 *ctx* GSO context object pointer. \
 *pkts\_out* Pointer array used to store the MBUF addresses of output GSO segments, when **rte\_gso\_segment()** succeeds. \
 *nb\_pkts\_out* The max number of items that pkts\_out can keep.

**Returns**

- •

  The number of GSO segments filled in pkts\_out on success.

- •

  Return 0 if it does not need to be GSO'd.

- •

  Return -ENOMEM if run out of memory in MBUF pools.

- •

  Return -ENOTSUP for protocols that can not be segmented.

- •

  Return -EINVAL for invalid parameters.

## Author

Generated automatically by Doxygen for DPDK from the source code.
