mirror of https://github.com/ipxe/ipxe.git
[tcpip] Allow for architecture-specific TCP/IP checksum routines
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>pull/6/head^2
parent
6a4ff519c8
commit
1d77d03216
|
@ -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 */
|
|
@ -13,6 +13,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#include <ipxe/socket.h>
|
#include <ipxe/socket.h>
|
||||||
#include <ipxe/in.h>
|
#include <ipxe/in.h>
|
||||||
#include <ipxe/tables.h>
|
#include <ipxe/tables.h>
|
||||||
|
#include <bits/tcpip.h>
|
||||||
|
|
||||||
struct io_buffer;
|
struct io_buffer;
|
||||||
struct net_device;
|
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 sockaddr_tcpip *st_dest,
|
||||||
struct net_device *netdev,
|
struct net_device *netdev,
|
||||||
uint16_t *trans_csum );
|
uint16_t *trans_csum );
|
||||||
extern uint16_t tcpip_continue_chksum ( uint16_t partial,
|
extern uint16_t generic_tcpip_continue_chksum ( uint16_t partial,
|
||||||
const void *data, size_t len );
|
const void *data, size_t len );
|
||||||
extern uint16_t tcpip_chksum ( 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 */
|
#endif /* _IPXE_TCPIP_H */
|
||||||
|
|
|
@ -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
|
* or both. Deciding which to swap is left as an exercise for the
|
||||||
* interested reader.
|
* interested reader.
|
||||||
*/
|
*/
|
||||||
uint16_t tcpip_continue_chksum ( uint16_t partial, const void *data,
|
uint16_t generic_tcpip_continue_chksum ( uint16_t partial,
|
||||||
size_t len ) {
|
const void *data, size_t len ) {
|
||||||
unsigned int cksum = ( ( ~partial ) & 0xffff );
|
unsigned int cksum = ( ( ~partial ) & 0xffff );
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
Loading…
Reference in New Issue