]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/uknetdev: Add interface for IPv4/TCP segmentation offload
authorMarco Schlumpp <marco@unikraft.io>
Wed, 8 Mar 2023 12:56:39 +0000 (13:56 +0100)
committerMichalis Pappas <michalis@unikraft.io>
Tue, 22 Aug 2023 09:04:44 +0000 (11:04 +0200)
This allows network device to advertise support for TSO on IPv4 and
clients to send large packets that are split by the hardware.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
lib/uknetdev/include/uk/netbuf.h
lib/uknetdev/include/uk/netdev_core.h

index 853952dc9510ac439547f34b348185207c08bf57..0306ad64500bbe52ca386adde3ccba05f0426408 100644 (file)
@@ -123,6 +123,12 @@ typedef void (*uk_netbuf_dtor_t)(struct uk_netbuf *);
 #define UK_NETBUF_F_PARTIAL_CSUM_BIT 1
 #define UK_NETBUF_F_PARTIAL_CSUM     (1 << UK_NETBUF_F_PARTIAL_CSUM_BIT)
 
+/* Indicates the packet should be sent with the help of TCP Segmentation
+ * Offloading. This requires that the device supports this.
+ */
+#define UK_NETBUF_F_GSO_TCPV4_BIT    2
+#define UK_NETBUF_F_GSO_TCPV4        (1 << UK_NETBUF_F_GSO_TCPV4_BIT)
+
 struct uk_netbuf {
        struct uk_netbuf *next;
        struct uk_netbuf *prev;
@@ -147,6 +153,14 @@ struct uk_netbuf {
                                 * pointing to the checksum field
                                 */
 
+       uint16_t header_len;   /**< Used if UK_NETBUF_F_GSO_* is set;
+                                * Number of bytes to copy into each split
+                                * packet as a header
+                                */
+       uint16_t gso_size;     /**< Used if UK_NETBUF_F_GSO_* is set;
+                                * Maximum size of each packet beyond the header
+                                */
+
        uk_netbuf_dtor_t dtor; /**< Destructor callback */
        struct uk_alloc *_a;   /**< @internal Allocator for free'ing */
        void *_b;              /**< @internal Base address for free'ing */
index b31e2e7805963bf3c3f14cb1879fa43a147b19d7..75022ec67a9faa556b5474ad819c0e370acfec54 100644 (file)
@@ -142,13 +142,19 @@ struct uk_hwaddr {
 #define UK_NETDEV_F_PARTIAL_CSUM_BIT   2
 #define UK_NETDEV_F_PARTIAL_CSUM       (1UL << UK_NETDEV_F_PARTIAL_CSUM_BIT)
 
+/* Indicates that the network device supports sending netbufs with the
+ * UK_NETBUF_F_GSO_TCPV4 bit set. */
+#define UK_NETDEV_F_TSO4_BIT           3
+#define UK_NETDEV_F_TSO4               (1UL << UK_NETDEV_F_TSO4_BIT)
+
 #define uk_netdev_rxintr_supported(feature)    \
        (feature & (UK_NETDEV_F_RXQ_INTR))
 #define uk_netdev_txintr_supported(feature)    \
        (feature & (UK_NETDEV_F_TXQ_INTR))
 #define uk_netdev_partial_csum_supported(feature)      \
        (feature & (UK_NETDEV_F_PARTIAL_CSUM))
-
+#define uk_netdev_tso4_supported(feature) \
+       (feature & (UK_NETDEV_F_TSO4))
 /**
  * A structure used to describe network device capabilities.
  */