Skip to content

Commit

Permalink
drivers/virtio: Add support for IPv4/TSO
Browse files Browse the repository at this point in the history
When the host indicates support for TSO, enable it and accept large
packets when the corresponding uknetbuf flag is set.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1088
  • Loading branch information
mschlumpp authored and razvand committed Oct 3, 2023
1 parent 381a90e commit c0fe2aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/uknetdev/include/uk/netbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down
8 changes: 7 additions & 1 deletion lib/uknetdev/include/uk/netdev_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit c0fe2aa

Please sign in to comment.