Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHEL-69070: [HLK-SANITY] Adding clang format to VirtIO folder #1195

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 104 additions & 1 deletion VirtIO/.clang-format
Original file line number Diff line number Diff line change
@@ -1 +1,104 @@
DisableFormat: true
---
BinPackArguments: true
BinPackParameters: true
AllowAllParametersOfDeclarationOnNextLine: true
AlignConsecutiveDeclarations: false
BreakConstructorInitializers: AfterColon
PointerAlignment: Right
IndentFunctionDeclarationAfterType: false
AlignAfterOpenBracket: Align
InsertBraces: true
AccessModifierOffset: -4
AlignConsecutiveAssignments: false
AlignEscapedNewlines: Left
AlignOperands: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentGotoLabels: false
IndentPPDirectives: None
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptForEachMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03

IndentWidth: 4
TabWidth: 4
UseTab: Never
ObjCBlockIndentWidth: 4
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
ColumnLimit: 100
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignTrailingComments: true
---
48 changes: 19 additions & 29 deletions VirtIO/VirtIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,38 @@ struct VirtIOBufferDescriptor {
ULONG length;
};

typedef int (*proc_virtqueue_add_buf)(
struct virtqueue *vq,
struct scatterlist sg[],
unsigned int out_num,
unsigned int in_num,
void *opaque,
void *va_indirect,
ULONGLONG phys_indirect);
typedef int (*proc_virtqueue_add_buf)(struct virtqueue *vq, struct scatterlist sg[],
unsigned int out_num, unsigned int in_num, void *opaque,
void *va_indirect, ULONGLONG phys_indirect);

typedef bool(*proc_virtqueue_kick_prepare)(struct virtqueue *vq);
typedef bool (*proc_virtqueue_kick_prepare)(struct virtqueue *vq);

typedef void(*proc_virtqueue_kick_always)(struct virtqueue *vq);
typedef void (*proc_virtqueue_kick_always)(struct virtqueue *vq);

typedef void * (*proc_virtqueue_get_buf)(struct virtqueue *vq, unsigned int *len);
typedef void *(*proc_virtqueue_get_buf)(struct virtqueue *vq, unsigned int *len);

typedef void(*proc_virtqueue_disable_cb)(struct virtqueue *vq);
typedef void (*proc_virtqueue_disable_cb)(struct virtqueue *vq);

typedef bool(*proc_virtqueue_enable_cb)(struct virtqueue *vq);
typedef bool (*proc_virtqueue_enable_cb)(struct virtqueue *vq);

typedef bool(*proc_virtqueue_enable_cb_delayed)(struct virtqueue *vq);
typedef bool (*proc_virtqueue_enable_cb_delayed)(struct virtqueue *vq);

typedef void * (*proc_virtqueue_detach_unused_buf)(struct virtqueue *vq);
typedef void *(*proc_virtqueue_detach_unused_buf)(struct virtqueue *vq);

typedef BOOLEAN(*proc_virtqueue_is_interrupt_enabled)(struct virtqueue *vq);
typedef BOOLEAN (*proc_virtqueue_is_interrupt_enabled)(struct virtqueue *vq);

typedef BOOLEAN(*proc_virtqueue_has_buf)(struct virtqueue *vq);
typedef BOOLEAN (*proc_virtqueue_has_buf)(struct virtqueue *vq);

typedef void(*proc_virtqueue_shutdown)(struct virtqueue *vq);
typedef void (*proc_virtqueue_shutdown)(struct virtqueue *vq);

/* Represents one virtqueue; only data pointed to by the vring structure is exposed to the host */
struct virtqueue {
VirtIODevice *vdev;
unsigned int index;
void (*notification_cb)(struct virtqueue *vq);
void *notification_addr;
void *avail_va;
void *used_va;
void *notification_addr;
void *avail_va;
void *used_va;
proc_virtqueue_add_buf add_buf;
proc_virtqueue_kick_prepare kick_prepare;
proc_virtqueue_kick_always kick_always;
Expand All @@ -60,14 +55,9 @@ struct virtqueue {
proc_virtqueue_shutdown shutdown;
};

static inline int virtqueue_add_buf(
struct virtqueue *vq,
struct scatterlist sg[],
unsigned int out_num,
unsigned int in_num,
void *opaque,
void *va_indirect,
ULONGLONG phys_indirect)
static inline int virtqueue_add_buf(struct virtqueue *vq, struct scatterlist sg[],
unsigned int out_num, unsigned int in_num, void *opaque,
void *va_indirect, ULONGLONG phys_indirect)
{
return vq->add_buf(vq, sg, out_num, in_num, opaque, va_indirect, phys_indirect);
}
Expand Down
71 changes: 25 additions & 46 deletions VirtIO/VirtIOPCICommon.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@

#include "virtio_pci_common.h"

NTSTATUS virtio_device_initialize(VirtIODevice *vdev,
const VirtIOSystemOps *pSystemOps,
PVOID DeviceContext,
bool msix_used)
NTSTATUS virtio_device_initialize(VirtIODevice *vdev, const VirtIOSystemOps *pSystemOps,
PVOID DeviceContext, bool msix_used)
{
NTSTATUS status;

Expand Down Expand Up @@ -76,8 +74,7 @@ NTSTATUS virtio_device_initialize(VirtIODevice *vdev,

void virtio_device_shutdown(VirtIODevice *vdev)
{
if (vdev->info &&
vdev->info != vdev->inline_info) {
if (vdev->info && vdev->info != vdev->inline_info) {
mem_free_nonpaged_block(vdev, vdev->info);
vdev->info = NULL;
}
Expand Down Expand Up @@ -143,29 +140,26 @@ NTSTATUS virtio_set_features(VirtIODevice *vdev, u64 features)
}

/* Read @count fields, @bytes each. */
static void virtio_cread_many(VirtIODevice *vdev,
unsigned int offset,
void *buf, size_t count, size_t bytes)
static void virtio_cread_many(VirtIODevice *vdev, unsigned int offset, void *buf, size_t count,
size_t bytes)
{
u32 old, gen = vdev->device->get_config_generation ?
vdev->device->get_config_generation(vdev) : 0;
u32 old,
gen = vdev->device->get_config_generation ? vdev->device->get_config_generation(vdev) : 0;
size_t i;

do {
old = gen;

for (i = 0; i < count; i++) {
vdev->device->get_config(vdev, (unsigned)(offset + bytes * i),
(char *)buf + i * bytes, (unsigned)bytes);
vdev->device->get_config(vdev, (unsigned)(offset + bytes * i), (char *)buf + i * bytes,
(unsigned)bytes);
}

gen = vdev->device->get_config_generation ?
vdev->device->get_config_generation(vdev) : 0;
gen = vdev->device->get_config_generation ? vdev->device->get_config_generation(vdev) : 0;
} while (gen != old);
}

void virtio_get_config(VirtIODevice *vdev, unsigned offset,
void *buf, unsigned len)
void virtio_get_config(VirtIODevice *vdev, unsigned offset, void *buf, unsigned len)
{
switch (len) {
case 1:
Expand All @@ -183,19 +177,17 @@ void virtio_get_config(VirtIODevice *vdev, unsigned offset,
}

/* Write @count fields, @bytes each. */
static void virtio_cwrite_many(VirtIODevice *vdev,
unsigned int offset,
void *buf, size_t count, size_t bytes)
static void virtio_cwrite_many(VirtIODevice *vdev, unsigned int offset, void *buf, size_t count,
size_t bytes)
{
size_t i;
for (i = 0; i < count; i++) {
vdev->device->set_config(vdev, (unsigned)(offset + bytes * i),
(char *)buf + i * bytes, (unsigned)bytes);
vdev->device->set_config(vdev, (unsigned)(offset + bytes * i), (char *)buf + i * bytes,
(unsigned)bytes);
}
}

void virtio_set_config(VirtIODevice *vdev, unsigned offset,
void *buf, unsigned len)
void virtio_set_config(VirtIODevice *vdev, unsigned offset, void *buf, unsigned len)
{
switch (len) {
case 1:
Expand All @@ -212,10 +204,8 @@ void virtio_set_config(VirtIODevice *vdev, unsigned offset,
}
}

NTSTATUS virtio_query_queue_allocation(VirtIODevice *vdev,
unsigned index,
unsigned short *pNumEntries,
unsigned long *pRingSize,
NTSTATUS virtio_query_queue_allocation(VirtIODevice *vdev, unsigned index,
unsigned short *pNumEntries, unsigned long *pRingSize,
unsigned long *pHeapSize)
{
return vdev->device->query_queue_alloc(vdev, index, pNumEntries, pRingSize, pHeapSize);
Expand All @@ -239,8 +229,7 @@ NTSTATUS virtio_reserve_queue_memory(VirtIODevice *vdev, unsigned nvqs)
return STATUS_SUCCESS;
}

static NTSTATUS vp_setup_vq(struct virtqueue **queue,
VirtIODevice *vdev, unsigned index,
static NTSTATUS vp_setup_vq(struct virtqueue **queue, VirtIODevice *vdev, unsigned index,
u16 msix_vec)
{
VirtIOQueueInfo *info = &vdev->info[index];
Expand All @@ -253,20 +242,13 @@ static NTSTATUS vp_setup_vq(struct virtqueue **queue,
return status;
}

NTSTATUS virtio_find_queue(VirtIODevice *vdev, unsigned index,
struct virtqueue **vq)
NTSTATUS virtio_find_queue(VirtIODevice *vdev, unsigned index, struct virtqueue **vq)
{
u16 msix_vec = vdev_get_msix_vector(vdev, index);
return vp_setup_vq(
vq,
vdev,
index,
msix_vec);
return vp_setup_vq(vq, vdev, index, msix_vec);
}

NTSTATUS virtio_find_queues(VirtIODevice *vdev,
unsigned nvqs,
struct virtqueue *vqs[])
NTSTATUS virtio_find_queues(VirtIODevice *vdev, unsigned nvqs, struct virtqueue *vqs[])
{
unsigned i;
NTSTATUS status;
Expand All @@ -292,11 +274,7 @@ NTSTATUS virtio_find_queues(VirtIODevice *vdev,
/* set up queue interrupts */
for (i = 0; i < nvqs; i++) {
msix_vec = vdev_get_msix_vector(vdev, i);
status = vp_setup_vq(
&vqs[i],
vdev,
i,
msix_vec);
status = vp_setup_vq(&vqs[i], vdev, i, msix_vec);
if (!NT_SUCCESS(status)) {
goto error_find;
}
Expand All @@ -322,8 +300,9 @@ void virtio_delete_queues(VirtIODevice *vdev)
struct virtqueue *vq;
unsigned i;

if (vdev->info == NULL)
if (vdev->info == NULL) {
return;
}

for (i = 0; i < vdev->maxQueues; i++) {
vq = vdev->info[i].vq;
Expand Down
Loading