VMPACKET_DESCRIPTOR desc;
u32 packetLen = sizeof(VMPACKET_DESCRIPTOR) + BufferLen;
u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
- SG_BUFFER_LIST bufferList[3];
+ struct scatterlist bufferList[3];
u64 alignedData=0;
DPRINT_ENTER(VMBUS);
desc.Length8 = (u16)(packetLenAligned >> 3);
desc.TransactionId = RequestId;
- bufferList[0].Data = &desc;
- bufferList[0].Length = sizeof(VMPACKET_DESCRIPTOR);
-
- bufferList[1].Data = Buffer;
- bufferList[1].Length = BufferLen;
-
- bufferList[2].Data = &alignedData;
- bufferList[2].Length = packetLenAligned - packetLen;
+ sg_init_table(bufferList,3);
+ sg_set_buf(&bufferList[0], &desc, sizeof(VMPACKET_DESCRIPTOR));
+ sg_set_buf(&bufferList[1], Buffer, BufferLen);
+ sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
ret = RingBufferWrite(
&Channel->Outbound,
u32 descSize;
u32 packetLen;
u32 packetLenAligned;
- SG_BUFFER_LIST bufferList[3];
+ struct scatterlist bufferList[3];
u64 alignedData=0;
DPRINT_ENTER(VMBUS);
desc.Range[i].Pfn = PageBuffers[i].Pfn;
}
- bufferList[0].Data = &desc;
- bufferList[0].Length = descSize;
-
- bufferList[1].Data = Buffer;
- bufferList[1].Length = BufferLen;
-
- bufferList[2].Data = &alignedData;
- bufferList[2].Length = packetLenAligned - packetLen;
+ sg_init_table(bufferList,3);
+ sg_set_buf(&bufferList[0], &desc, descSize);
+ sg_set_buf(&bufferList[1], Buffer, BufferLen);
+ sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
ret = RingBufferWrite(
&Channel->Outbound,
u32 descSize;
u32 packetLen;
u32 packetLenAligned;
- SG_BUFFER_LIST bufferList[3];
+ struct scatterlist bufferList[3];
u64 alignedData=0;
u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset, MultiPageBuffer->Length);
memcpy(desc.Range.PfnArray, MultiPageBuffer->PfnArray, PfnCount*sizeof(u64));
- bufferList[0].Data = &desc;
- bufferList[0].Length = descSize;
-
- bufferList[1].Data = Buffer;
- bufferList[1].Length = BufferLen;
-
- bufferList[2].Data = &alignedData;
- bufferList[2].Length = packetLenAligned - packetLen;
+ sg_init_table(bufferList,3);
+ sg_set_buf(&bufferList[0], &desc, descSize);
+ sg_set_buf(&bufferList[1], Buffer, BufferLen);
+ sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
ret = RingBufferWrite(
&Channel->Outbound,
--*/
static int
RingBufferWrite(
- RING_BUFFER_INFO* OutRingInfo,
- SG_BUFFER_LIST SgBuffers[],
- u32 SgBufferCount
+ RING_BUFFER_INFO *OutRingInfo,
+ struct scatterlist *sglist,
+ u32 sgcount
)
{
int i=0;
u32 byteAvailToRead;
u32 totalBytesToWrite=0;
+ struct scatterlist *sg;
volatile u32 nextWriteLocation;
u64 prevIndices=0;
unsigned long flags;
DPRINT_ENTER(VMBUS);
- for (i=0; i < SgBufferCount; i++)
+ for_each_sg(sglist, sg, sgcount, i)
{
- totalBytesToWrite += SgBuffers[i].Length;
+ totalBytesToWrite += sg->length;
}
totalBytesToWrite += sizeof(u64);
/* Write to the ring buffer */
nextWriteLocation = GetNextWriteLocation(OutRingInfo);
- for (i=0; i < SgBufferCount; i++)
+ for_each_sg(sglist, sg, sgcount, i)
{
- nextWriteLocation = CopyToRingBuffer(OutRingInfo,
- nextWriteLocation,
- SgBuffers[i].Data,
- SgBuffers[i].Length);
+ nextWriteLocation = CopyToRingBuffer(OutRingInfo,
+ nextWriteLocation,
+ sg_virt(sg),
+ sg->length);
}
/* Set previous packet start */
prevIndices = GetRingBufferIndices(OutRingInfo);
nextWriteLocation = CopyToRingBuffer(OutRingInfo,
- nextWriteLocation,
- &prevIndices,
- sizeof(u64));
+ nextWriteLocation,
+ &prevIndices,
+ sizeof(u64));
/* Make sure we flush all writes before updating the writeIndex */
mb();
#ifndef _RING_BUFFER_H_
#define _RING_BUFFER_H_
-#include "include/osd.h"
+#include <linux/scatterlist.h>
-typedef struct _SG_BUFFER_LIST {
- void * Data;
- u32 Length;
-} SG_BUFFER_LIST;
+#include "include/osd.h"
typedef struct _RING_BUFFER {
volatile u32 WriteIndex; /* Offset in bytes from the start of ring data below */
static int
RingBufferWrite(
- RING_BUFFER_INFO *RingInfo,
- SG_BUFFER_LIST SgBuffers[],
- u32 SgBufferCount
+ RING_BUFFER_INFO *RingInfo,
+ struct scatterlist *sglist,
+ u32 sgcount
);
static int