-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hardware checksum offloading with partially computed TCP and UDP checksums #12
base: staging
Are you sure you want to change the base?
Changes from all commits
fe132cb
abcb328
8723313
f9e7d14
c4814cb
76a2e84
0a602a3
90fdbc8
7d33417
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,7 @@ static int liblwip_init(void) | |
const char __maybe_unused *strcfg; | ||
uint16_t __maybe_unused int16cfg; | ||
int is_first_nf; | ||
int ret; | ||
#if LWIP_IPV4 | ||
ip4_addr_t ip4; | ||
ip4_addr_t *ip4_arg; | ||
|
@@ -174,12 +175,25 @@ static int liblwip_init(void) | |
dev = uk_netdev_get(devid); | ||
if (!dev) | ||
continue; | ||
if (uk_netdev_state_get(dev) != UK_NETDEV_UNCONFIGURED) { | ||
if (uk_netdev_state_get(dev) != UK_NETDEV_UNCONFIGURED | ||
&& uk_netdev_state_get(dev) != UK_NETDEV_UNPROBED) { | ||
uk_pr_info("Skipping to add network device %u to lwIP: Not in unconfigured state\n", | ||
devid); | ||
continue; | ||
} | ||
|
||
if (uk_netdev_state_get(dev) == UK_NETDEV_UNPROBED) { | ||
ret = uk_netdev_probe(dev); | ||
if (ret < 0) { | ||
uk_pr_err("Failed to probe features of network device %u: %d; skipping device...\n", | ||
devid, ret); | ||
continue; | ||
} | ||
} | ||
|
||
/* Here, the device has to be in unconfigured state */ | ||
UK_ASSERT(uk_netdev_state_get(dev) == UK_NETDEV_UNCONFIGURED); | ||
|
||
uk_pr_info("Attach network device %u to lwIP...\n", | ||
devid); | ||
|
||
|
@@ -239,6 +253,80 @@ static int liblwip_init(void) | |
continue; | ||
} | ||
|
||
/* Print hardware address */ | ||
if (nf->hwaddr_len == 6) { | ||
uk_pr_info("%c%c%u: Hardware address: %02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8"\n", | ||
nf->name[0], nf->name[1], nf->num, | ||
nf->hwaddr[0], nf->hwaddr[1], nf->hwaddr[2], | ||
nf->hwaddr[3], nf->hwaddr[4], nf->hwaddr[5]); | ||
} | ||
|
||
#if LWIP_CHECKSUM_CTRL_PER_NETIF | ||
uk_pr_info("%c%c%u: Check checksums:", | ||
nf->name[0], nf->name[1], nf->num); | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_CHECK_IP) { | ||
uk_pr_info(" IP"); | ||
} | ||
Comment on lines
+267
to
+269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This macro looks okay, but, wouldn't it be better if there was another macro that included the print too? PRINT_IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_CHECK_IP, " IP");
PRINT_IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_CHECK_UDP, " UDP");
... It would save a lot of lines as this is repeated a lot below 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a lwip provided macro that I am using here. I find it counter-intuitive to add another macro on top for the printing. |
||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_CHECK_UDP) { | ||
uk_pr_info(" UDP"); | ||
#if LWIP_CHECKSUM_PARTIAL | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_PARTIAL_UDP) { | ||
uk_pr_info("[+partial]"); | ||
} | ||
Comment on lines
+273
to
+275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same suggestion as before/above. This is repeated a lot and I think would sit better inside a macro. Also, this can be a different define and it can be empty if partial checksumming is disabled: #if LWIP_CHECKSUM_PARTIAL
#define PRINT_PART_IF__NETIF_CHECKSUM_ENABLED(INTF, NETIF_CHECKSUM_FLAG, MSG) \
IF__NETIF_CHECKSUM_ENABLED(INTF, NETIF_CHECKSUM_FLAG) \
uk_pr_info(MSG)
#else
#define PRINT_PART_IF__NETIF_CHECKSUM_ENABLED(INTF, NETIF_CHECKSUM_FLAG, MSG) \
do { } while (0)
#endif /* LWIP_CHECKSUM_PARTIAL */ Something like this, to have fewer |
||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_SKIPVALID_UDP) { | ||
uk_pr_info("[+offloaded]"); | ||
} | ||
#endif /* LWIP_CHECKSUM_PARTIAL */ | ||
} | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_CHECK_TCP) { | ||
uk_pr_info(" TCP"); | ||
#if LWIP_CHECKSUM_PARTIAL | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_PARTIAL_TCP) { | ||
uk_pr_info("[+partial]"); | ||
} | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_SKIPVALID_TCP) { | ||
uk_pr_info("[+offloaded]"); | ||
} | ||
#endif /* LWIP_CHECKSUM_PARTIAL */ | ||
} | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_CHECK_ICMP) { | ||
uk_pr_info(" ICMP"); | ||
} | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_CHECK_ICMP6) { | ||
uk_pr_info(" ICMP6"); | ||
} | ||
uk_pr_info("\n"); | ||
|
||
uk_pr_info("%c%c%u: Generate checksums:", | ||
nf->name[0], nf->name[1], nf->num); | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_GEN_IP) { | ||
uk_pr_info(" IP"); | ||
} | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_GEN_UDP) { | ||
uk_pr_info(" UDP"); | ||
#if LWIP_CHECKSUM_PARTIAL | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_PARTIAL_UDP) { | ||
uk_pr_info("[partial]"); | ||
} | ||
#endif /* LWIP_CHECKSUM_PARTIAL */ | ||
} | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_GEN_TCP) { | ||
uk_pr_info(" TCP"); | ||
#if LWIP_CHECKSUM_PARTIAL | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_PARTIAL_TCP) { | ||
uk_pr_info("[partial]"); | ||
} | ||
#endif /* LWIP_CHECKSUM_PARTIAL */ | ||
} | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_GEN_ICMP) { | ||
uk_pr_info(" ICMP"); | ||
} | ||
IF__NETIF_CHECKSUM_ENABLED(nf, NETIF_CHECKSUM_GEN_ICMP6) { | ||
uk_pr_info(" ICMP6"); | ||
} | ||
uk_pr_info("\n"); | ||
#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */ | ||
|
||
/* Declare the first network device as default interface */ | ||
if (is_first_nf) { | ||
uk_pr_info("%c%c%u: Set as default interface\n", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checksummin gis
->checksumming is