Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist
typedef SG_BUFFER_LIST is removed and its uses are replaced by the use of struct scatterlist. Signed-off-by: Nicolas Palix <npalix@diku.dk> Cc: Bill Pemberton <wfp5p@virginia.edu> Cc: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Родитель
45dcfb3809
Коммит
b219b3f732
|
@ -773,7 +773,7 @@ VmbusChannelSendPacket(
|
||||||
VMPACKET_DESCRIPTOR desc;
|
VMPACKET_DESCRIPTOR desc;
|
||||||
u32 packetLen = sizeof(VMPACKET_DESCRIPTOR) + BufferLen;
|
u32 packetLen = sizeof(VMPACKET_DESCRIPTOR) + BufferLen;
|
||||||
u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
|
u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
|
||||||
SG_BUFFER_LIST bufferList[3];
|
struct scatterlist bufferList[3];
|
||||||
u64 alignedData=0;
|
u64 alignedData=0;
|
||||||
|
|
||||||
DPRINT_ENTER(VMBUS);
|
DPRINT_ENTER(VMBUS);
|
||||||
|
@ -790,14 +790,10 @@ VmbusChannelSendPacket(
|
||||||
desc.Length8 = (u16)(packetLenAligned >> 3);
|
desc.Length8 = (u16)(packetLenAligned >> 3);
|
||||||
desc.TransactionId = RequestId;
|
desc.TransactionId = RequestId;
|
||||||
|
|
||||||
bufferList[0].Data = &desc;
|
sg_init_table(bufferList,3);
|
||||||
bufferList[0].Length = sizeof(VMPACKET_DESCRIPTOR);
|
sg_set_buf(&bufferList[0], &desc, sizeof(VMPACKET_DESCRIPTOR));
|
||||||
|
sg_set_buf(&bufferList[1], Buffer, BufferLen);
|
||||||
bufferList[1].Data = Buffer;
|
sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
|
||||||
bufferList[1].Length = BufferLen;
|
|
||||||
|
|
||||||
bufferList[2].Data = &alignedData;
|
|
||||||
bufferList[2].Length = packetLenAligned - packetLen;
|
|
||||||
|
|
||||||
ret = RingBufferWrite(
|
ret = RingBufferWrite(
|
||||||
&Channel->Outbound,
|
&Channel->Outbound,
|
||||||
|
@ -841,7 +837,7 @@ VmbusChannelSendPacketPageBuffer(
|
||||||
u32 descSize;
|
u32 descSize;
|
||||||
u32 packetLen;
|
u32 packetLen;
|
||||||
u32 packetLenAligned;
|
u32 packetLenAligned;
|
||||||
SG_BUFFER_LIST bufferList[3];
|
struct scatterlist bufferList[3];
|
||||||
u64 alignedData=0;
|
u64 alignedData=0;
|
||||||
|
|
||||||
DPRINT_ENTER(VMBUS);
|
DPRINT_ENTER(VMBUS);
|
||||||
|
@ -872,14 +868,10 @@ VmbusChannelSendPacketPageBuffer(
|
||||||
desc.Range[i].Pfn = PageBuffers[i].Pfn;
|
desc.Range[i].Pfn = PageBuffers[i].Pfn;
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferList[0].Data = &desc;
|
sg_init_table(bufferList,3);
|
||||||
bufferList[0].Length = descSize;
|
sg_set_buf(&bufferList[0], &desc, descSize);
|
||||||
|
sg_set_buf(&bufferList[1], Buffer, BufferLen);
|
||||||
bufferList[1].Data = Buffer;
|
sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
|
||||||
bufferList[1].Length = BufferLen;
|
|
||||||
|
|
||||||
bufferList[2].Data = &alignedData;
|
|
||||||
bufferList[2].Length = packetLenAligned - packetLen;
|
|
||||||
|
|
||||||
ret = RingBufferWrite(
|
ret = RingBufferWrite(
|
||||||
&Channel->Outbound,
|
&Channel->Outbound,
|
||||||
|
@ -922,7 +914,7 @@ VmbusChannelSendPacketMultiPageBuffer(
|
||||||
u32 descSize;
|
u32 descSize;
|
||||||
u32 packetLen;
|
u32 packetLen;
|
||||||
u32 packetLenAligned;
|
u32 packetLenAligned;
|
||||||
SG_BUFFER_LIST bufferList[3];
|
struct scatterlist bufferList[3];
|
||||||
u64 alignedData=0;
|
u64 alignedData=0;
|
||||||
u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset, MultiPageBuffer->Length);
|
u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset, MultiPageBuffer->Length);
|
||||||
|
|
||||||
|
@ -955,14 +947,10 @@ VmbusChannelSendPacketMultiPageBuffer(
|
||||||
|
|
||||||
memcpy(desc.Range.PfnArray, MultiPageBuffer->PfnArray, PfnCount*sizeof(u64));
|
memcpy(desc.Range.PfnArray, MultiPageBuffer->PfnArray, PfnCount*sizeof(u64));
|
||||||
|
|
||||||
bufferList[0].Data = &desc;
|
sg_init_table(bufferList,3);
|
||||||
bufferList[0].Length = descSize;
|
sg_set_buf(&bufferList[0], &desc, descSize);
|
||||||
|
sg_set_buf(&bufferList[1], Buffer, BufferLen);
|
||||||
bufferList[1].Data = Buffer;
|
sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
|
||||||
bufferList[1].Length = BufferLen;
|
|
||||||
|
|
||||||
bufferList[2].Data = &alignedData;
|
|
||||||
bufferList[2].Length = packetLenAligned - packetLen;
|
|
||||||
|
|
||||||
ret = RingBufferWrite(
|
ret = RingBufferWrite(
|
||||||
&Channel->Outbound,
|
&Channel->Outbound,
|
||||||
|
|
|
@ -347,9 +347,9 @@ Description:
|
||||||
--*/
|
--*/
|
||||||
static int
|
static int
|
||||||
RingBufferWrite(
|
RingBufferWrite(
|
||||||
RING_BUFFER_INFO* OutRingInfo,
|
RING_BUFFER_INFO *OutRingInfo,
|
||||||
SG_BUFFER_LIST SgBuffers[],
|
struct scatterlist *sglist,
|
||||||
u32 SgBufferCount
|
u32 sgcount
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
|
@ -357,15 +357,16 @@ RingBufferWrite(
|
||||||
u32 byteAvailToRead;
|
u32 byteAvailToRead;
|
||||||
u32 totalBytesToWrite=0;
|
u32 totalBytesToWrite=0;
|
||||||
|
|
||||||
|
struct scatterlist *sg;
|
||||||
volatile u32 nextWriteLocation;
|
volatile u32 nextWriteLocation;
|
||||||
u64 prevIndices=0;
|
u64 prevIndices=0;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
DPRINT_ENTER(VMBUS);
|
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);
|
totalBytesToWrite += sizeof(u64);
|
||||||
|
@ -394,21 +395,21 @@ RingBufferWrite(
|
||||||
/* Write to the ring buffer */
|
/* Write to the ring buffer */
|
||||||
nextWriteLocation = GetNextWriteLocation(OutRingInfo);
|
nextWriteLocation = GetNextWriteLocation(OutRingInfo);
|
||||||
|
|
||||||
for (i=0; i < SgBufferCount; i++)
|
for_each_sg(sglist, sg, sgcount, i)
|
||||||
{
|
{
|
||||||
nextWriteLocation = CopyToRingBuffer(OutRingInfo,
|
nextWriteLocation = CopyToRingBuffer(OutRingInfo,
|
||||||
nextWriteLocation,
|
nextWriteLocation,
|
||||||
SgBuffers[i].Data,
|
sg_virt(sg),
|
||||||
SgBuffers[i].Length);
|
sg->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set previous packet start */
|
/* Set previous packet start */
|
||||||
prevIndices = GetRingBufferIndices(OutRingInfo);
|
prevIndices = GetRingBufferIndices(OutRingInfo);
|
||||||
|
|
||||||
nextWriteLocation = CopyToRingBuffer(OutRingInfo,
|
nextWriteLocation = CopyToRingBuffer(OutRingInfo,
|
||||||
nextWriteLocation,
|
nextWriteLocation,
|
||||||
&prevIndices,
|
&prevIndices,
|
||||||
sizeof(u64));
|
sizeof(u64));
|
||||||
|
|
||||||
/* Make sure we flush all writes before updating the writeIndex */
|
/* Make sure we flush all writes before updating the writeIndex */
|
||||||
mb();
|
mb();
|
||||||
|
|
|
@ -25,12 +25,9 @@
|
||||||
#ifndef _RING_BUFFER_H_
|
#ifndef _RING_BUFFER_H_
|
||||||
#define _RING_BUFFER_H_
|
#define _RING_BUFFER_H_
|
||||||
|
|
||||||
#include "include/osd.h"
|
#include <linux/scatterlist.h>
|
||||||
|
|
||||||
typedef struct _SG_BUFFER_LIST {
|
#include "include/osd.h"
|
||||||
void * Data;
|
|
||||||
u32 Length;
|
|
||||||
} SG_BUFFER_LIST;
|
|
||||||
|
|
||||||
typedef struct _RING_BUFFER {
|
typedef struct _RING_BUFFER {
|
||||||
volatile u32 WriteIndex; /* Offset in bytes from the start of ring data below */
|
volatile u32 WriteIndex; /* Offset in bytes from the start of ring data below */
|
||||||
|
@ -83,9 +80,9 @@ RingBufferCleanup(
|
||||||
|
|
||||||
static int
|
static int
|
||||||
RingBufferWrite(
|
RingBufferWrite(
|
||||||
RING_BUFFER_INFO *RingInfo,
|
RING_BUFFER_INFO *RingInfo,
|
||||||
SG_BUFFER_LIST SgBuffers[],
|
struct scatterlist *sglist,
|
||||||
u32 SgBufferCount
|
u32 sgcount
|
||||||
);
|
);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Загрузка…
Ссылка в новой задаче