summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--datapath-windows/automake.mk4
-rw-r--r--datapath-windows/ovsext/Actions.c6
-rw-r--r--datapath-windows/ovsext/BufferMgmt.c15
-rw-r--r--datapath-windows/ovsext/BufferMgmt.h16
-rw-r--r--datapath-windows/ovsext/Gre.c85
-rw-r--r--datapath-windows/ovsext/Offload.c (renamed from datapath-windows/ovsext/Checksum.c)115
-rw-r--r--datapath-windows/ovsext/Offload.h (renamed from datapath-windows/ovsext/Checksum.h)16
-rw-r--r--datapath-windows/ovsext/Stt.c24
-rw-r--r--datapath-windows/ovsext/User.c20
-rw-r--r--datapath-windows/ovsext/Vxlan.c98
-rw-r--r--datapath-windows/ovsext/ovsext.vcxproj4
11 files changed, 189 insertions, 214 deletions
diff --git a/datapath-windows/automake.mk b/datapath-windows/automake.mk
index fd2221850..f29f548a2 100644
--- a/datapath-windows/automake.mk
+++ b/datapath-windows/automake.mk
@@ -12,8 +12,6 @@ EXTRA_DIST += \
datapath-windows/ovsext/Atomic.h \
datapath-windows/ovsext/BufferMgmt.c \
datapath-windows/ovsext/BufferMgmt.h \
- datapath-windows/ovsext/Checksum.c \
- datapath-windows/ovsext/Checksum.h \
datapath-windows/ovsext/Datapath.c \
datapath-windows/ovsext/Datapath.h \
datapath-windows/ovsext/Debug.c \
@@ -39,6 +37,8 @@ EXTRA_DIST += \
datapath-windows/ovsext/Netlink/NetlinkBuf.h \
datapath-windows/ovsext/Netlink/NetlinkError.h \
datapath-windows/ovsext/Netlink/NetlinkProto.h \
+ datapath-windows/ovsext/Offload.c \
+ datapath-windows/ovsext/Offload.h \
datapath-windows/ovsext/Oid.c \
datapath-windows/ovsext/Oid.h \
datapath-windows/ovsext/PacketIO.c \
diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c
index 8e41b7455..5a045419d 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 VMware, Inc.
+ * Copyright (c) 2014, 2016 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,13 @@
#include "precomp.h"
-#include "Checksum.h"
+#include "Debug.h"
#include "Event.h"
#include "Flow.h"
#include "Gre.h"
#include "Mpls.h"
#include "NetProto.h"
+#include "Offload.h"
#include "PacketIO.h"
#include "Stt.h"
#include "Switch.h"
@@ -33,7 +34,6 @@
#undef OVS_DBG_MOD
#endif
#define OVS_DBG_MOD OVS_DBG_ACTION
-#include "Debug.h"
typedef struct _OVS_ACTION_STATS {
UINT64 rxGre;
diff --git a/datapath-windows/ovsext/BufferMgmt.c b/datapath-windows/ovsext/BufferMgmt.c
index 7ec073b70..3189e9b61 100644
--- a/datapath-windows/ovsext/BufferMgmt.c
+++ b/datapath-windows/ovsext/BufferMgmt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 VMware, Inc.
+ * Copyright (c) 2014, 2016 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,18 +77,19 @@
*/
#include "precomp.h"
+#include "Debug.h"
+#include "Flow.h"
+#include "Offload.h"
+#include "NetProto.h"
+#include "PacketParser.h"
#include "Switch.h"
+#include "Vport.h"
#ifdef OVS_DBG_MOD
#undef OVS_DBG_MOD
#endif
#define OVS_DBG_MOD OVS_DBG_BUFMGMT
-#include "Debug.h"
-#include "NetProto.h"
-#include "Flow.h"
-#include "Checksum.h"
-#include "PacketParser.h"
-#include "Vport.h"
+
/*
* --------------------------------------------------------------------------
diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath-windows/ovsext/BufferMgmt.h
index 79abc3d9d..11a05b2c5 100644
--- a/datapath-windows/ovsext/BufferMgmt.h
+++ b/datapath-windows/ovsext/BufferMgmt.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 VMware, Inc.
+ * Copyright (c) 2014, 2016 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,7 +63,6 @@ typedef union _OVS_BUFFER_CONTEXT {
UINT64 value[MEM_ALIGN_SIZE(16) >> 3];
} OVS_BUFFER_CONTEXT, *POVS_BUFFER_CONTEXT;
-
typedef struct _OVS_NBL_POOL {
NDIS_SWITCH_CONTEXT ndisContext;
NDIS_HANDLE ndisHandle;
@@ -83,11 +82,13 @@ typedef struct _OVS_NBL_POOL {
NDIS_STATUS OvsInitBufferPool(PVOID context);
+
VOID OvsCleanupBufferPool(PVOID context);
PNET_BUFFER_LIST OvsAllocateFixSizeNBL(PVOID context,
UINT32 size,
UINT32 headRoom);
+
PNET_BUFFER_LIST OvsAllocateVariableSizeNBL(PVOID context,
UINT32 size,
UINT32 headRoom);
@@ -106,20 +107,27 @@ PNET_BUFFER_LIST OvsPartialCopyToMultipleNBLs(PVOID context,
UINT32 copySize,
UINT32 headRoom,
BOOLEAN copyNblInfo);
+
PNET_BUFFER_LIST OvsFullCopyNBL(PVOID context, PNET_BUFFER_LIST nbl,
UINT32 headRoom, BOOLEAN copyNblInfo);
+
PNET_BUFFER_LIST OvsTcpSegmentNBL(PVOID context,
PNET_BUFFER_LIST nbl,
POVS_PACKET_HDR_INFO hdrInfo,
UINT32 MSS,
UINT32 headRoom);
+
PNET_BUFFER_LIST OvsAllocateNBLFromBuffer(PVOID context,
PVOID buffer,
ULONG length);
-PNET_BUFFER_LIST OvsFullCopyToMultipleNBLs(PVOID context,
- PNET_BUFFER_LIST nbl, UINT32 headRoom, BOOLEAN copyNblInfo);
+
+PNET_BUFFER_LIST OvsFullCopyToMultipleNBLs(PVOID context, PNET_BUFFER_LIST nbl,
+ UINT32 headRoom,
+ BOOLEAN copyNblInfo);
+
PNET_BUFFER_LIST OvsCompleteNBL(PVOID context, PNET_BUFFER_LIST nbl,
BOOLEAN updateRef);
+
NDIS_STATUS OvsSetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 portNo);
NDIS_STATUS OvsGetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 *portNo);
diff --git a/datapath-windows/ovsext/Gre.c b/datapath-windows/ovsext/Gre.c
index 5abd4a43e..cb4159379 100644
--- a/datapath-windows/ovsext/Gre.c
+++ b/datapath-windows/ovsext/Gre.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Cloudbase Solutions Srl
+ * Copyright (c) 2015, 2016 Cloudbase Solutions Srl
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,11 +17,12 @@
#include "precomp.h"
#include "Atomic.h"
-#include "Checksum.h"
+#include "Debug.h"
#include "Flow.h"
#include "Gre.h"
#include "IpHelper.h"
#include "NetProto.h"
+#include "Offload.h"
#include "PacketIO.h"
#include "PacketParser.h"
#include "Switch.h"
@@ -33,7 +34,6 @@
#undef OVS_DBG_MOD
#endif
#define OVS_DBG_MOD OVS_DBG_GRE
-#include "Debug.h"
static NDIS_STATUS
OvsDoEncapGre(POVS_VPORT_ENTRY vport, PNET_BUFFER_LIST curNbl,
@@ -147,21 +147,8 @@ OvsDoEncapGre(POVS_VPORT_ENTRY vport,
packetLength = NET_BUFFER_DATA_LENGTH(curNb);
if (layers->isTcp) {
- NDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO tsoInfo;
-
- tsoInfo.Value = NET_BUFFER_LIST_INFO(curNbl,
- TcpLargeSendNetBufferListInfo);
- switch (tsoInfo.Transmit.Type) {
- case NDIS_TCP_LARGE_SEND_OFFLOAD_V1_TYPE:
- mss = tsoInfo.LsoV1Transmit.MSS;
- break;
- case NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE:
- mss = tsoInfo.LsoV2Transmit.MSS;
- break;
- default:
- OVS_LOG_ERROR("Unknown LSO transmit type:%d",
- tsoInfo.Transmit.Type);
- }
+ mss = OVSGetTcpMSS(curNbl);
+
OVS_LOG_TRACE("MSS %u packet len %u", mss,
packetLength);
if (mss) {
@@ -188,71 +175,15 @@ OvsDoEncapGre(POVS_VPORT_ENTRY vport,
OVS_LOG_ERROR("Unable to copy NBL");
return NDIS_STATUS_FAILURE;
}
- /*
- * To this point we do not have GRE hardware offloading.
- * Apply defined checksums
- */
- curNb = NET_BUFFER_LIST_FIRST_NB(*newNbl);
- curMdl = NET_BUFFER_CURRENT_MDL(curNb);
- bufferStart = (PUINT8)MmGetSystemAddressForMdlSafe(curMdl,
- LowPagePriority);
- if (!bufferStart) {
- status = NDIS_STATUS_RESOURCES;
- goto ret_error;
- }
NDIS_TCP_IP_CHECKSUM_NET_BUFFER_LIST_INFO csumInfo;
csumInfo.Value = NET_BUFFER_LIST_INFO(curNbl,
TcpIpChecksumNetBufferListInfo);
- bufferStart += NET_BUFFER_CURRENT_MDL_OFFSET(curNb);
-
- if (layers->isIPv4) {
- IPHdr *ip = (IPHdr *)(bufferStart + layers->l3Offset);
-
- if (csumInfo.Transmit.IpHeaderChecksum) {
- ip->check = 0;
- ip->check = IPChecksum((UINT8 *)ip, 4 * ip->ihl, 0);
- }
-
- if (layers->isTcp && csumInfo.Transmit.TcpChecksum) {
- UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
- TCPHdr *tcp = (TCPHdr *)(bufferStart + layers->l4Offset);
- tcp->check = IPPseudoChecksum(&ip->saddr, &ip->daddr,
- IPPROTO_TCP, csumLength);
- tcp->check = CalculateChecksumNB(curNb, csumLength,
- (UINT32)(layers->l4Offset));
- } else if (layers->isUdp && csumInfo.Transmit.UdpChecksum) {
- UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
- UDPHdr *udp = (UDPHdr *)((PCHAR)ip + sizeof *ip);
- udp->check = IPPseudoChecksum(&ip->saddr, &ip->daddr,
- IPPROTO_UDP, csumLength);
- udp->check = CalculateChecksumNB(curNb, csumLength,
- (UINT32)(layers->l4Offset));
- }
- } else if (layers->isIPv6) {
- IPv6Hdr *ip = (IPv6Hdr *)(bufferStart + layers->l3Offset);
-
- if (layers->isTcp && csumInfo.Transmit.TcpChecksum) {
- UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
- TCPHdr *tcp = (TCPHdr *)(bufferStart + layers->l4Offset);
- tcp->check = IPv6PseudoChecksum((UINT32 *) &ip->saddr,
- (UINT32 *) &ip->daddr,
- IPPROTO_TCP, csumLength);
- tcp->check = CalculateChecksumNB(curNb, csumLength,
- (UINT32)(layers->l4Offset));
- } else if (layers->isUdp && csumInfo.Transmit.UdpChecksum) {
- UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
- UDPHdr *udp = (UDPHdr *)((PCHAR)ip + sizeof *ip);
- udp->check = IPv6PseudoChecksum((UINT32 *) &ip->saddr,
- (UINT32 *) &ip->daddr,
- IPPROTO_UDP, csumLength);
- udp->check = CalculateChecksumNB(curNb, csumLength,
- (UINT32)(layers->l4Offset));
- }
+ status = OvsApplySWChecksumOnNB(layers, *newNbl, &csumInfo);
+ if (status != NDIS_STATUS_SUCCESS) {
+ goto ret_error;
}
- /* Clear out TcpIpChecksumNetBufferListInfo flag */
- NET_BUFFER_LIST_INFO(*newNbl, TcpIpChecksumNetBufferListInfo) = 0;
}
curNbl = *newNbl;
diff --git a/datapath-windows/ovsext/Checksum.c b/datapath-windows/ovsext/Offload.c
index 5d9b035e2..1e43a9e71 100644
--- a/datapath-windows/ovsext/Checksum.c
+++ b/datapath-windows/ovsext/Offload.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 VMware, Inc.
+ * Copyright (c) 2014, 2016 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,15 +15,15 @@
*/
#include "precomp.h"
-#include "Checksum.h"
+#include "Debug.h"
#include "Flow.h"
+#include "Offload.h"
+#include "PacketParser.h"
#ifdef OVS_DBG_MOD
#undef OVS_DBG_MOD
#endif
#define OVS_DBG_MOD OVS_DBG_CHECKSUM
-#include "Debug.h"
-#include "PacketParser.h"
#ifndef htons
#define htons(_x) (((UINT16)(_x) >> 8) + (((UINT16)(_x) << 8) & 0xff00))
@@ -594,3 +594,110 @@ OvsValidateUDPChecksum(PNET_BUFFER_LIST curNbl, BOOLEAN udpCsumZero)
return NDIS_STATUS_SUCCESS;
}
+
+
+/*
+ * OvsApplySWChecksumOnNB --
+ *
+ * This function calculates and sets the required sofware offloads given by
+ * csumInfo for a given NBL(nbl) with a single NB.
+ *
+ */
+NDIS_STATUS
+OvsApplySWChecksumOnNB(POVS_PACKET_HDR_INFO layers,
+ PNET_BUFFER_LIST nbl,
+ PNDIS_TCP_IP_CHECKSUM_NET_BUFFER_LIST_INFO csumInfo)
+{
+ PNET_BUFFER curNb;
+ PMDL curMdl;
+ PUINT8 bufferStart;
+ UINT32 packetLength = 0;
+ ASSERT(nbl != NULL);
+
+ curNb = NET_BUFFER_LIST_FIRST_NB(nbl);
+ ASSERT(curNb->Next == NULL);
+ packetLength = NET_BUFFER_DATA_LENGTH(curNb);
+ curMdl = NET_BUFFER_CURRENT_MDL(curNb);
+ bufferStart = (PUINT8)MmGetSystemAddressForMdlSafe(curMdl,
+ LowPagePriority);
+ if (!bufferStart) {
+ return NDIS_STATUS_RESOURCES;
+ }
+
+ bufferStart += NET_BUFFER_CURRENT_MDL_OFFSET(curNb);
+
+ if (layers->isIPv4) {
+ IPHdr *ip = (IPHdr *)(bufferStart + layers->l3Offset);
+
+ if (csumInfo->Transmit.IpHeaderChecksum) {
+ ip->check = 0;
+ ip->check = IPChecksum((UINT8 *)ip, 4 * ip->ihl, 0);
+ }
+
+ if (layers->isTcp && csumInfo->Transmit.TcpChecksum) {
+ UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
+ TCPHdr *tcp = (TCPHdr *)(bufferStart + layers->l4Offset);
+ tcp->check = IPPseudoChecksum(&ip->saddr, &ip->daddr,
+ IPPROTO_TCP, csumLength);
+ tcp->check = CalculateChecksumNB(curNb, csumLength,
+ (UINT32)(layers->l4Offset));
+ } else if (layers->isUdp && csumInfo->Transmit.UdpChecksum) {
+ UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
+ UDPHdr *udp = (UDPHdr *)((PCHAR)ip + sizeof *ip);
+ udp->check = IPPseudoChecksum(&ip->saddr, &ip->daddr,
+ IPPROTO_UDP, csumLength);
+ udp->check = CalculateChecksumNB(curNb, csumLength,
+ (UINT32)(layers->l4Offset));
+ }
+ } else if (layers->isIPv6) {
+ IPv6Hdr *ip = (IPv6Hdr *)(bufferStart + layers->l3Offset);
+
+ if (layers->isTcp && csumInfo->Transmit.TcpChecksum) {
+ UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
+ TCPHdr *tcp = (TCPHdr *)(bufferStart + layers->l4Offset);
+ tcp->check = IPv6PseudoChecksum((UINT32 *) &ip->saddr,
+ (UINT32 *) &ip->daddr,
+ IPPROTO_TCP, csumLength);
+ tcp->check = CalculateChecksumNB(curNb, csumLength,
+ (UINT32)(layers->l4Offset));
+ } else if (layers->isUdp && csumInfo->Transmit.UdpChecksum) {
+ UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
+ UDPHdr *udp = (UDPHdr *)((PCHAR)ip + sizeof *ip);
+ udp->check = IPv6PseudoChecksum((UINT32 *) &ip->saddr,
+ (UINT32 *) &ip->daddr,
+ IPPROTO_UDP, csumLength);
+ udp->check = CalculateChecksumNB(curNb, csumLength,
+ (UINT32)(layers->l4Offset));
+ }
+ }
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+/*
+ * OVSGetTcpMSS --
+ *
+ * This function returns the maximum segment size of the given NBL. It takes
+ * into consideration both LSO v1 and v2.
+ */
+ULONG
+OVSGetTcpMSS(PNET_BUFFER_LIST nbl)
+{
+ NDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO lsoInfo;
+ ASSERT(nbl != NULL);
+
+ lsoInfo.Value = NET_BUFFER_LIST_INFO(nbl,
+ TcpLargeSendNetBufferListInfo);
+ switch (lsoInfo.Transmit.Type) {
+ case NDIS_TCP_LARGE_SEND_OFFLOAD_V1_TYPE:
+ return lsoInfo.LsoV1Transmit.MSS;
+ break;
+ case NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE:
+ return lsoInfo.LsoV2Transmit.MSS;
+ break;
+ default:
+ OVS_LOG_ERROR("Unknown LSO transmit type:%d",
+ lsoInfo.Transmit.Type);
+ return 0;
+ }
+}
diff --git a/datapath-windows/ovsext/Checksum.h b/datapath-windows/ovsext/Offload.h
index 2378a324a..b5cae2f2c 100644
--- a/datapath-windows/ovsext/Checksum.h
+++ b/datapath-windows/ovsext/Offload.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 VMware, Inc.
+ * Copyright (c) 2014, 2016 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef __CHECKSUM_H_
-#define __CHECKSUM_H_ 1
+#ifndef __OFFLOAD_H_
+#define __OFFLOAD_H_ 1
typedef union _OVS_PACKET_HDR_INFO *POVS_PACKET_HDR_INFO;
@@ -36,4 +36,12 @@ NDIS_STATUS OvsValidateIPChecksum(PNET_BUFFER_LIST curNbl,
NDIS_STATUS OvsValidateUDPChecksum(PNET_BUFFER_LIST curNbl,
BOOLEAN udpCsumZero);
-#endif /* __CHECKSUM_H_ */
+
+ULONG OVSGetTcpMSS(PNET_BUFFER_LIST nbl);
+
+NDIS_STATUS OvsApplySWChecksumOnNB(POVS_PACKET_HDR_INFO layers,
+ PNET_BUFFER_LIST nbl,
+ PNDIS_TCP_IP_CHECKSUM_NET_BUFFER_LIST_INFO
+ csumInfo);
+
+#endif /* __OFFLOAD_H_ */
diff --git a/datapath-windows/ovsext/Stt.c b/datapath-windows/ovsext/Stt.c
index 0ae263391..dd7bf9279 100644
--- a/datapath-windows/ovsext/Stt.c
+++ b/datapath-windows/ovsext/Stt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 VMware, Inc.
+ * Copyright (c) 2015, 2016 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,10 +17,12 @@
#include "precomp.h"
#include "Atomic.h"
-#include "Checksum.h"
+#include "Debug.h"
#include "Flow.h"
#include "IpHelper.h"
+#include "Jhash.h"
#include "NetProto.h"
+#include "Offload.h"
#include "PacketIO.h"
#include "PacketParser.h"
#include "Stt.h"
@@ -33,8 +35,7 @@
#undef OVS_DBG_MOD
#endif
#define OVS_DBG_MOD OVS_DBG_STT
-#include "Debug.h"
-#include "Jhash.h"
+
KSTART_ROUTINE OvsSttDefragCleaner;
static PLIST_ENTRY OvsSttPktFragHash;
@@ -163,20 +164,7 @@ OvsDoEncapStt(POVS_VPORT_ENTRY vport,
BOOLEAN innerPartialChecksum = FALSE;
if (layers->isTcp) {
- lsoInfo.Value = NET_BUFFER_LIST_INFO(curNbl,
- TcpLargeSendNetBufferListInfo);
-
- switch (lsoInfo.Transmit.Type) {
- case NDIS_TCP_LARGE_SEND_OFFLOAD_V1_TYPE:
- mss = lsoInfo.LsoV1Transmit.MSS;
- break;
- case NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE:
- mss = lsoInfo.LsoV2Transmit.MSS;
- break;
- default:
- OVS_LOG_ERROR("Unknown LSO transmit type:%d",
- lsoInfo.Transmit.Type);
- }
+ mss = OVSGetTcpMSS(curNbl);
}
vportStt = (POVS_STT_VPORT) GetOvsVportPriv(vport);
diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index 04d22949e..e97f2b2b6 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 VMware, Inc.
+ * Copyright (c) 2014, 2016 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,23 +22,23 @@
#include "precomp.h"
-#include "Switch.h"
-#include "Vport.h"
-#include "Event.h"
-#include "User.h"
#include "Datapath.h"
-#include "PacketIO.h"
-#include "Checksum.h"
-#include "NetProto.h"
+#include "Debug.h"
+#include "Event.h"
#include "Flow.h"
-#include "TunnelIntf.h"
#include "Jhash.h"
+#include "NetProto.h"
+#include "Offload.h"
+#include "PacketIO.h"
+#include "Switch.h"
+#include "TunnelIntf.h"
+#include "User.h"
+#include "Vport.h"
#ifdef OVS_DBG_MOD
#undef OVS_DBG_MOD
#endif
#define OVS_DBG_MOD OVS_DBG_USER
-#include "Debug.h"
POVS_PACKET_QUEUE_ELEM OvsGetNextPacket(POVS_OPEN_INSTANCE instance);
extern PNDIS_SPIN_LOCK gOvsCtrlLock;
diff --git a/datapath-windows/ovsext/Vxlan.c b/datapath-windows/ovsext/Vxlan.c
index 2516ece35..b89c03209 100644
--- a/datapath-windows/ovsext/Vxlan.c
+++ b/datapath-windows/ovsext/Vxlan.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 VMware, Inc.
+ * Copyright (c) 2014, 2016 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,20 @@
*/
#include "precomp.h"
+
#include "Atomic.h"
-#include "NetProto.h"
-#include "Switch.h"
-#include "Vport.h"
+#include "Debug.h"
+#include "Flow.h"
#include "Flow.h"
-#include "Vxlan.h"
#include "IpHelper.h"
-#include "Checksum.h"
-#include "User.h"
+#include "NetProto.h"
+#include "Offload.h"
#include "PacketIO.h"
-#include "Flow.h"
#include "PacketParser.h"
+#include "Switch.h"
+#include "User.h"
+#include "Vport.h"
+#include "Vxlan.h"
#pragma warning( push )
#pragma warning( disable:4127 )
@@ -36,7 +38,6 @@
#undef OVS_DBG_MOD
#endif
#define OVS_DBG_MOD OVS_DBG_VXLAN
-#include "Debug.h"
/* Helper macro to check if a VXLAN ID is valid. */
#define VXLAN_ID_IS_VALID(vxlanID) (0 < (vxlanID) && (vxlanID) <= 0xffffff)
@@ -201,21 +202,8 @@ OvsDoEncapVxlan(POVS_VPORT_ENTRY vport,
packetLength = NET_BUFFER_DATA_LENGTH(curNb);
if (layers->isTcp) {
- NDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO tsoInfo;
-
- tsoInfo.Value = NET_BUFFER_LIST_INFO(curNbl,
- TcpLargeSendNetBufferListInfo);
- switch (tsoInfo.Transmit.Type) {
- case NDIS_TCP_LARGE_SEND_OFFLOAD_V1_TYPE:
- mss = tsoInfo.LsoV1Transmit.MSS;
- break;
- case NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE:
- mss = tsoInfo.LsoV2Transmit.MSS;
- break;
- default:
- OVS_LOG_ERROR("Unknown LSO transmit type:%d",
- tsoInfo.Transmit.Type);
- }
+ mss = OVSGetTcpMSS(curNbl);
+
OVS_LOG_TRACE("MSS %u packet len %u", mss,
packetLength);
if (mss) {
@@ -242,70 +230,14 @@ OvsDoEncapVxlan(POVS_VPORT_ENTRY vport,
OVS_LOG_ERROR("Unable to copy NBL");
return NDIS_STATUS_FAILURE;
}
- /*
- * To this point we do not have VXLAN offloading.
- * Apply defined checksums
- */
- curNb = NET_BUFFER_LIST_FIRST_NB(*newNbl);
- curMdl = NET_BUFFER_CURRENT_MDL(curNb);
- bufferStart = (PUINT8)MmGetSystemAddressForMdlSafe(curMdl, LowPagePriority);
- if (!bufferStart) {
- status = NDIS_STATUS_RESOURCES;
- goto ret_error;
- }
-
NDIS_TCP_IP_CHECKSUM_NET_BUFFER_LIST_INFO csumInfo;
csumInfo.Value = NET_BUFFER_LIST_INFO(curNbl,
TcpIpChecksumNetBufferListInfo);
+ status = OvsApplySWChecksumOnNB(layers, *newNbl, &csumInfo);
- bufferStart += NET_BUFFER_CURRENT_MDL_OFFSET(curNb);
-
- if (layers->isIPv4) {
- IPHdr *ip = (IPHdr *)(bufferStart + layers->l3Offset);
-
- if (csumInfo.Transmit.IpHeaderChecksum) {
- ip->check = 0;
- ip->check = IPChecksum((UINT8 *)ip, 4 * ip->ihl, 0);
- }
-
- if (layers->isTcp && csumInfo.Transmit.TcpChecksum) {
- UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
- TCPHdr *tcp = (TCPHdr *)(bufferStart + layers->l4Offset);
- tcp->check = IPPseudoChecksum(&ip->saddr, &ip->daddr,
- IPPROTO_TCP, csumLength);
- tcp->check = CalculateChecksumNB(curNb, csumLength,
- (UINT32)(layers->l4Offset));
- } else if (layers->isUdp && csumInfo.Transmit.UdpChecksum) {
- UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
- UDPHdr *udp = (UDPHdr *)((PCHAR)ip + sizeof *ip);
- udp->check = IPPseudoChecksum(&ip->saddr, &ip->daddr,
- IPPROTO_UDP, csumLength);
- udp->check = CalculateChecksumNB(curNb, csumLength,
- (UINT32)(layers->l4Offset));
- }
- } else if (layers->isIPv6) {
- IPv6Hdr *ip = (IPv6Hdr *)(bufferStart + layers->l3Offset);
-
- if (layers->isTcp && csumInfo.Transmit.TcpChecksum) {
- UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
- TCPHdr *tcp = (TCPHdr *)(bufferStart + layers->l4Offset);
- tcp->check = IPv6PseudoChecksum((UINT32 *) &ip->saddr,
- (UINT32 *) &ip->daddr,
- IPPROTO_TCP, csumLength);
- tcp->check = CalculateChecksumNB(curNb, csumLength,
- (UINT32)(layers->l4Offset));
- } else if (layers->isUdp && csumInfo.Transmit.UdpChecksum) {
- UINT16 csumLength = (UINT16)(packetLength - layers->l4Offset);
- UDPHdr *udp = (UDPHdr *)((PCHAR)ip + sizeof *ip);
- udp->check = IPv6PseudoChecksum((UINT32 *) &ip->saddr,
- (UINT32 *) &ip->daddr,
- IPPROTO_UDP, csumLength);
- udp->check = CalculateChecksumNB(curNb, csumLength,
- (UINT32)(layers->l4Offset));
- }
+ if (status != NDIS_STATUS_SUCCESS) {
+ goto ret_error;
}
- /* Clear out TcpIpChecksumNetBufferListInfo flag */
- NET_BUFFER_LIST_INFO(*newNbl, TcpIpChecksumNetBufferListInfo) = 0;
}
curNbl = *newNbl;
diff --git a/datapath-windows/ovsext/ovsext.vcxproj b/datapath-windows/ovsext/ovsext.vcxproj
index fd10809dd..7b0ebcfaf 100644
--- a/datapath-windows/ovsext/ovsext.vcxproj
+++ b/datapath-windows/ovsext/ovsext.vcxproj
@@ -73,7 +73,6 @@
<ClInclude Include="..\include\OvsDpInterfaceExt.h" />
<ClInclude Include="Atomic.h" />
<ClInclude Include="BufferMgmt.h" />
- <ClInclude Include="Checksum.h" />
<ClInclude Include="Datapath.h" />
<ClInclude Include="Debug.h" />
<ClInclude Include="DpInternal.h" />
@@ -89,6 +88,7 @@
<ClInclude Include="Netlink/NetlinkProto.h" />
<ClInclude Include="Netlink\NetlinkError.h" />
<ClInclude Include="NetProto.h" />
+ <ClInclude Include="Offload.h" />
<ClInclude Include="Oid.h" />
<ClInclude Include="PacketIO.h" />
<ClInclude Include="PacketParser.h" />
@@ -169,7 +169,6 @@
<ItemGroup>
<ClCompile Include="Actions.c" />
<ClCompile Include="BufferMgmt.c" />
- <ClCompile Include="Checksum.c" />
<ClCompile Include="Debug.c" />
<ClCompile Include="Driver.c" />
<ClCompile Include="Event.c" />
@@ -180,6 +179,7 @@
<ClCompile Include="Netlink/Netlink.c" />
<ClCompile Include="Netlink/NetlinkBuf.c" />
<ClCompile Include="Datapath.c" />
+ <ClCompile Include="Offload.c" />
<ClCompile Include="Oid.c" />
<ClCompile Include="PacketIO.c" />
<ClCompile Include="PacketParser.c" />