]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[tcpip] Allow for architecture-specific TCP/IP checksum routines
authorMichael Brown <mcb30@ipxe.org>
Wed, 27 Jun 2012 11:02:58 +0000 (12:02 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 27 Jun 2012 18:15:17 +0000 (19:15 +0100)
Calculating the TCP/IP checksum on received packets accounts for a
substantial fraction of the response latency.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/include/bits/tcpip.h [new file with mode: 0644]
src/include/ipxe/tcpip.h
src/net/tcpip.c

diff --git a/src/arch/x86/include/bits/tcpip.h b/src/arch/x86/include/bits/tcpip.h
new file mode 100644 (file)
index 0000000..9ae8d92
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _BITS_TCPIP_H
+#define _BITS_TCPIP_H
+
+/** @file
+ *
+ * Transport-network layer interface
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#endif /* _BITS_TCPIP_H */
index cdf554eae63063ad0f8b0fd8b0e422df16db3d08..34d7f88f4d62c566bec8d6b72070d9917e3fbc20 100644 (file)
@@ -13,6 +13,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <ipxe/socket.h>
 #include <ipxe/in.h>
 #include <ipxe/tables.h>
+#include <bits/tcpip.h>
 
 struct io_buffer;
 struct net_device;
@@ -121,8 +122,15 @@ extern int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip,
                      struct sockaddr_tcpip *st_dest,
                      struct net_device *netdev,
                      uint16_t *trans_csum );
-extern uint16_t tcpip_continue_chksum ( uint16_t partial,
-                                       const void *data, size_t len );
+extern uint16_t generic_tcpip_continue_chksum ( uint16_t partial,
+                                               const void *data, size_t len );
 extern uint16_t tcpip_chksum ( const void *data, size_t len );
 
+/* Use generic_tcpip_continue_chksum() if no architecture-specific
+ * version is available
+ */
+#ifndef tcpip_continue_chksum
+#define tcpip_continue_chksum generic_tcpip_continue_chksum
+#endif
+
 #endif /* _IPXE_TCPIP_H */
index 4451bf11126f909b729221ce109ea65b4b307738..8e187f7ecc7603865ecadfb3abdb81ba81409ef7 100644 (file)
@@ -97,8 +97,8 @@ int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip_protocol,
  * or both.  Deciding which to swap is left as an exercise for the
  * interested reader.
  */
-uint16_t tcpip_continue_chksum ( uint16_t partial, const void *data,
-                                size_t len ) {
+uint16_t generic_tcpip_continue_chksum ( uint16_t partial,
+                                        const void *data, size_t len ) {
        unsigned int cksum = ( ( ~partial ) & 0xffff );
        unsigned int value;
        unsigned int i;