* Re: [Xen-devel] PROBLEM: [BISECTED] 2.6.35.5 xen domU panics just after the boot
From: Jeremy Fitzhardinge @ 2010-09-24 18:00 UTC (permalink / raw)
To: Paweł Zuzelski
Cc: Jeremy Fitzhardinge, virtualization, xen-devel, lkml,
James Dingwall
In-Reply-To: <20100924054000.GA4689@pzz.touk.pl>
On 09/23/2010 10:40 PM, Paweł Zuzelski wrote:
> Have you seen the message from James Dingwall?
>
> He had found the typo in fb412a178502dc498430723b082a932f797e4763
> commit and sent the patch to lkml that fixes it.
>
> Please, see https://patchwork.kernel.org/patch/202282/ if you have
> not received James' mail. That patch resolves the problem for me and
> for James.
>
(!) Oh, well. Yes, that would explain it. I'd noticed the missing 'x',
but assumed I'd just done it with an editor fat-finger...
Looks like upstream is OK, so it crept in with the stable
cherry-pick/backport to both stable-2.6.32/master and stable-2.6.35/master.
J
^ permalink raw reply
* Re: [PATCH 1/1] Rename camel case variables in channel.c (updated again)
From: Joe Perches @ 2010-09-24 17:29 UTC (permalink / raw)
To: Haiyang Zhang
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de'
In-Reply-To: <1FB5E1D5CA062146B38059374562DF7289EDBC9E@TK5EX14MBXC130.redmond.corp.microsoft.com>
On Fri, 2010-09-24 at 16:06 +0000, Haiyang Zhang wrote:
> From: Haiyang Zhang <haiyangz@microsoft.com>
> - set_bit(Channel->MonitorBit,
> - (unsigned long *)&monitorPage->TriggerGroup
> - [Channel->MonitorGroup].Pending);
> + set_bit(channel->MonitorBit,
> + (unsigned long *)&monitorpage->TriggerGroup
> + [channel->MonitorGroup].Pending);
Unrelated to the camelcase conversion, this casting of
a (u32 *) to an (unsigned long *) to set a bit seems
like a bad idea and an error waiting to happen.
Does it really need to be atomic?
Perhaps it'd be better to write something like:
monitorpage->TriggerGroup[channel->MonitorGroup].Pending |=
(1 << channel->MonitorBit);
Maybe like the other 2 uses of set_bit in hv, it
should be set_bit(channel->MonitorBit & 31, ...
^ permalink raw reply
* RE: [PATCH 1/1] Rename camel case variables in channel.c (updated)
From: Haiyang Zhang @ 2010-09-24 16:08 UTC (permalink / raw)
To: Joe Perches
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de'
In-Reply-To: <1285281486.25928.31.camel@Joe-Laptop>
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Thursday, September 23, 2010 6:38 PM
> > + struct vmbus_channel_gpadl_header *gpal_header;
> > + struct vmbus_channel_gpadl_body *gpadl_body;
> > + struct vmbus_channel_msginfo *msgheader;
> > + struct vmbus_channel_msginfo *msgbody = NULL;
> > + u32 msgsize;
>
> Why gpal_header and not gpadl_header?
I have sent out an updated patch.
Thanks,
- Haiyang
^ permalink raw reply
* [PATCH 1/1] Rename camel case variables in channel.c (updated again)
From: Haiyang Zhang @ 2010-09-24 16:06 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
"'virtualization@lists.osdl.org'" <virtualiz>
In-Reply-To: <1FB5E1D5CA062146B38059374562DF7289ED89CF@TK5EX14MBXC130.redmond.corp.microsoft.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
Rename camel case variables in channel.c
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 767 +++++++++++++++++++++---------------------
1 files changed, 387 insertions(+), 380 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 37b7b4c..1037488 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -28,10 +28,10 @@
/* Internal routines */
static int VmbusChannelCreateGpadlHeader(
- void *Kbuffer, /* must be phys and virt contiguous */
- u32 Size, /* page-size multiple */
- struct vmbus_channel_msginfo **msgInfo,
- u32 *MessageCount);
+ void *kbuffer, /* must be phys and virt contiguous */
+ u32 size, /* page-size multiple */
+ struct vmbus_channel_msginfo **msginfo,
+ u32 *messagecount);
static void DumpVmbusChannel(struct vmbus_channel *channel);
static void VmbusChannelSetEvent(struct vmbus_channel *channel);
@@ -70,25 +70,25 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
* VmbusChannelSetEvent - Trigger an event notification on the specified
* channel.
*/
-static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
+static void VmbusChannelSetEvent(struct vmbus_channel *channel)
{
- struct hv_monitor_page *monitorPage;
+ struct hv_monitor_page *monitorpage;
- if (Channel->OfferMsg.MonitorAllocated) {
+ if (channel->OfferMsg.MonitorAllocated) {
/* Each u32 represents 32 channels */
- set_bit(Channel->OfferMsg.ChildRelId & 31,
+ set_bit(channel->OfferMsg.ChildRelId & 31,
(unsigned long *) gVmbusConnection.SendInterruptPage +
- (Channel->OfferMsg.ChildRelId >> 5));
+ (channel->OfferMsg.ChildRelId >> 5));
- monitorPage = gVmbusConnection.MonitorPages;
- monitorPage++; /* Get the child to parent monitor page */
+ monitorpage = gVmbusConnection.MonitorPages;
+ monitorpage++; /* Get the child to parent monitor page */
- set_bit(Channel->MonitorBit,
- (unsigned long *)&monitorPage->TriggerGroup
- [Channel->MonitorGroup].Pending);
+ set_bit(channel->MonitorBit,
+ (unsigned long *)&monitorpage->TriggerGroup
+ [channel->MonitorGroup].Pending);
} else {
- VmbusSetEvent(Channel->OfferMsg.ChildRelId);
+ VmbusSetEvent(channel->OfferMsg.ChildRelId);
}
}
@@ -117,54 +117,54 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
/*
* VmbusChannelGetDebugInfo -Retrieve various channel debug info
*/
-void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
- struct vmbus_channel_debug_info *DebugInfo)
+void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
+ struct vmbus_channel_debug_info *debuginfo)
{
- struct hv_monitor_page *monitorPage;
- u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32;
- u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32;
+ struct hv_monitor_page *monitorpage;
+ u8 monitor_group = (u8)channel->OfferMsg.MonitorId / 32;
+ u8 monitor_offset = (u8)channel->OfferMsg.MonitorId % 32;
/* u32 monitorBit = 1 << monitorOffset; */
- DebugInfo->RelId = Channel->OfferMsg.ChildRelId;
- DebugInfo->State = Channel->State;
- memcpy(&DebugInfo->InterfaceType,
- &Channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
- memcpy(&DebugInfo->InterfaceInstance,
- &Channel->OfferMsg.Offer.InterfaceInstance,
+ debuginfo->RelId = channel->OfferMsg.ChildRelId;
+ debuginfo->State = channel->State;
+ memcpy(&debuginfo->InterfaceType,
+ &channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
+ memcpy(&debuginfo->InterfaceInstance,
+ &channel->OfferMsg.Offer.InterfaceInstance,
sizeof(struct hv_guid));
- monitorPage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
+ monitorpage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
- DebugInfo->MonitorId = Channel->OfferMsg.MonitorId;
+ debuginfo->MonitorId = channel->OfferMsg.MonitorId;
- DebugInfo->ServerMonitorPending =
- monitorPage->TriggerGroup[monitorGroup].Pending;
- DebugInfo->ServerMonitorLatency =
- monitorPage->Latency[monitorGroup][monitorOffset];
- DebugInfo->ServerMonitorConnectionId =
- monitorPage->Parameter[monitorGroup]
- [monitorOffset].ConnectionId.u.Id;
+ debuginfo->ServerMonitorPending =
+ monitorpage->TriggerGroup[monitor_group].Pending;
+ debuginfo->ServerMonitorLatency =
+ monitorpage->Latency[monitor_group][monitor_offset];
+ debuginfo->ServerMonitorConnectionId =
+ monitorpage->Parameter[monitor_group]
+ [monitor_offset].ConnectionId.u.Id;
- monitorPage++;
+ monitorpage++;
- DebugInfo->ClientMonitorPending =
- monitorPage->TriggerGroup[monitorGroup].Pending;
- DebugInfo->ClientMonitorLatency =
- monitorPage->Latency[monitorGroup][monitorOffset];
- DebugInfo->ClientMonitorConnectionId =
- monitorPage->Parameter[monitorGroup]
- [monitorOffset].ConnectionId.u.Id;
+ debuginfo->ClientMonitorPending =
+ monitorpage->TriggerGroup[monitor_group].Pending;
+ debuginfo->ClientMonitorLatency =
+ monitorpage->Latency[monitor_group][monitor_offset];
+ debuginfo->ClientMonitorConnectionId =
+ monitorpage->Parameter[monitor_group]
+ [monitor_offset].ConnectionId.u.Id;
- RingBufferGetDebugInfo(&Channel->Inbound, &DebugInfo->Inbound);
- RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound);
+ RingBufferGetDebugInfo(&channel->Inbound, &debuginfo->Inbound);
+ RingBufferGetDebugInfo(&channel->Outbound, &debuginfo->Outbound);
}
/*
* VmbusChannelOpen - Open the specified channel.
*/
-int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
- u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
- void (*OnChannelCallback)(void *context), void *Context)
+int VmbusChannelOpen(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
+ u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
+ void (*onchannelcallback)(void *context), void *context)
{
struct vmbus_channel_open_channel *openMsg;
struct vmbus_channel_msginfo *openInfo = NULL;
@@ -176,30 +176,30 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
/* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
/* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */
- NewChannel->OnChannelCallback = OnChannelCallback;
- NewChannel->ChannelCallbackContext = Context;
+ newchannel->OnChannelCallback = onchannelcallback;
+ newchannel->ChannelCallbackContext = context;
/* Allocate the ring buffer */
- out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize)
+ out = osd_PageAlloc((send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
if (!out)
return -ENOMEM;
/* ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0); */
- in = (void *)((unsigned long)out + SendRingBufferSize);
+ in = (void *)((unsigned long)out + send_ringbuffer_size);
- NewChannel->RingBufferPages = out;
- NewChannel->RingBufferPageCount = (SendRingBufferSize +
- RecvRingBufferSize) >> PAGE_SHIFT;
+ newchannel->RingBufferPages = out;
+ newchannel->RingBufferPageCount = (send_ringbuffer_size +
+ recv_ringbuffer_size) >> PAGE_SHIFT;
- ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
+ ret = RingBufferInit(&newchannel->Outbound, out, send_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
}
- ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
+ ret = RingBufferInit(&newchannel->Inbound, in, recv_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
@@ -208,15 +208,15 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
/* Establish the gpadl for the ring buffer */
DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
- NewChannel);
+ newchannel);
- NewChannel->RingBufferGpadlHandle = 0;
+ newchannel->RingBufferGpadlHandle = 0;
- ret = VmbusChannelEstablishGpadl(NewChannel,
- NewChannel->Outbound.RingBuffer,
- SendRingBufferSize +
- RecvRingBufferSize,
- &NewChannel->RingBufferGpadlHandle);
+ ret = VmbusChannelEstablishGpadl(newchannel,
+ newchannel->Outbound.RingBuffer,
+ send_ringbuffer_size +
+ recv_ringbuffer_size,
+ &newchannel->RingBufferGpadlHandle);
if (ret != 0) {
err = ret;
@@ -225,13 +225,13 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
DPRINT_DBG(VMBUS, "channel %p <relid %d gpadl 0x%x send ring %p "
"size %d recv ring %p size %d, downstreamoffset %d>",
- NewChannel, NewChannel->OfferMsg.ChildRelId,
- NewChannel->RingBufferGpadlHandle,
- NewChannel->Outbound.RingBuffer,
- NewChannel->Outbound.RingSize,
- NewChannel->Inbound.RingBuffer,
- NewChannel->Inbound.RingSize,
- SendRingBufferSize);
+ newchannel, newchannel->OfferMsg.ChildRelId,
+ newchannel->RingBufferGpadlHandle,
+ newchannel->Outbound.RingBuffer,
+ newchannel->Outbound.RingSize,
+ newchannel->Inbound.RingBuffer,
+ newchannel->Inbound.RingSize,
+ send_ringbuffer_size);
/* Create and init the channel open message */
openInfo = kmalloc(sizeof(*openInfo) +
@@ -250,20 +250,20 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
openMsg = (struct vmbus_channel_open_channel *)openInfo->Msg;
openMsg->Header.MessageType = ChannelMessageOpenChannel;
- openMsg->OpenId = NewChannel->OfferMsg.ChildRelId; /* FIXME */
- openMsg->ChildRelId = NewChannel->OfferMsg.ChildRelId;
- openMsg->RingBufferGpadlHandle = NewChannel->RingBufferGpadlHandle;
- openMsg->DownstreamRingBufferPageOffset = SendRingBufferSize >>
+ openMsg->OpenId = newchannel->OfferMsg.ChildRelId; /* FIXME */
+ openMsg->ChildRelId = newchannel->OfferMsg.ChildRelId;
+ openMsg->RingBufferGpadlHandle = newchannel->RingBufferGpadlHandle;
+ openMsg->DownstreamRingBufferPageOffset = send_ringbuffer_size >>
PAGE_SHIFT;
openMsg->ServerContextAreaGpadlHandle = 0; /* TODO */
- if (UserDataLen > MAX_USER_DEFINED_BYTES) {
+ if (userdatalen > MAX_USER_DEFINED_BYTES) {
err = -EINVAL;
goto errorout;
}
- if (UserDataLen)
- memcpy(openMsg->UserData, UserData, UserDataLen);
+ if (userdatalen)
+ memcpy(openMsg->UserData, userdata, userdatalen);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&openInfo->MsgListEntry,
@@ -283,10 +283,10 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
osd_WaitEventWait(openInfo->WaitEvent);
if (openInfo->Response.OpenResult.Status == 0)
- DPRINT_INFO(VMBUS, "channel <%p> open success!!", NewChannel);
+ DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
else
DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!",
- NewChannel, openInfo->Response.OpenResult.Status);
+ newchannel, openInfo->Response.OpenResult.Status);
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
@@ -298,9 +298,9 @@ Cleanup:
return 0;
errorout:
- RingBufferCleanup(&NewChannel->Outbound);
- RingBufferCleanup(&NewChannel->Inbound);
- osd_PageFree(out, (SendRingBufferSize + RecvRingBufferSize)
+ RingBufferCleanup(&newchannel->Outbound);
+ RingBufferCleanup(&newchannel->Inbound);
+ osd_PageFree(out, (send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
kfree(openInfo);
return err;
@@ -310,289 +310,292 @@ errorout:
* DumpGpadlBody - Dump the gpadl body message to the console for
* debugging purposes.
*/
-static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len)
+static void DumpGpadlBody(struct vmbus_channel_gpadl_body *gpadl, u32 len)
{
int i;
- int pfnCount;
+ int pfncount;
- pfnCount = (Len - sizeof(struct vmbus_channel_gpadl_body)) /
+ pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
sizeof(u64);
- DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", Len, pfnCount);
+ DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
- for (i = 0; i < pfnCount; i++)
+ for (i = 0; i < pfncount; i++)
DPRINT_DBG(VMBUS, "gpadl body - %d) pfn %llu",
- i, Gpadl->Pfn[i]);
+ i, gpadl->Pfn[i]);
}
/*
* DumpGpadlHeader - Dump the gpadl header message to the console for
* debugging purposes.
*/
-static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl)
+static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *gpadl)
{
int i, j;
- int pageCount;
+ int pagecount;
DPRINT_DBG(VMBUS,
"gpadl header - relid %d, range count %d, range buflen %d",
- Gpadl->ChildRelId, Gpadl->RangeCount, Gpadl->RangeBufLen);
- for (i = 0; i < Gpadl->RangeCount; i++) {
- pageCount = Gpadl->Range[i].ByteCount >> PAGE_SHIFT;
- pageCount = (pageCount > 26) ? 26 : pageCount;
+ gpadl->ChildRelId, gpadl->RangeCount, gpadl->RangeBufLen);
+ for (i = 0; i < gpadl->RangeCount; i++) {
+ pagecount = gpadl->Range[i].ByteCount >> PAGE_SHIFT;
+ pagecount = (pagecount > 26) ? 26 : pagecount;
DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
- "page count %d", i, Gpadl->Range[i].ByteCount,
- Gpadl->Range[i].ByteOffset, pageCount);
+ "page count %d", i, gpadl->Range[i].ByteCount,
+ gpadl->Range[i].ByteOffset, pagecount);
- for (j = 0; j < pageCount; j++)
+ for (j = 0; j < pagecount; j++)
DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
- Gpadl->Range[i].PfnArray[j]);
+ gpadl->Range[i].PfnArray[j]);
}
}
/*
* VmbusChannelCreateGpadlHeader - Creates a gpadl for the specified buffer
*/
-static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
- struct vmbus_channel_msginfo **MsgInfo,
- u32 *MessageCount)
+static int VmbusChannelCreateGpadlHeader(void *kbuffer, u32 size,
+ struct vmbus_channel_msginfo **msginfo,
+ u32 *messagecount)
{
int i;
- int pageCount;
+ int pagecount;
unsigned long long pfn;
- struct vmbus_channel_gpadl_header *gpaHeader;
- struct vmbus_channel_gpadl_body *gpadlBody;
- struct vmbus_channel_msginfo *msgHeader;
- struct vmbus_channel_msginfo *msgBody = NULL;
- u32 msgSize;
+ struct vmbus_channel_gpadl_header *gpadl_header;
+ struct vmbus_channel_gpadl_body *gpadl_body;
+ struct vmbus_channel_msginfo *msgheader;
+ struct vmbus_channel_msginfo *msgbody = NULL;
+ u32 msgsize;
- int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize;
+ int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;
/* ASSERT((kbuffer & (PAGE_SIZE-1)) == 0); */
/* ASSERT((Size & (PAGE_SIZE-1)) == 0); */
- pageCount = Size >> PAGE_SHIFT;
- pfn = virt_to_phys(Kbuffer) >> PAGE_SHIFT;
+ pagecount = size >> PAGE_SHIFT;
+ pfn = virt_to_phys(kbuffer) >> PAGE_SHIFT;
/* do we need a gpadl body msg */
- pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+ pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
sizeof(struct vmbus_channel_gpadl_header) -
sizeof(struct gpa_range);
- pfnCount = pfnSize / sizeof(u64);
+ pfncount = pfnsize / sizeof(u64);
- if (pageCount > pfnCount) {
+ if (pagecount > pfncount) {
/* we need a gpadl body */
/* fill in the header */
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_header) +
- sizeof(struct gpa_range) + pfnCount * sizeof(u64);
- msgHeader = kzalloc(msgSize, GFP_KERNEL);
- if (!msgHeader)
+ sizeof(struct gpa_range) + pfncount * sizeof(u64);
+ msgheader = kzalloc(msgsize, GFP_KERNEL);
+ if (!msgheader)
goto nomem;
- INIT_LIST_HEAD(&msgHeader->SubMsgList);
- msgHeader->MessageSize = msgSize;
+ INIT_LIST_HEAD(&msgheader->SubMsgList);
+ msgheader->MessageSize = msgsize;
- gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
- gpaHeader->RangeCount = 1;
- gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
- pageCount * sizeof(u64);
- gpaHeader->Range[0].ByteOffset = 0;
- gpaHeader->Range[0].ByteCount = Size;
- for (i = 0; i < pfnCount; i++)
- gpaHeader->Range[0].PfnArray[i] = pfn+i;
- *MsgInfo = msgHeader;
- *MessageCount = 1;
+ gpadl_header = (struct vmbus_channel_gpadl_header *)
+ msgheader->Msg;
+ gpadl_header->RangeCount = 1;
+ gpadl_header->RangeBufLen = sizeof(struct gpa_range) +
+ pagecount * sizeof(u64);
+ gpadl_header->Range[0].ByteOffset = 0;
+ gpadl_header->Range[0].ByteCount = size;
+ for (i = 0; i < pfncount; i++)
+ gpadl_header->Range[0].PfnArray[i] = pfn+i;
+ *msginfo = msgheader;
+ *messagecount = 1;
- pfnSum = pfnCount;
- pfnLeft = pageCount - pfnCount;
+ pfnsum = pfncount;
+ pfnleft = pagecount - pfncount;
/* how many pfns can we fit */
- pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+ pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
sizeof(struct vmbus_channel_gpadl_body);
- pfnCount = pfnSize / sizeof(u64);
+ pfncount = pfnsize / sizeof(u64);
/* fill in the body */
- while (pfnLeft) {
- if (pfnLeft > pfnCount)
- pfnCurr = pfnCount;
+ while (pfnleft) {
+ if (pfnleft > pfncount)
+ pfncurr = pfncount;
else
- pfnCurr = pfnLeft;
+ pfncurr = pfnleft;
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_body) +
- pfnCurr * sizeof(u64);
- msgBody = kzalloc(msgSize, GFP_KERNEL);
+ pfncurr * sizeof(u64);
+ msgbody = kzalloc(msgsize, GFP_KERNEL);
/* FIXME: we probably need to more if this fails */
- if (!msgBody)
+ if (!msgbody)
goto nomem;
- msgBody->MessageSize = msgSize;
- (*MessageCount)++;
- gpadlBody =
- (struct vmbus_channel_gpadl_body *)msgBody->Msg;
+ msgbody->MessageSize = msgsize;
+ (*messagecount)++;
+ gpadl_body =
+ (struct vmbus_channel_gpadl_body *)msgbody->Msg;
/*
* FIXME:
* Gpadl is u32 and we are using a pointer which could
* be 64-bit
*/
- /* gpadlBody->Gpadl = kbuffer; */
- for (i = 0; i < pfnCurr; i++)
- gpadlBody->Pfn[i] = pfn + pfnSum + i;
+ /* gpadl_body->Gpadl = kbuffer; */
+ for (i = 0; i < pfncurr; i++)
+ gpadl_body->Pfn[i] = pfn + pfnsum + i;
/* add to msg header */
- list_add_tail(&msgBody->MsgListEntry,
- &msgHeader->SubMsgList);
- pfnSum += pfnCurr;
- pfnLeft -= pfnCurr;
+ list_add_tail(&msgbody->MsgListEntry,
+ &msgheader->SubMsgList);
+ pfnsum += pfncurr;
+ pfnleft -= pfncurr;
}
} else {
/* everything fits in a header */
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_header) +
- sizeof(struct gpa_range) + pageCount * sizeof(u64);
- msgHeader = kzalloc(msgSize, GFP_KERNEL);
- if (msgHeader == NULL)
+ sizeof(struct gpa_range) + pagecount * sizeof(u64);
+ msgheader = kzalloc(msgsize, GFP_KERNEL);
+ if (msgheader == NULL)
goto nomem;
- msgHeader->MessageSize = msgSize;
-
- gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
- gpaHeader->RangeCount = 1;
- gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
- pageCount * sizeof(u64);
- gpaHeader->Range[0].ByteOffset = 0;
- gpaHeader->Range[0].ByteCount = Size;
- for (i = 0; i < pageCount; i++)
- gpaHeader->Range[0].PfnArray[i] = pfn+i;
-
- *MsgInfo = msgHeader;
- *MessageCount = 1;
+ msgheader->MessageSize = msgsize;
+
+ gpadl_header = (struct vmbus_channel_gpadl_header *)
+ msgheader->Msg;
+ gpadl_header->RangeCount = 1;
+ gpadl_header->RangeBufLen = sizeof(struct gpa_range) +
+ pagecount * sizeof(u64);
+ gpadl_header->Range[0].ByteOffset = 0;
+ gpadl_header->Range[0].ByteCount = size;
+ for (i = 0; i < pagecount; i++)
+ gpadl_header->Range[0].PfnArray[i] = pfn+i;
+
+ *msginfo = msgheader;
+ *messagecount = 1;
}
return 0;
nomem:
- kfree(msgHeader);
- kfree(msgBody);
+ kfree(msgheader);
+ kfree(msgbody);
return -ENOMEM;
}
/*
* VmbusChannelEstablishGpadl - Estabish a GPADL for the specified buffer
*
- * @Channel: a channel
- * @Kbuffer: from kmalloc
- * @Size: page-size multiple
- * @GpadlHandle: some funky thing
+ * @channel: a channel
+ * @kbuffer: from kmalloc
+ * @size: page-size multiple
+ * @gpadl_handle: some funky thing
*/
-int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
- u32 Size, u32 *GpadlHandle)
+int VmbusChannelEstablishGpadl(struct vmbus_channel *channel, void *kbuffer,
+ u32 size, u32 *gpadl_handle)
{
- struct vmbus_channel_gpadl_header *gpadlMsg;
- struct vmbus_channel_gpadl_body *gpadlBody;
+ struct vmbus_channel_gpadl_header *gpadlmsg;
+ struct vmbus_channel_gpadl_body *gpadl_body;
/* struct vmbus_channel_gpadl_created *gpadlCreated; */
- struct vmbus_channel_msginfo *msgInfo = NULL;
- struct vmbus_channel_msginfo *subMsgInfo;
- u32 msgCount;
+ struct vmbus_channel_msginfo *msginfo = NULL;
+ struct vmbus_channel_msginfo *submsginfo;
+ u32 msgcount;
struct list_head *curr;
- u32 nextGpadlHandle;
+ u32 next_gpadl_handle;
unsigned long flags;
int ret = 0;
- nextGpadlHandle = atomic_read(&gVmbusConnection.NextGpadlHandle);
+ next_gpadl_handle = atomic_read(&gVmbusConnection.NextGpadlHandle);
atomic_inc(&gVmbusConnection.NextGpadlHandle);
- ret = VmbusChannelCreateGpadlHeader(Kbuffer, Size, &msgInfo, &msgCount);
+ ret = VmbusChannelCreateGpadlHeader(kbuffer, size, &msginfo, &msgcount);
if (ret)
return ret;
- msgInfo->WaitEvent = osd_WaitEventCreate();
- if (!msgInfo->WaitEvent) {
+ msginfo->WaitEvent = osd_WaitEventCreate();
+ if (!msginfo->WaitEvent) {
ret = -ENOMEM;
goto Cleanup;
}
- gpadlMsg = (struct vmbus_channel_gpadl_header *)msgInfo->Msg;
- gpadlMsg->Header.MessageType = ChannelMessageGpadlHeader;
- gpadlMsg->ChildRelId = Channel->OfferMsg.ChildRelId;
- gpadlMsg->Gpadl = nextGpadlHandle;
+ gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->Msg;
+ gpadlmsg->Header.MessageType = ChannelMessageGpadlHeader;
+ gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId;
+ gpadlmsg->Gpadl = next_gpadl_handle;
- DumpGpadlHeader(gpadlMsg);
+ DumpGpadlHeader(gpadlmsg);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&msgInfo->MsgListEntry,
+ list_add_tail(&msginfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
- Kbuffer, Size, msgCount);
+ kbuffer, size, msgcount);
DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
- msgInfo->MessageSize - sizeof(*msgInfo));
+ msginfo->MessageSize - sizeof(*msginfo));
- ret = VmbusPostMessage(gpadlMsg, msgInfo->MessageSize -
- sizeof(*msgInfo));
+ ret = VmbusPostMessage(gpadlmsg, msginfo->MessageSize -
+ sizeof(*msginfo));
if (ret != 0) {
DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
goto Cleanup;
}
- if (msgCount > 1) {
- list_for_each(curr, &msgInfo->SubMsgList) {
+ if (msgcount > 1) {
+ list_for_each(curr, &msginfo->SubMsgList) {
/* FIXME: should this use list_entry() instead ? */
- subMsgInfo = (struct vmbus_channel_msginfo *)curr;
- gpadlBody =
- (struct vmbus_channel_gpadl_body *)subMsgInfo->Msg;
+ submsginfo = (struct vmbus_channel_msginfo *)curr;
+ gpadl_body =
+ (struct vmbus_channel_gpadl_body *)submsginfo->Msg;
- gpadlBody->Header.MessageType = ChannelMessageGpadlBody;
- gpadlBody->Gpadl = nextGpadlHandle;
+ gpadl_body->Header.MessageType =
+ ChannelMessageGpadlBody;
+ gpadl_body->Gpadl = next_gpadl_handle;
DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd",
- subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
-
- DumpGpadlBody(gpadlBody, subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
- ret = VmbusPostMessage(gpadlBody,
- subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
+ submsginfo->MessageSize -
+ sizeof(*submsginfo));
+
+ DumpGpadlBody(gpadl_body, submsginfo->MessageSize -
+ sizeof(*submsginfo));
+ ret = VmbusPostMessage(gpadl_body,
+ submsginfo->MessageSize -
+ sizeof(*submsginfo));
if (ret != 0)
goto Cleanup;
}
}
- osd_WaitEventWait(msgInfo->WaitEvent);
+ osd_WaitEventWait(msginfo->WaitEvent);
/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created "
"(relid %d, status %d handle %x)",
- Channel->OfferMsg.ChildRelId,
- msgInfo->Response.GpadlCreated.CreationStatus,
- gpadlMsg->Gpadl);
+ channel->OfferMsg.ChildRelId,
+ msginfo->Response.GpadlCreated.CreationStatus,
+ gpadlmsg->Gpadl);
- *GpadlHandle = gpadlMsg->Gpadl;
+ *gpadl_handle = gpadlmsg->Gpadl;
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_del(&msgInfo->MsgListEntry);
+ list_del(&msginfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
- kfree(msgInfo->WaitEvent);
- kfree(msgInfo);
+ kfree(msginfo->WaitEvent);
+ kfree(msginfo);
return ret;
}
/*
* VmbusChannelTeardownGpadl -Teardown the specified GPADL handle
*/
-int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
+int VmbusChannelTeardownGpadl(struct vmbus_channel *channel, u32 gpadl_handle)
{
struct vmbus_channel_gpadl_teardown *msg;
struct vmbus_channel_msginfo *info;
unsigned long flags;
int ret;
- /* ASSERT(GpadlHandle != 0); */
+ /* ASSERT(gpadl_handle != 0); */
info = kmalloc(sizeof(*info) +
sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
@@ -608,8 +611,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
msg = (struct vmbus_channel_gpadl_teardown *)info->Msg;
msg->Header.MessageType = ChannelMessageGpadlTeardown;
- msg->ChildRelId = Channel->OfferMsg.ChildRelId;
- msg->Gpadl = GpadlHandle;
+ msg->ChildRelId = channel->OfferMsg.ChildRelId;
+ msg->Gpadl = gpadl_handle;
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&info->MsgListEntry,
@@ -638,7 +641,7 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
/*
* VmbusChannelClose - Close the specified channel
*/
-void VmbusChannelClose(struct vmbus_channel *Channel)
+void VmbusChannelClose(struct vmbus_channel *channel)
{
struct vmbus_channel_close_channel *msg;
struct vmbus_channel_msginfo *info;
@@ -646,8 +649,8 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
int ret;
/* Stop callback and cancel the timer asap */
- Channel->OnChannelCallback = NULL;
- del_timer_sync(&Channel->poll_timer);
+ channel->OnChannelCallback = NULL;
+ del_timer_sync(&channel->poll_timer);
/* Send a closing message */
info = kmalloc(sizeof(*info) +
@@ -661,7 +664,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
msg = (struct vmbus_channel_close_channel *)info->Msg;
msg->Header.MessageType = ChannelMessageCloseChannel;
- msg->ChildRelId = Channel->OfferMsg.ChildRelId;
+ msg->ChildRelId = channel->OfferMsg.ChildRelId;
ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
if (ret != 0) {
@@ -670,17 +673,17 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
}
/* Tear down the gpadl for the channel's ring buffer */
- if (Channel->RingBufferGpadlHandle)
- VmbusChannelTeardownGpadl(Channel,
- Channel->RingBufferGpadlHandle);
+ if (channel->RingBufferGpadlHandle)
+ VmbusChannelTeardownGpadl(channel,
+ channel->RingBufferGpadlHandle);
/* TODO: Send a msg to release the childRelId */
/* Cleanup the ring buffers for this channel */
- RingBufferCleanup(&Channel->Outbound);
- RingBufferCleanup(&Channel->Inbound);
+ RingBufferCleanup(&channel->Outbound);
+ RingBufferCleanup(&channel->Inbound);
- osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
+ osd_PageFree(channel->RingBufferPages, channel->RingBufferPageCount);
kfree(info);
@@ -690,65 +693,66 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
* caller will free the channel
*/
- if (Channel->State == CHANNEL_OPEN_STATE) {
+ if (channel->State == CHANNEL_OPEN_STATE) {
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_del(&Channel->ListEntry);
+ list_del(&channel->ListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
- FreeVmbusChannel(Channel);
+ FreeVmbusChannel(channel);
}
}
/**
* VmbusChannelSendPacket() - Send the specified buffer on the given channel
- * @Channel: Pointer to vmbus_channel structure.
- * @Buffer: Pointer to the buffer you want to receive the data into.
- * @BufferLen: Maximum size of what the the buffer will hold
- * @RequestId: Identifier of the request
- * @vmbus_packet_type: Type of packet that is being send e.g. negotiate, time
+ * @channel: Pointer to vmbus_channel structure.
+ * @buffer: Pointer to the buffer you want to receive the data into.
+ * @bufferlen: Maximum size of what the the buffer will hold
+ * @requestid: Identifier of the request
+ * @type: Type of packet that is being send e.g. negotiate, time
* packet etc.
*
- * Sends data in @Buffer directly to hyper-v via the vmbus
+ * Sends data in @buffer directly to hyper-v via the vmbus
* This will send the data unparsed to hyper-v.
*
* Mainly used by Hyper-V drivers.
*/
-int VmbusChannelSendPacket(struct vmbus_channel *Channel, const void *Buffer,
- u32 BufferLen, u64 RequestId,
- enum vmbus_packet_type Type, u32 Flags)
+int VmbusChannelSendPacket(struct vmbus_channel *channel, const void *buffer,
+ u32 bufferlen, u64 requestid,
+ enum vmbus_packet_type type, u32 flags)
{
struct vmpacket_descriptor desc;
- u32 packetLen = sizeof(struct vmpacket_descriptor) + BufferLen;
- u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
+ u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen;
+ u32 packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
int ret;
DPRINT_DBG(VMBUS, "channel %p buffer %p len %d",
- Channel, Buffer, BufferLen);
+ channel, buffer, bufferlen);
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.Type = Type; /* VmbusPacketTypeDataInBand; */
- desc.Flags = Flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
+ desc.Type = type; /* VmbusPacketTypeDataInBand; */
+ desc.Flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
/* in 8-bytes granularity */
desc.DataOffset8 = sizeof(struct vmpacket_descriptor) >> 3;
- desc.Length8 = (u16)(packetLenAligned >> 3);
- desc.TransactionId = RequestId;
+ desc.Length8 = (u16)(packetlen_aligned >> 3);
+ desc.TransactionId = requestid;
- sg_init_table(bufferList, 3);
- sg_set_buf(&bufferList[0], &desc, sizeof(struct vmpacket_descriptor));
- sg_set_buf(&bufferList[1], Buffer, BufferLen);
- sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, sizeof(struct vmpacket_descriptor));
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -758,61 +762,62 @@ EXPORT_SYMBOL(VmbusChannelSendPacket);
* VmbusChannelSendPacketPageBuffer - Send a range of single-page buffer
* packets using a GPADL Direct packet type.
*/
-int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
- struct hv_page_buffer PageBuffers[],
- u32 PageCount, void *Buffer, u32 BufferLen,
- u64 RequestId)
+int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel,
+ struct hv_page_buffer pagebuffers[],
+ u32 pagecount, void *buffer, u32 bufferlen,
+ u64 requestid)
{
int ret;
int i;
struct vmbus_channel_packet_page_buffer desc;
- u32 descSize;
- u32 packetLen;
- u32 packetLenAligned;
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
+ u32 descsize;
+ u32 packetlen;
+ u32 packetlen_aligned;
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
- if (PageCount > MAX_PAGE_BUFFER_COUNT)
+ if (pagecount > MAX_PAGE_BUFFER_COUNT)
return -EINVAL;
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/*
* Adjust the size down since vmbus_channel_packet_page_buffer is the
* largest size we support
*/
- descSize = sizeof(struct vmbus_channel_packet_page_buffer) -
- ((MAX_PAGE_BUFFER_COUNT - PageCount) *
+ descsize = sizeof(struct vmbus_channel_packet_page_buffer) -
+ ((MAX_PAGE_BUFFER_COUNT - pagecount) *
sizeof(struct hv_page_buffer));
- packetLen = descSize + BufferLen;
- packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+ packetlen = descsize + bufferlen;
+ packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
desc.type = VmbusPacketTypeDataUsingGpaDirect;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.length8 = (u16)(packetLenAligned >> 3);
- desc.transactionid = RequestId;
- desc.rangecount = PageCount;
-
- for (i = 0; i < PageCount; i++) {
- desc.range[i].Length = PageBuffers[i].Length;
- desc.range[i].Offset = PageBuffers[i].Offset;
- desc.range[i].Pfn = PageBuffers[i].Pfn;
+ desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetlen_aligned >> 3);
+ desc.transactionid = requestid;
+ desc.rangecount = pagecount;
+
+ for (i = 0; i < pagecount; i++) {
+ desc.range[i].Length = pagebuffers[i].Length;
+ desc.range[i].Offset = pagebuffers[i].Offset;
+ desc.range[i].Pfn = pagebuffers[i].Pfn;
}
- 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);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, descsize);
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -821,64 +826,66 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
* VmbusChannelSendPacketMultiPageBuffer - Send a multi-page buffer packet
* using a GPADL Direct packet type.
*/
-int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
- struct hv_multipage_buffer *MultiPageBuffer,
- void *Buffer, u32 BufferLen, u64 RequestId)
+int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
+ struct hv_multipage_buffer *multi_pagebuffer,
+ void *buffer, u32 bufferlen, u64 requestid)
{
int ret;
struct vmbus_channel_packet_multipage_buffer desc;
- u32 descSize;
- u32 packetLen;
- u32 packetLenAligned;
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
- u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset,
- MultiPageBuffer->Length);
+ u32 descsize;
+ u32 packetlen;
+ u32 packetlen_aligned;
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
+ u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->Offset,
+ multi_pagebuffer->Length);
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u",
- MultiPageBuffer->Offset, MultiPageBuffer->Length, PfnCount);
+ multi_pagebuffer->Offset,
+ multi_pagebuffer->Length, pfncount);
- if ((PfnCount < 0) || (PfnCount > MAX_MULTIPAGE_BUFFER_COUNT))
+ if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT))
return -EINVAL;
/*
* Adjust the size down since vmbus_channel_packet_multipage_buffer is
* the largest size we support
*/
- descSize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
- ((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount) *
+ descsize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
+ ((MAX_MULTIPAGE_BUFFER_COUNT - pfncount) *
sizeof(u64));
- packetLen = descSize + BufferLen;
- packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+ packetlen = descsize + bufferlen;
+ packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
desc.type = VmbusPacketTypeDataUsingGpaDirect;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.length8 = (u16)(packetLenAligned >> 3);
- desc.transactionid = RequestId;
+ desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetlen_aligned >> 3);
+ desc.transactionid = requestid;
desc.rangecount = 1;
- desc.range.Length = MultiPageBuffer->Length;
- desc.range.Offset = MultiPageBuffer->Offset;
+ desc.range.Length = multi_pagebuffer->Length;
+ desc.range.Offset = multi_pagebuffer->Offset;
- memcpy(desc.range.PfnArray, MultiPageBuffer->PfnArray,
- PfnCount * sizeof(u64));
+ memcpy(desc.range.PfnArray, multi_pagebuffer->PfnArray,
+ pfncount * sizeof(u64));
- 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);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, descsize);
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -886,35 +893,35 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
/**
* VmbusChannelRecvPacket() - Retrieve the user packet on the specified channel
- * @Channel: Pointer to vmbus_channel structure.
- * @Buffer: Pointer to the buffer you want to receive the data into.
- * @BufferLen: Maximum size of what the the buffer will hold
- * @BufferActualLen: The actual size of the data after it was received
- * @RequestId: Identifier of the request
+ * @channel: Pointer to vmbus_channel structure.
+ * @buffer: Pointer to the buffer you want to receive the data into.
+ * @bufferlen: Maximum size of what the the buffer will hold
+ * @buffer_actual_len: The actual size of the data after it was received
+ * @requestid: Identifier of the request
*
* Receives directly from the hyper-v vmbus and puts the data it received
* into Buffer. This will receive the data unparsed from hyper-v.
*
* Mainly used by Hyper-V drivers.
*/
-int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
- u32 BufferLen, u32 *BufferActualLen, u64 *RequestId)
+int VmbusChannelRecvPacket(struct vmbus_channel *channel, void *buffer,
+ u32 bufferlen, u32 *buffer_actual_len, u64 *requestid)
{
struct vmpacket_descriptor desc;
- u32 packetLen;
- u32 userLen;
+ u32 packetlen;
+ u32 userlen;
int ret;
unsigned long flags;
- *BufferActualLen = 0;
- *RequestId = 0;
+ *buffer_actual_len = 0;
+ *requestid = 0;
- spin_lock_irqsave(&Channel->inbound_lock, flags);
+ spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&Channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->Inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
return 0;
@@ -922,32 +929,32 @@ int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
/* VmbusChannelClearEvent(Channel); */
- packetLen = desc.Length8 << 3;
- userLen = packetLen - (desc.DataOffset8 << 3);
+ packetlen = desc.Length8 << 3;
+ userlen = packetlen - (desc.DataOffset8 << 3);
/* ASSERT(userLen > 0); */
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- Channel, Channel->OfferMsg.ChildRelId, desc.Type,
- desc.Flags, desc.TransactionId, packetLen, userLen);
+ channel, channel->OfferMsg.ChildRelId, desc.Type,
+ desc.Flags, desc.TransactionId, packetlen, userlen);
- *BufferActualLen = userLen;
+ *buffer_actual_len = userlen;
- if (userLen > BufferLen) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ if (userlen > bufferlen) {
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
DPRINT_ERR(VMBUS, "buffer too small - got %d needs %d",
- BufferLen, userLen);
+ bufferlen, userlen);
return -1;
}
- *RequestId = desc.TransactionId;
+ *requestid = desc.TransactionId;
/* Copy over the packet to the user buffer */
- ret = RingBufferRead(&Channel->Inbound, Buffer, userLen,
+ ret = RingBufferRead(&channel->Inbound, buffer, userlen,
(desc.DataOffset8 << 3));
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
}
@@ -956,25 +963,25 @@ EXPORT_SYMBOL(VmbusChannelRecvPacket);
/*
* VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel
*/
-int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
- u32 BufferLen, u32 *BufferActualLen,
- u64 *RequestId)
+int VmbusChannelRecvPacketRaw(struct vmbus_channel *channel, void *buffer,
+ u32 bufferlen, u32 *buffer_actual_len,
+ u64 *requestid)
{
struct vmpacket_descriptor desc;
- u32 packetLen;
- u32 userLen;
+ u32 packetlen;
+ u32 userlen;
int ret;
unsigned long flags;
- *BufferActualLen = 0;
- *RequestId = 0;
+ *buffer_actual_len = 0;
+ *requestid = 0;
- spin_lock_irqsave(&Channel->inbound_lock, flags);
+ spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&Channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->Inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
return 0;
@@ -982,44 +989,44 @@ int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
/* VmbusChannelClearEvent(Channel); */
- packetLen = desc.Length8 << 3;
- userLen = packetLen - (desc.DataOffset8 << 3);
+ packetlen = desc.Length8 << 3;
+ userlen = packetlen - (desc.DataOffset8 << 3);
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- Channel, Channel->OfferMsg.ChildRelId, desc.Type,
- desc.Flags, desc.TransactionId, packetLen, userLen);
+ channel, channel->OfferMsg.ChildRelId, desc.Type,
+ desc.Flags, desc.TransactionId, packetlen, userlen);
- *BufferActualLen = packetLen;
+ *buffer_actual_len = packetlen;
- if (packetLen > BufferLen) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ if (packetlen > bufferlen) {
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
DPRINT_ERR(VMBUS, "buffer too small - needed %d bytes but "
- "got space for only %d bytes", packetLen, BufferLen);
+ "got space for only %d bytes", packetlen, bufferlen);
return -2;
}
- *RequestId = desc.TransactionId;
+ *requestid = desc.TransactionId;
/* Copy over the entire packet to the user buffer */
- ret = RingBufferRead(&Channel->Inbound, Buffer, packetLen, 0);
+ ret = RingBufferRead(&channel->Inbound, buffer, packetlen, 0);
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
}
/*
* VmbusChannelOnChannelEvent - Channel event callback
*/
-void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel)
+void VmbusChannelOnChannelEvent(struct vmbus_channel *channel)
{
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/* ASSERT(Channel->OnChannelCallback); */
- Channel->OnChannelCallback(Channel->ChannelCallbackContext);
+ channel->OnChannelCallback(channel->ChannelCallbackContext);
- mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100));
+ mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100));
}
/*
@@ -1036,9 +1043,9 @@ void VmbusChannelOnTimer(unsigned long data)
/*
* DumpVmbusChannel - Dump vmbus channel info to the console
*/
-static void DumpVmbusChannel(struct vmbus_channel *Channel)
+static void DumpVmbusChannel(struct vmbus_channel *channel)
{
- DPRINT_DBG(VMBUS, "Channel (%d)", Channel->OfferMsg.ChildRelId);
- DumpRingInfo(&Channel->Outbound, "Outbound ");
- DumpRingInfo(&Channel->Inbound, "Inbound ");
+ DPRINT_DBG(VMBUS, "Channel (%d)", channel->OfferMsg.ChildRelId);
+ DumpRingInfo(&channel->Outbound, "Outbound ");
+ DumpRingInfo(&channel->Inbound, "Inbound ");
}
--
1.6.3.2
^ permalink raw reply related
* Re: [E1000-eedc] [PATCH 02/10] implementation of IEEE 802.1Qbg in lldpad, part 1
From: Jens Osterkamp @ 2010-09-24 14:23 UTC (permalink / raw)
To: John Fastabend
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <4C9AA43B.9000702@intel.com>
On Thursday 23 September 2010, John Fastabend wrote:
> On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
> > This patch contains the first part of an initial implementation of the
> > IEEE 802.1Qbg standard: it implements code for the exchange of EVB
> > capabilities between a host with virtual machines and an adjacent switch.
> > For this it adds a new EVB TLV to LLDP.
> >
> > Exchange of EVB TLV may be enabled or disabled on a per port basis.
> > Information about the information negotiated by the protocol can be
> > queried on the commandline with lldptool.
> >
> > This patch adds support for querying and setting parameters used in
> > the exchange of EVB TLV messages.
> > The parameters that can be set are:
> >
> > - forwarding mode
> > - host protocol capabilities (RTE, ECP, VDP)
> > - no. of supported VSIs
> > - retransmission timer exponent (RTE)
> >
> > The parameters are implemented as a local policy: all frames received by
> > an adjacent switch are validated against this policy and taken over where
> > appropriate. Negotiated parameters are stored in lldpads config, picked up
> > again and used at the next start.
> >
> > The patch applies to lldpad 0.9.38 and still contains code to log protocol
> > activity more verbosely than it would be necessary in the final version.
> >
> > Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
snip
> remove the unneeded braces in the if statements above.
>
> > + /* only look at the mode for now
> > + if (tie->ccap == ed->tie->ccap) {
> > + ed->tie->ccap = tie->ccap;
> > + }
> > +
> > + if (tie->cvsi == ed->tie->cvsi) {
> > + ed->tie->cvsi = tie->cvsi;
> > + }
> > + */
>
> Why is this commented out? I will review the spec shortly, but please
> remind me. If its not needed remove it and add it later in a clean
> patch
Its not used right now, so its commented out. I removed it for now.
>
> > +
> > + return TLV_OK;
> > +}
> > +
> > +/* evb_compare
> > + *
> > + * compare our own and received tlv_info_evb
> > + */
> > +static int evb_compare(struct evb_data *ed, struct tlv_info_evb *tie)
> > +{
> > + printf("%s(%i): \n", __func__, __LINE__);
> > +
> > + if ((ed->tie->cmode == tie->cmode) /* &&
> > + (ed->tie->ccap == tie->ccap) &&
> > + (ed->tie->cvsi == tie->cvsi)*/)
>
> Same here if its going to be commented out lets remove it for now.
Removed it.
>
> > + return 0;
> > + else
> > + return 1;
> > +}
> > +
> > +/* evb_statemachine:
> > + *
> > + * handle possible states during EVB capabilities exchange
> > + *
> > + * possible states: EVB_OFFER_CAPABILITIES
> > + * EVB_CONFIGURE
> > + * EVB_CONFIRMATION
> > + */
> > +static void evb_statemachine(struct evb_data *ed, struct tlv_info_evb *tie)
snip
> > diff --git a/lldptool.c b/lldptool.c
> > index 5cf2846..7e166fe 100644
> > --- a/lldptool.c
> > +++ b/lldptool.c
> > @@ -39,6 +39,7 @@
> > #include "lldp_med_clif.h"
> > #include "lldp_8023_clif.h"
> > #include "lldp_dcbx_clif.h"
> > +#include "lldp_evb_clif.h"
> > #include "lldptool.h"
> > #include "lldptool_cli.h"
> > #include "lldp_mod.h"
> > @@ -156,6 +157,7 @@ struct lldp_module *(*register_tlv_table[])(void) = {
> > ieee8023_cli_register,
> > med_cli_register,
> > dcbx_cli_register,
> > + evb_cli_register,
> > NULL,
> > };
> >
>
> Jens, in general this looks OK. Can you fix the coding style throughout
> I prefer for single line if statements,
>
> if (x)
> a_line;
> else (y)
> b_line;
>
> The intent here is to use the same coding style as linux kernel where it
> is reasonable to do so. Like I said before I know lldpad is not at all
> consistent in this regard, but I want to get the rest of the code in
> order and certainly have new code be consistent.
fixed this in all the places I could find.
I will address the rest your comments in my next posting of the series.
Thanks !
Jens
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply
* Re: [E1000-eedc] [PATCH 04/10] ECP implementation
From: Jens Osterkamp @ 2010-09-24 14:18 UTC (permalink / raw)
To: John Fastabend
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <4C9AA46D.2040802@intel.com>
On Thursday 23 September 2010, John Fastabend wrote:
> On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
> > This is the implementation of the edge control protocol (ECP) as specified
> > in IEEE 802.1Qbg.
> >
> > For this it extends the infrastructure defined lldpad to send and receive
> > ECP frames with a new (yet to be defined) ethertype.
> > Received frames are validated and analyzed before the content is handed to the
> > upper layer protocol (ULP, VDP in this case) for further processing. Frames
> > to be transmitted are compiled from VSI (guest interface) profiles registered
> > on a interface.
> > Reception and transmission of ECP frames is controlled by RX and TX state
> > machines, timeouts are handled timeout functions.
> > The patch still contains a lot of debug code to allow low-level protocol
> > analysis.
> >
> > Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
>
> I am hesitant to apply these without a defined ethertype. Presumably this will come out of the IEEE DCB task group.
I am not familiar with the IEEE process, but my current understanding is that the ethertype is defined towards the
end of the standardization process, and the extended ethertype together with the OUI has to be used until then.
>
> > ---
> > Makefile.am | 2 +
> > ecp/ecp.c | 77 +++++++
> > ecp/ecp.h | 92 ++++++++
> > ecp/ecp_rx.c | 597 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > ecp/ecp_tx.c | 467 ++++++++++++++++++++++++++++++++++++++++
> > include/lldp_evb.h | 6 +
> > include/lldp_vdp.h | 157 ++++++++++++++
> > lldp/l2_packet.h | 2 +
> > lldp/ports.h | 25 ++-
> > 9 files changed, 1422 insertions(+), 3 deletions(-)
> > create mode 100644 ecp/ecp.c
> > create mode 100644 ecp/ecp.h
> > create mode 100644 ecp/ecp_rx.c
> > create mode 100644 ecp/ecp_tx.c
> > create mode 100644 include/lldp_vdp.h
> >
> > diff --git a/Makefile.am b/Makefile.am
> > index d59a6fa..061f2ee 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -56,6 +56,8 @@ $(lldpad_include_HEADERS) $(noinst_HEADERS) \
> > lldp/ports.c lldp/agent.c lldp/l2_packet_linux.c lldp/tx.c \
> > lldp/rx.c lldp/agent.h lldp/l2_packet.h lldp/mibdata.h lldp/ports.h \
> > lldp/states.h \
> > +ecp/ecp.c ecp/ecp_tx.c \
> > +ecp/ecp_rx.c \
> > include/lldp.h include/lldp_mod.h \
> > lldp_dcbx.c include/lldp_dcbx.h tlv_dcbx.c include/tlv_dcbx.h \
> > lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
> > diff --git a/ecp/ecp.c b/ecp/ecp.c
> > new file mode 100644
> > index 0000000..ecf68f9
> > --- /dev/null
> > +++ b/ecp/ecp.c
> > @@ -0,0 +1,77 @@
>
> snip snip
>
snip
> Please merge the relevant pieces of this patch with the following patch so it does not add 'struct ecp' to the port structure then immediately move it to vdp_data in the following patch.
I will address your comments in my next posting of the series and merge the relevant pieces to the previous patch.
Thanks !
Jens
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply
* Re: [E1000-eedc] [PATCH 05/10] implementation of VDP
From: Jens Osterkamp @ 2010-09-24 14:15 UTC (permalink / raw)
To: John Fastabend
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <4C9AA580.2010102@intel.com>
On Thursday 23 September 2010, John Fastabend wrote:
> On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
> > This patch contains an initial implemention of VDP as specified in IEEE
> > 802.1Qbg.
> > VDP serves as the upper layer protocol (ULP) for TLVs communicated via the
> > ECP protocol.
> > For this it registers as a new module in lldpad. The VDP module supports a
> > station and a bridge role. As a station, new VSI (virtual station interface)
> > profiles can be registered to the VDP module using lldptool or libvirt.
> > These profiles are then announced to an adjacent switch. Transmitted profiles
> > are processed to the desired state by the VDP station state machine.
> > As a bridge, the VDP module waits for new profiles received in TLVs by ECP.
> > The received profiles are processed to the desired state by a VDP bridge
> > state machine.
> >
> > VDP module parameters are stored in the "vdp" section under the appropriate
> > interface.
> >
> > The patch still contains a lot of debug code to allow analysis of VDP
> > protocol behavior.
> >
> > Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
snip
>
>
> Few minor nits otherwise looks good. Please merge relevant parts with patch 4 though.
I will address all your comments in my next posting of the series.
Thanks !
Jens
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply
* Re: [E1000-eedc] [PATCH 06/10] VDP commandline interface
From: Jens Osterkamp @ 2010-09-24 14:13 UTC (permalink / raw)
To: John Fastabend
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <4C9AA5E8.8050603@intel.com>
On Thursday 23 September 2010, John Fastabend wrote:
> On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
> > This patch implements the command line interface to control the VDP module.
> > In station role, it allows to register a new VSI (guest interface) profile
> > and query its state. In bridge role, it allows to query the state of all
> > registered profiles.
> > With lldptool it is possible to set the role from default "station" to
> > "bridge".
> > The configuration of the role for a port is saved to lldpads config file.
> >
> > Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
> > ---
> > Makefile.am | 12 +-
> > include/lldp_vdp_clif.h | 39 +++++
> > include/lldp_vdp_cmds.h | 44 ++++++
> > lldp_vdp_clif.c | 136 ++++++++++++++++
> > lldp_vdp_cmds.c | 394 +++++++++++++++++++++++++++++++++++++++++++++++
> > lldptool.c | 2 +
> > 6 files changed, 622 insertions(+), 5 deletions(-)
> > create mode 100644 include/lldp_vdp_clif.h
> > create mode 100644 include/lldp_vdp_cmds.h
> > create mode 100644 lldp_vdp_clif.c
> > create mode 100644 lldp_vdp_cmds.c
> >
> > diff --git a/Makefile.am b/Makefile.am
> > index 4b69389..9a3baf4 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -37,7 +37,8 @@ lldpad_include_HEADERS = include/dcb_types.h include/dcbtool.h \
> > include/dcb_osdep.h include/clif.h include/lldp_dcbx_cmds.h include/common.h \
> > include/lldpad.h include/os.h include/includes.h include/lldp_mand_cmds.h \
> > include/clif_msgs.h include/lldp_basman_cmds.h include/lldp_8023_cmds.h \
> > -include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h
> > +include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h \
> > +include/lldp_vdp_cmds.h
> >
> > noinst_HEADERS = include/config.h include/ctrl_iface.h \
> > include/dcb_driver_if_types.h include/dcb_driver_interface.h \
> > @@ -47,7 +48,7 @@ include/event_iface.h include/messages.h include/parse_cli.h include/version.h \
> > include/lldptool_cli.h include/list.h \
> > include/lldp_mand_clif.h include/lldp_basman_clif.h include/lldp_med_clif.h \
> > include/lldp_8023_clif.h include/lldp_dcbx_clif.h include/lldptool.h \
> > -include/lldp_rtnl.h include/lldp_evb_clif.h
> > +include/lldp_rtnl.h include/lldp_evb_clif.h include/lldp_vdp_clif.h
> >
> > lldpad_SOURCES = lldpad.c config.c drv_cfg.c ctrl_iface.c event_iface.c eloop.c \
> > common.c os_unix.c lldp_dcbx_cmds.c log.c lldpad_shm.c \
> > @@ -64,20 +65,21 @@ lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
> > lldp_util.c include/lldp_util.h \
> > lldp_mand.c include/lldp_mand.h \
> > lldp_mand_cmds.c lldp_basman_cmds.c lldp_8023_cmds.c lldp_med_cmds.c \
> > -lldp_evb_cmds.c \
> > +lldp_evb_cmds.c lldp_vdp_cmds.c \
> > lldp_tlv.c include/lldp_tlv.h \
> > lldp_basman.c include/lldp_basman.h \
> > lldp_med.c include/lldp_med.h \
> > lldp_8023.c include/lldp_8023.h \
> > lldp_evb.c include/lldp_evb.h \
> > -lldp_vdp.c include/lldp_vdp.h
> > +lldp_vdp.c include/lldp_vdp.h \
> > +lldp_vdp_cmds.h
> >
> > dcbtool_SOURCES = dcbtool.c clif.c dcbtool_cmds.c parse_cli.l \
> > $(lldpad_include_HEADERS) $(noinst_HEADERS)
> >
> > lldptool_SOURCES = lldptool.c clif.c lldptool_cmds.c common.c os_unix.c \
> > lldp_mand_clif.c lldp_basman_clif.c lldp_med_clif.c lldp_8023_clif.c \
> > -lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) \
> > +lldp_dcbx_clif.c lldp_evb_clif.c lldp_vdp_clif.c $(lldpad_include_HEADERS) \
> > $(noinst_HEADERS)
> >
> > nltest_SOURCES = nltest.c nltest.h
> > diff --git a/include/lldp_vdp_clif.h b/include/lldp_vdp_clif.h
> > new file mode 100644
> > index 0000000..adb6333
> > --- /dev/null
> > +++ b/include/lldp_vdp_clif.h
> > @@ -0,0 +1,39 @@
> > +/*******************************************************************************
> > +
> > + implementation of VDP according to IEEE 802.1Qbg
> > + (c) Copyright IBM Corp. 2010
> > +
> > + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> > +
> > + This program is free software; you can redistribute it and/or modify it
> > + under the terms and conditions of the GNU General Public License,
> > + version 2, as published by the Free Software Foundation.
> > +
> > + This program is distributed in the hope it will be useful, but WITHOUT
> > + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> > + more details.
> > +
> > + You should have received a copy of the GNU General Public License along with
> > + this program; if not, write to the Free Software Foundation, Inc.,
> > + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> > +
> > + The full GNU General Public License is included in this distribution in
> > + the file called "COPYING".
> > +
> > +*******************************************************************************/
> > +
> > +#ifndef _LLDP_VDP_CLIF_H
> > +#define _LLDP_VDP_CLIF_H
> > +
> > +struct lldp_module *vdp_cli_register(void);
> > +void vdp_cli_unregister(struct lldp_module *);
> > +int vdp_print_tlv(u32, u16, char *);
> > +
> > +#define VDP_BUF_SIZE 256
> > +
> > +#define VDP_PREFIX "vdp"
> > +#define ARG_VDP_MODE "mode"
> > +#define ARG_VDP_ROLE "role"
> > +
> > +#endif
> > diff --git a/include/lldp_vdp_cmds.h b/include/lldp_vdp_cmds.h
> > new file mode 100644
> > index 0000000..5e64c27
> > --- /dev/null
> > +++ b/include/lldp_vdp_cmds.h
> > @@ -0,0 +1,44 @@
> > +/*******************************************************************************
> > +
> > + implementation of VDP according to IEEE 802.1Qbg
> > + (c) Copyright IBM Corp. 2010
> > +
> > + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> > +
> > + This program is free software; you can redistribute it and/or modify it
> > + under the terms and conditions of the GNU General Public License,
> > + version 2, as published by the Free Software Foundation.
> > +
> > + This program is distributed in the hope it will be useful, but WITHOUT
> > + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> > + more details.
> > +
> > + You should have received a copy of the GNU General Public License along with
> > + this program; if not, write to the Free Software Foundation, Inc.,
> > + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> > +
> > + The full GNU General Public License is included in this distribution in
> > + the file called "COPYING".
> > +
> > +*******************************************************************************/
> > +
> > +#ifndef _LLDP_VDP_CMDS_H
> > +#define _LLDP_VDP_CMDS_H
> > +
> > +struct arg_handlers *vdp_get_arg_handlers();
> > +
> > +enum {
> > + MODE = 0,
> > + MGRID,
> > + TYPEID,
> > + TYPEIDVERSION,
> > + INSTANCEID,
> > + MAC,
> > + VLAN,
> > +};
> > +
> > +#define VAL_STATION "station"
> > +#define VAL_BRIDGE "bridge"
> > +
> > +#endif
> > diff --git a/lldp_vdp_clif.c b/lldp_vdp_clif.c
> > new file mode 100644
> > index 0000000..aa357e9
> > --- /dev/null
> > +++ b/lldp_vdp_clif.c
> > @@ -0,0 +1,136 @@
> > +/*******************************************************************************
> > +
> > + implementation of VDP according to IEEE 802.1Qbg
> > + (c) Copyright IBM Corp. 2010
> > +
> > + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> > +
> > + This program is free software; you can redistribute it and/or modify it
> > + under the terms and conditions of the GNU General Public License,
> > + version 2, as published by the Free Software Foundation.
> > +
> > + This program is distributed in the hope it will be useful, but WITHOUT
> > + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> > + more details.
> > +
> > + You should have received a copy of the GNU General Public License along with
> > + this program; if not, write to the Free Software Foundation, Inc.,
> > + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> > +
> > + The full GNU General Public License is included in this distribution in
> > + the file called "COPYING".
> > +
> > +*******************************************************************************/
> > +
> > +#include "includes.h"
> > +#include "common.h"
> > +#include <stdio.h>
> > +#include <syslog.h>
> > +#include <sys/un.h>
> > +#include <sys/stat.h>
> > +#include "lldp_mod.h"
> > +#include "lldptool.h"
> > +#include "lldp.h"
> > +#include "lldp_vdp.h"
> > +#include "lldp_vdp_clif.h"
> > +
> > +void vdp_print_cfg_tlv(u16, char *info);
> > +int vdp_print_help();
> > +
> > +u32 vdp_lookup_tlv_name(char *tlvid_str);
> > +
>
> snip
>
> > +
> > +static int get_arg_mode(struct cmd *cmd, char *arg, char *argvalue,
> > + char *obuf)
> > +{
> > + char *s, *t;
> > + struct vsi_profile *np;
> > + struct vdp_data *vd;
> > +
> > + if (cmd->cmd != cmd_gettlv)
> > + return cmd_invalid;
> > +
> > + switch (cmd->tlvid) {
> > + case ((LLDP_MOD_VDP) << 8) | LLDP_VDP_SUBTYPE:
> > + break;
> > + case INVALID_TLVID:
> > + return cmd_invalid;
> > + default:
> > + return cmd_not_applicable;
> > + }
> > +
> > + s = t = malloc(VDP_BUF_SIZE);
>
> memory leak on s or maybe I missed something.
>
> > + if (!s)
> > + return cmd_invalid;
> > + memset(s, 0, VDP_BUF_SIZE);
> > +
> > + vd = vdp_data(cmd->ifname);
> > + if (!vd) {
> > + printf("%s(%i): vdp_data for %s not found !\n", __func__, __LINE__,
> > + cmd->ifname);
> > + return cmd_invalid;
> > + }
> > +
> > + LIST_FOREACH(np, &vd->profile_head, profile) {
> > + PRINT_PROFILE(t, np);
> > + }
> > +
> > + sprintf(obuf, "%02x%s%04x%s", (unsigned int) strlen(arg), arg,
> > + (unsigned int) strlen(s), s);
> > +
> > + return cmd_success;
> > +}
> > +
>
> Thanks,
> John.
>
Will be fixed in my next posting of the series.
Thanks !
Jens
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply
* Re: PROBLEM: [BISECTED] 2.6.35.5 xen domU panics just after the boot
From: Paweł Zuzelski @ 2010-09-24 5:40 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Jeremy Fitzhardinge, Paweł Zuzelski, James Dingwall, lkml,
virtualization, xen-devel
In-Reply-To: <4C9BEA8C.2030808@goop.org>
On Thu, 23 Sep 2010, Jeremy Fitzhardinge wrote:
> On 09/21/2010 12:05 PM, Paweł Zuzelski wrote:
> > Hello,
> >
> > kernels 2.6.35.5 and 2.6.32.22 xen domU panics at the very begining of the
> > boot process.
> >
> > I have bisected it to a single commit, and the first bad commit is:
> > [fb412a178502dc498430723b082a932f797e4763] xen: use percpu interrupts for IPIs and VIRQs
> >
> > kernel v2.6.35.5 with reverted this commit works for me.
>
> Thanks very much for doing that. I'll have to work out what's going on
> (obviously it doesn't do it for me).
Have you seen the message from James Dingwall?
He had found the typo in fb412a178502dc498430723b082a932f797e4763
commit and sent the patch to lkml that fixes it.
Please, see https://patchwork.kernel.org/patch/202282/ if you have
not received James' mail. That patch resolves the problem for me and
for James.
--
Regards,
Paweł Zuzelski
^ permalink raw reply
* RE: PROBLEM: [BISECTED] 2.6.35.5 xen domU panics just after the boot
From: Dan Magenheimer @ 2010-09-24 2:13 UTC (permalink / raw)
To: Jeremy Fitzhardinge, Paweł Zuzelski
Cc: virtualization, Jeremy Fitzhardinge, xen-devel, lkml
In-Reply-To: <4C9BEA8C.2030808@goop.org>
Jeremy --
FYI, I think I've also seen this problem, or something similar,
but ONLY on a Nehalem box (and only intermittently), not on my
Core 2 Duo boxen. The
Nehalem box is an SDP so I had assumed that it was something
to do with that, but maybe not. Maybe some feature is
"leaking through" to the guest. Hyperthreading? MSI? EPT?
Anyway, if you have a newer box, you might try reproducing
on that, rather than your usual development box (which IIRC
was a Core 2 Duo laptop?)
> -----Original Message-----
> From: Jeremy Fitzhardinge [mailto:jeremy@goop.org]
> Sent: Thursday, September 23, 2010 6:02 PM
> To: Pawel Zuzelski
> Cc: virtualization@lists.osdl.org; Jeremy Fitzhardinge; xen-
> devel@lists.xensource.com; lkml
> Subject: Re: [Xen-devel] PROBLEM: [BISECTED] 2.6.35.5 xen domU panics
> just after the boot
>
> On 09/21/2010 12:05 PM, Paweł Zuzelski wrote:
> > Hello,
> >
> > kernels 2.6.35.5 and 2.6.32.22 xen domU panics at the very begining
> of the
> > boot process.
> >
> > I have bisected it to a single commit, and the first bad commit is:
> > [fb412a178502dc498430723b082a932f797e4763] xen: use percpu interrupts
> for IPIs and VIRQs
> >
> > kernel v2.6.35.5 with reverted this commit works for me.
>
> Thanks very much for doing that. I'll have to work out what's going on
> (obviously it doesn't do it for me).
>
> J
>
> > Here are the kernel configs I was using:
> > http://carme.pld-linux.org/~pawelz/kernel-2.6.35.5-domU-config
> > http://carme.pld-linux.org/~pawelz/kernel-2.6.32.22-domU-config
> > As you can see they are stripped down configs, intended to run in
> domU only.
> >
> > I was testing it with the very simple domU configuration:
> >
> > kernel = '/srv/xen/bzImage'
> > memory = '128'
> > vcpus = 2
> > name = 'test'
> > on_poweroff = 'destroy'
> > on_reboot = 'restart'
> > on_crash = 'restart'
> >
> > Here is the full output of kernel 2.6.35.5:
> >
> > Using config file "/etc/xen/test".
> > Started domain test
> > [ 0.000000] Policy zone: DMA32
> > [ 0.000000] Kernel command line:
> > [ 0.000000] PID hash table entries: 512 (order: 0, 4096 bytes)
> > [ 0.000000] Subtract (33 early reservations)
> > [ 0.000000] #1 [0001976000 - 0001987000] XEN PAGETABLES
> > [ 0.000000] #2 [0001000000 - 00019125f8] TEXT DATA BSS
> > [ 0.000000] #3 [0001933000 - 0001976000] XEN START INFO
> > [ 0.000000] #4 [0000010000 - 0000012000] TRAMPOLINE
> > [ 0.000000] #5 [0000012000 - 0000040000] PGTABLE
> > [ 0.000000] #6 [0001912600 - 0001917600] NODE_DATA
> > [ 0.000000] #7 [0001917600 - 0001918600] BOOTMEM
> > [ 0.000000] #8 [0001918600 - 0001918618] BOOTMEM
> > [ 0.000000] #9 [0001919000 - 000191a000] BOOTMEM
> > [ 0.000000] #10 [000191a000 - 000191b000] BOOTMEM
> > [ 0.000000] #11 [000191b000 - 000191c000] BOOTMEM
> > [ 0.000000] #12 [0002200000 - 00023c0000] MEMMAP 0
> > [ 0.000000] #13 [0001918640 - 00019187c0] BOOTMEM
> > [ 0.000000] #14 [000191c000 - 000191cc00] BOOTMEM
> > [ 0.000000] #15 [000191d000 - 000191e000] BOOTMEM
> > [ 0.000000] #16 [000191e000 - 000191f000] BOOTMEM
> > [ 0.000000] #17 [000191f000 - 0001920000] BOOTMEM
> > [ 0.000000] #18 [00019187c0 - 00019188a0] BOOTMEM
> > [ 0.000000] #19 [00019188c0 - 0001918928] BOOTMEM
> > [ 0.000000] #20 [0001918940 - 00019189a8] BOOTMEM
> > [ 0.000000] #21 [00019189c0 - 0001918a28] BOOTMEM
> > [ 0.000000] #22 [0001918a40 - 0001918a41] BOOTMEM
> > [ 0.000000] #23 [0001918a80 - 0001918a81] BOOTMEM
> > [ 0.000000] #24 [0001987000 - 00019c1000] BOOTMEM
> > [ 0.000000] #25 [0001918ac0 - 0001918ac8] BOOTMEM
> > [ 0.000000] #26 [0001918b00 - 0001918b08] BOOTMEM
> > [ 0.000000] #27 [0001918b40 - 0001918b48] BOOTMEM
> > [ 0.000000] #28 [0001918b80 - 0001918b90] BOOTMEM
> > [ 0.000000] #29 [0001918bc0 - 0001918cc0] BOOTMEM
> > [ 0.000000] #30 [0001918cc0 - 0001918d08] BOOTMEM
> > [ 0.000000] #31 [0001918d40 - 0001918d88] BOOTMEM
> > [ 0.000000] #32 [0001920000 - 0001921000] BOOTMEM
> > [ 0.000000] Memory: 118724k/131072k available (3327k kernel code,
> 448k absent, 11900k reserved, 3931k data, 440k init)
> > [ 0.000000] SLUB: Genslabs=14, HWalign=64, Order=0-3,
> MinObjects=0, CPUs=2, Nodes=1
> > [ 0.000000] Hierarchical RCU implementation.
> > [ 0.000000] RCU-based detection of stalled CPUs is disabled.
> > [ 0.000000] Verbose stalled-CPUs detection is disabled.
> > [ 0.000000] NR_IRQS:2304
> > [ 0.000000] Console: colour dummy device 80x25
> > [ 0.000000] console [tty0] enabled
> > [ 0.000000] console [hvc0] enabled
> > [ 0.000000] installing Xen timer for CPU 0
> > [ 0.000000] BUG: unable to handle kernel NULL pointer dereference
> at (null)
> > [ 0.000000] IP: [<(null)>] (null)
> > [ 0.000000] PGD 0
> > [ 0.000000] Oops: 0010 [#1] SMP
> > [ 0.000000] last sysfs file:
> > [ 0.000000] CPU 0
> > [ 0.000000] Modules linked in:
> > [ 0.000000]
> > [ 0.000000] Pid: 0, comm: swapper Not tainted 2.6.35.5 #1 /
> > [ 0.000000] RIP: e030:[<0000000000000000>] [<(null)>] (null)
> > [ 0.000000] RSP: e02b:ffffffff81601d70 EFLAGS: 00010082
> > [ 0.000000] RAX: ffffffff818fdb50 RBX: 0000000000000000 RCX:
> 0000000000000000
> > [ 0.000000] RDX: 0000000000000000 RSI: ffffffff818c7958 RDI:
> 0000000000000000
> > [ 0.000000] RBP: ffffffff81601d88 R08: ffffea00001b22d8 R09:
> 000000000000001a
> > [ 0.000000] R10: 0000000000000000 R11: 0000000000006477 R12:
> ffffffff81623280
> > [ 0.000000] R13: 0000000000000000 R14: 00000000ffffffea R15:
> 0000000000000000
> > [ 0.000000] FS: 0000000000000000(0000) GS:ffff880001987000(0000)
> knlGS:0000000000000000
> > [ 0.000000] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b
> > [ 0.000000] CR2: 0000000000000000 CR3: 00000000016b9000 CR4:
> 0000000000002620
> > [ 0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
> 0000000000000000
> > [ 0.000000] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7:
> 0000000000000400
> > [ 0.000000] Process swapper (pid: 0, threadinfo ffffffff81600000,
> task ffffffff816c1020)
> > [ 0.000000] Stack:
> > [ 0.000000] ffffffff8107c849 0000000000000000 ffff880007c0d000
> ffffffff81601da8
> > [ 0.000000] <0> ffffffff8107c829 ffffffff8133d3fb ffffffff81623280
> ffffffff81601df8
> > [ 0.000000] <0> ffffffff8107c033 ffffffff816202e4 ffffffff816232e4
> ffffffff8100572f
> > [ 0.000000] Call Trace:
> > [ 0.000000] [<ffffffff8107c849>] ? default_enable+0x1a/0x28
> > [ 0.000000] [<ffffffff8107c829>] default_startup+0x19/0x1f
> > [ 0.000000] [<ffffffff8133d3fb>] ?
> _raw_spin_lock_irqsave+0xd/0x24
> > [ 0.000000] [<ffffffff8107c033>] __setup_irq+0x1ab/0x2d8
> > [ 0.000000] [<ffffffff8100572f>] ?
> xen_restore_fl_direct_end+0x0/0x1
> > [ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
> > [ 0.000000] [<ffffffff8107c278>] request_threaded_irq+0x118/0x146
> > [ 0.000000] [<ffffffff8125dda5>]
> bind_virq_to_irqhandler+0x146/0x168
> > [ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
> > [ 0.000000] [<ffffffff810055ee>] xen_setup_timer+0x59/0x9d
> > [ 0.000000] [<ffffffff81731b68>] xen_time_init+0x7b/0x89
> > [ 0.000000] [<ffffffff81731ead>] x86_late_time_init+0xa/0x11
> > [ 0.000000] [<ffffffff8172eb49>] start_kernel+0x30b/0x38d
> > [ 0.000000] [<ffffffff8172e2c6>]
> x86_64_start_reservations+0xb1/0xb5
> > [ 0.000000] [<ffffffff817313e8>] xen_start_kernel+0x508/0x50f
> > [ 0.000000] Code: Bad RIP value.
> > [ 0.000000] RIP [<(null)>] (null)
> > [ 0.000000] RSP <ffffffff81601d70>
> > [ 0.000000] CR2: 0000000000000000
> > [ 0.000000] ---[ end trace 4eaa2a86a8e2da22 ]---
> > [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle
> task!
> > [ 0.000000] Pid: 0, comm: swapper Tainted: G D 2.6.35.5
> #1
> > [ 0.000000] Call Trace:
> > [ 0.000000] [<ffffffff8133bae9>] panic+0x86/0xfa
> > [ 0.000000] [<ffffffff8103c5c6>] do_exit+0x6d/0x77e
> > [ 0.000000] [<ffffffff8133d43f>] ?
> _raw_spin_unlock_irqrestore+0x11/0x13
> > [ 0.000000] [<ffffffff8103ac55>] ? kmsg_dump+0x11e/0x139
> > [ 0.000000] [<ffffffff8100b936>] oops_end+0x8f/0x94
> > [ 0.000000] [<ffffffff810239cc>] no_context+0x1f4/0x203
> > [ 0.000000] [<ffffffff81023b65>]
> __bad_area_nosemaphore+0x18a/0x1ad
> > [ 0.000000] [<ffffffff81023b96>] bad_area_nosemaphore+0xe/0x10
> > [ 0.000000] [<ffffffff81023f10>] do_page_fault+0x115/0x229
> > [ 0.000000] [<ffffffff8133daf5>] page_fault+0x25/0x30
> > [ 0.000000] [<ffffffff8107c849>] ? default_enable+0x1a/0x28
> > [ 0.000000] [<ffffffff8107c829>] default_startup+0x19/0x1f
> > [ 0.000000] [<ffffffff8133d3fb>] ?
> _raw_spin_lock_irqsave+0xd/0x24
> > [ 0.000000] [<ffffffff8107c033>] __setup_irq+0x1ab/0x2d8
> > [ 0.000000] [<ffffffff8100572f>] ?
> xen_restore_fl_direct_end+0x0/0x1
> > [ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
> > [ 0.000000] [<ffffffff8107c278>] request_threaded_irq+0x118/0x146
> > [ 0.000000] [<ffffffff8125dda5>]
> bind_virq_to_irqhandler+0x146/0x168
> > [ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
> > [ 0.000000] [<ffffffff810055ee>] xen_setup_timer+0x59/0x9d
> > [ 0.000000] [<ffffffff81731b68>] xen_time_init+0x7b/0x89
> > [ 0.000000] [<ffffffff81731ead>] x86_late_time_init+0xa/0x11
> > [ 0.000000] [<ffffffff8172eb49>] start_kernel+0x30b/0x38d
> > [ 0.000000] [<ffffffff8172e2c6>]
> x86_64_start_reservations+0xb1/0xb5
> > [ 0.000000] [<ffffffff817313e8>] xen_start_kernel+0x508/0x50f
> >
> > Additional info:
> > arch: x86_64
> > cpu: Intel(R) Xeon(R) CPU E5345 @ 2.33GHz
> > xen: 3.2.1
> > dom0: Linux version 2.6.26-2-xen-amd64 (Debian 2.6.26-24lenny1)
> > (dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease)
> > (Debian 4.1.2-25)) #1 SMP Thu Aug 19 01:12:45 UTC 2010
> >
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply
* Re: [Xen-devel] PROBLEM: [BISECTED] 2.6.35.5 xen domU panics just after the boot
From: Jeremy Fitzhardinge @ 2010-09-24 0:02 UTC (permalink / raw)
To: Paweł Zuzelski; +Cc: Jeremy Fitzhardinge, virtualization, xen-devel, lkml
In-Reply-To: <20100921190525.GD4573@davabel.touk.pl>
On 09/21/2010 12:05 PM, Paweł Zuzelski wrote:
> Hello,
>
> kernels 2.6.35.5 and 2.6.32.22 xen domU panics at the very begining of the
> boot process.
>
> I have bisected it to a single commit, and the first bad commit is:
> [fb412a178502dc498430723b082a932f797e4763] xen: use percpu interrupts for IPIs and VIRQs
>
> kernel v2.6.35.5 with reverted this commit works for me.
Thanks very much for doing that. I'll have to work out what's going on
(obviously it doesn't do it for me).
J
> Here are the kernel configs I was using:
> http://carme.pld-linux.org/~pawelz/kernel-2.6.35.5-domU-config
> http://carme.pld-linux.org/~pawelz/kernel-2.6.32.22-domU-config
> As you can see they are stripped down configs, intended to run in domU only.
>
> I was testing it with the very simple domU configuration:
>
> kernel = '/srv/xen/bzImage'
> memory = '128'
> vcpus = 2
> name = 'test'
> on_poweroff = 'destroy'
> on_reboot = 'restart'
> on_crash = 'restart'
>
> Here is the full output of kernel 2.6.35.5:
>
> Using config file "/etc/xen/test".
> Started domain test
> [ 0.000000] Policy zone: DMA32
> [ 0.000000] Kernel command line:
> [ 0.000000] PID hash table entries: 512 (order: 0, 4096 bytes)
> [ 0.000000] Subtract (33 early reservations)
> [ 0.000000] #1 [0001976000 - 0001987000] XEN PAGETABLES
> [ 0.000000] #2 [0001000000 - 00019125f8] TEXT DATA BSS
> [ 0.000000] #3 [0001933000 - 0001976000] XEN START INFO
> [ 0.000000] #4 [0000010000 - 0000012000] TRAMPOLINE
> [ 0.000000] #5 [0000012000 - 0000040000] PGTABLE
> [ 0.000000] #6 [0001912600 - 0001917600] NODE_DATA
> [ 0.000000] #7 [0001917600 - 0001918600] BOOTMEM
> [ 0.000000] #8 [0001918600 - 0001918618] BOOTMEM
> [ 0.000000] #9 [0001919000 - 000191a000] BOOTMEM
> [ 0.000000] #10 [000191a000 - 000191b000] BOOTMEM
> [ 0.000000] #11 [000191b000 - 000191c000] BOOTMEM
> [ 0.000000] #12 [0002200000 - 00023c0000] MEMMAP 0
> [ 0.000000] #13 [0001918640 - 00019187c0] BOOTMEM
> [ 0.000000] #14 [000191c000 - 000191cc00] BOOTMEM
> [ 0.000000] #15 [000191d000 - 000191e000] BOOTMEM
> [ 0.000000] #16 [000191e000 - 000191f000] BOOTMEM
> [ 0.000000] #17 [000191f000 - 0001920000] BOOTMEM
> [ 0.000000] #18 [00019187c0 - 00019188a0] BOOTMEM
> [ 0.000000] #19 [00019188c0 - 0001918928] BOOTMEM
> [ 0.000000] #20 [0001918940 - 00019189a8] BOOTMEM
> [ 0.000000] #21 [00019189c0 - 0001918a28] BOOTMEM
> [ 0.000000] #22 [0001918a40 - 0001918a41] BOOTMEM
> [ 0.000000] #23 [0001918a80 - 0001918a81] BOOTMEM
> [ 0.000000] #24 [0001987000 - 00019c1000] BOOTMEM
> [ 0.000000] #25 [0001918ac0 - 0001918ac8] BOOTMEM
> [ 0.000000] #26 [0001918b00 - 0001918b08] BOOTMEM
> [ 0.000000] #27 [0001918b40 - 0001918b48] BOOTMEM
> [ 0.000000] #28 [0001918b80 - 0001918b90] BOOTMEM
> [ 0.000000] #29 [0001918bc0 - 0001918cc0] BOOTMEM
> [ 0.000000] #30 [0001918cc0 - 0001918d08] BOOTMEM
> [ 0.000000] #31 [0001918d40 - 0001918d88] BOOTMEM
> [ 0.000000] #32 [0001920000 - 0001921000] BOOTMEM
> [ 0.000000] Memory: 118724k/131072k available (3327k kernel code, 448k absent, 11900k reserved, 3931k data, 440k init)
> [ 0.000000] SLUB: Genslabs=14, HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
> [ 0.000000] Hierarchical RCU implementation.
> [ 0.000000] RCU-based detection of stalled CPUs is disabled.
> [ 0.000000] Verbose stalled-CPUs detection is disabled.
> [ 0.000000] NR_IRQS:2304
> [ 0.000000] Console: colour dummy device 80x25
> [ 0.000000] console [tty0] enabled
> [ 0.000000] console [hvc0] enabled
> [ 0.000000] installing Xen timer for CPU 0
> [ 0.000000] BUG: unable to handle kernel NULL pointer dereference at (null)
> [ 0.000000] IP: [<(null)>] (null)
> [ 0.000000] PGD 0
> [ 0.000000] Oops: 0010 [#1] SMP
> [ 0.000000] last sysfs file:
> [ 0.000000] CPU 0
> [ 0.000000] Modules linked in:
> [ 0.000000]
> [ 0.000000] Pid: 0, comm: swapper Not tainted 2.6.35.5 #1 /
> [ 0.000000] RIP: e030:[<0000000000000000>] [<(null)>] (null)
> [ 0.000000] RSP: e02b:ffffffff81601d70 EFLAGS: 00010082
> [ 0.000000] RAX: ffffffff818fdb50 RBX: 0000000000000000 RCX: 0000000000000000
> [ 0.000000] RDX: 0000000000000000 RSI: ffffffff818c7958 RDI: 0000000000000000
> [ 0.000000] RBP: ffffffff81601d88 R08: ffffea00001b22d8 R09: 000000000000001a
> [ 0.000000] R10: 0000000000000000 R11: 0000000000006477 R12: ffffffff81623280
> [ 0.000000] R13: 0000000000000000 R14: 00000000ffffffea R15: 0000000000000000
> [ 0.000000] FS: 0000000000000000(0000) GS:ffff880001987000(0000) knlGS:0000000000000000
> [ 0.000000] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b
> [ 0.000000] CR2: 0000000000000000 CR3: 00000000016b9000 CR4: 0000000000002620
> [ 0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [ 0.000000] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
> [ 0.000000] Process swapper (pid: 0, threadinfo ffffffff81600000, task ffffffff816c1020)
> [ 0.000000] Stack:
> [ 0.000000] ffffffff8107c849 0000000000000000 ffff880007c0d000 ffffffff81601da8
> [ 0.000000] <0> ffffffff8107c829 ffffffff8133d3fb ffffffff81623280 ffffffff81601df8
> [ 0.000000] <0> ffffffff8107c033 ffffffff816202e4 ffffffff816232e4 ffffffff8100572f
> [ 0.000000] Call Trace:
> [ 0.000000] [<ffffffff8107c849>] ? default_enable+0x1a/0x28
> [ 0.000000] [<ffffffff8107c829>] default_startup+0x19/0x1f
> [ 0.000000] [<ffffffff8133d3fb>] ? _raw_spin_lock_irqsave+0xd/0x24
> [ 0.000000] [<ffffffff8107c033>] __setup_irq+0x1ab/0x2d8
> [ 0.000000] [<ffffffff8100572f>] ? xen_restore_fl_direct_end+0x0/0x1
> [ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
> [ 0.000000] [<ffffffff8107c278>] request_threaded_irq+0x118/0x146
> [ 0.000000] [<ffffffff8125dda5>] bind_virq_to_irqhandler+0x146/0x168
> [ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
> [ 0.000000] [<ffffffff810055ee>] xen_setup_timer+0x59/0x9d
> [ 0.000000] [<ffffffff81731b68>] xen_time_init+0x7b/0x89
> [ 0.000000] [<ffffffff81731ead>] x86_late_time_init+0xa/0x11
> [ 0.000000] [<ffffffff8172eb49>] start_kernel+0x30b/0x38d
> [ 0.000000] [<ffffffff8172e2c6>] x86_64_start_reservations+0xb1/0xb5
> [ 0.000000] [<ffffffff817313e8>] xen_start_kernel+0x508/0x50f
> [ 0.000000] Code: Bad RIP value.
> [ 0.000000] RIP [<(null)>] (null)
> [ 0.000000] RSP <ffffffff81601d70>
> [ 0.000000] CR2: 0000000000000000
> [ 0.000000] ---[ end trace 4eaa2a86a8e2da22 ]---
> [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
> [ 0.000000] Pid: 0, comm: swapper Tainted: G D 2.6.35.5 #1
> [ 0.000000] Call Trace:
> [ 0.000000] [<ffffffff8133bae9>] panic+0x86/0xfa
> [ 0.000000] [<ffffffff8103c5c6>] do_exit+0x6d/0x77e
> [ 0.000000] [<ffffffff8133d43f>] ? _raw_spin_unlock_irqrestore+0x11/0x13
> [ 0.000000] [<ffffffff8103ac55>] ? kmsg_dump+0x11e/0x139
> [ 0.000000] [<ffffffff8100b936>] oops_end+0x8f/0x94
> [ 0.000000] [<ffffffff810239cc>] no_context+0x1f4/0x203
> [ 0.000000] [<ffffffff81023b65>] __bad_area_nosemaphore+0x18a/0x1ad
> [ 0.000000] [<ffffffff81023b96>] bad_area_nosemaphore+0xe/0x10
> [ 0.000000] [<ffffffff81023f10>] do_page_fault+0x115/0x229
> [ 0.000000] [<ffffffff8133daf5>] page_fault+0x25/0x30
> [ 0.000000] [<ffffffff8107c849>] ? default_enable+0x1a/0x28
> [ 0.000000] [<ffffffff8107c829>] default_startup+0x19/0x1f
> [ 0.000000] [<ffffffff8133d3fb>] ? _raw_spin_lock_irqsave+0xd/0x24
> [ 0.000000] [<ffffffff8107c033>] __setup_irq+0x1ab/0x2d8
> [ 0.000000] [<ffffffff8100572f>] ? xen_restore_fl_direct_end+0x0/0x1
> [ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
> [ 0.000000] [<ffffffff8107c278>] request_threaded_irq+0x118/0x146
> [ 0.000000] [<ffffffff8125dda5>] bind_virq_to_irqhandler+0x146/0x168
> [ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
> [ 0.000000] [<ffffffff810055ee>] xen_setup_timer+0x59/0x9d
> [ 0.000000] [<ffffffff81731b68>] xen_time_init+0x7b/0x89
> [ 0.000000] [<ffffffff81731ead>] x86_late_time_init+0xa/0x11
> [ 0.000000] [<ffffffff8172eb49>] start_kernel+0x30b/0x38d
> [ 0.000000] [<ffffffff8172e2c6>] x86_64_start_reservations+0xb1/0xb5
> [ 0.000000] [<ffffffff817313e8>] xen_start_kernel+0x508/0x50f
>
> Additional info:
> arch: x86_64
> cpu: Intel(R) Xeon(R) CPU E5345 @ 2.33GHz
> xen: 3.2.1
> dom0: Linux version 2.6.26-2-xen-amd64 (Debian 2.6.26-24lenny1)
> (dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease)
> (Debian 4.1.2-25)) #1 SMP Thu Aug 19 01:12:45 UTC 2010
>
^ permalink raw reply
* Re: [PATCH 1/1] Rename camel case variables in channel.c (updated)
From: Joe Perches @ 2010-09-23 22:38 UTC (permalink / raw)
To: Haiyang Zhang
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de'
In-Reply-To: <1FB5E1D5CA062146B38059374562DF7289ED89CF@TK5EX14MBXC130.redmond.corp.microsoft.com>
On Thu, 2010-09-23 at 22:04 +0000, Haiyang Zhang wrote:
> From: Haiyang Zhang <haiyangz@microsoft.com>
>
> Rename camel case variables in channel.c
[]
> -static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
> - struct vmbus_channel_msginfo **MsgInfo,
> - u32 *MessageCount)
> +static int VmbusChannelCreateGpadlHeader(void *kbuffer, u32 size,
> + struct vmbus_channel_msginfo **msginfo,
> + u32 *messagecount)
> {
> int i;
> - int pageCount;
> + int pagecount;
> unsigned long long pfn;
> - struct vmbus_channel_gpadl_header *gpaHeader;
> - struct vmbus_channel_gpadl_body *gpadlBody;
> - struct vmbus_channel_msginfo *msgHeader;
> - struct vmbus_channel_msginfo *msgBody = NULL;
> - u32 msgSize;
> + struct vmbus_channel_gpadl_header *gpal_header;
> + struct vmbus_channel_gpadl_body *gpadl_body;
> + struct vmbus_channel_msginfo *msgheader;
> + struct vmbus_channel_msginfo *msgbody = NULL;
> + u32 msgsize;
Why gpal_header and not gpadl_header?
I didn't read farther.
^ permalink raw reply
* [PATCH 1/1] Rename camel case variables in channel.c (updated)
From: Haiyang Zhang @ 2010-09-23 22:04 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
"'virtualization@lists.osdl.org'" <virtualiz>
From: Haiyang Zhang <haiyangz@microsoft.com>
Rename camel case variables in channel.c
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 733 +++++++++++++++++++++---------------------
1 files changed, 370 insertions(+), 363 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 37b7b4c..ceeadac 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -28,10 +28,10 @@
/* Internal routines */
static int VmbusChannelCreateGpadlHeader(
- void *Kbuffer, /* must be phys and virt contiguous */
- u32 Size, /* page-size multiple */
- struct vmbus_channel_msginfo **msgInfo,
- u32 *MessageCount);
+ void *kbuffer, /* must be phys and virt contiguous */
+ u32 size, /* page-size multiple */
+ struct vmbus_channel_msginfo **msginfo,
+ u32 *messagecount);
static void DumpVmbusChannel(struct vmbus_channel *channel);
static void VmbusChannelSetEvent(struct vmbus_channel *channel);
@@ -70,25 +70,25 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
* VmbusChannelSetEvent - Trigger an event notification on the specified
* channel.
*/
-static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
+static void VmbusChannelSetEvent(struct vmbus_channel *channel)
{
- struct hv_monitor_page *monitorPage;
+ struct hv_monitor_page *monitorpage;
- if (Channel->OfferMsg.MonitorAllocated) {
+ if (channel->OfferMsg.MonitorAllocated) {
/* Each u32 represents 32 channels */
- set_bit(Channel->OfferMsg.ChildRelId & 31,
+ set_bit(channel->OfferMsg.ChildRelId & 31,
(unsigned long *) gVmbusConnection.SendInterruptPage +
- (Channel->OfferMsg.ChildRelId >> 5));
+ (channel->OfferMsg.ChildRelId >> 5));
- monitorPage = gVmbusConnection.MonitorPages;
- monitorPage++; /* Get the child to parent monitor page */
+ monitorpage = gVmbusConnection.MonitorPages;
+ monitorpage++; /* Get the child to parent monitor page */
- set_bit(Channel->MonitorBit,
- (unsigned long *)&monitorPage->TriggerGroup
- [Channel->MonitorGroup].Pending);
+ set_bit(channel->MonitorBit,
+ (unsigned long *)&monitorpage->TriggerGroup
+ [channel->MonitorGroup].Pending);
} else {
- VmbusSetEvent(Channel->OfferMsg.ChildRelId);
+ VmbusSetEvent(channel->OfferMsg.ChildRelId);
}
}
@@ -117,54 +117,54 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
/*
* VmbusChannelGetDebugInfo -Retrieve various channel debug info
*/
-void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
- struct vmbus_channel_debug_info *DebugInfo)
+void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
+ struct vmbus_channel_debug_info *debuginfo)
{
- struct hv_monitor_page *monitorPage;
- u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32;
- u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32;
+ struct hv_monitor_page *monitorpage;
+ u8 monitor_group = (u8)channel->OfferMsg.MonitorId / 32;
+ u8 monitor_offset = (u8)channel->OfferMsg.MonitorId % 32;
/* u32 monitorBit = 1 << monitorOffset; */
- DebugInfo->RelId = Channel->OfferMsg.ChildRelId;
- DebugInfo->State = Channel->State;
- memcpy(&DebugInfo->InterfaceType,
- &Channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
- memcpy(&DebugInfo->InterfaceInstance,
- &Channel->OfferMsg.Offer.InterfaceInstance,
+ debuginfo->RelId = channel->OfferMsg.ChildRelId;
+ debuginfo->State = channel->State;
+ memcpy(&debuginfo->InterfaceType,
+ &channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
+ memcpy(&debuginfo->InterfaceInstance,
+ &channel->OfferMsg.Offer.InterfaceInstance,
sizeof(struct hv_guid));
- monitorPage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
+ monitorpage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
- DebugInfo->MonitorId = Channel->OfferMsg.MonitorId;
+ debuginfo->MonitorId = channel->OfferMsg.MonitorId;
- DebugInfo->ServerMonitorPending =
- monitorPage->TriggerGroup[monitorGroup].Pending;
- DebugInfo->ServerMonitorLatency =
- monitorPage->Latency[monitorGroup][monitorOffset];
- DebugInfo->ServerMonitorConnectionId =
- monitorPage->Parameter[monitorGroup]
- [monitorOffset].ConnectionId.u.Id;
+ debuginfo->ServerMonitorPending =
+ monitorpage->TriggerGroup[monitor_group].Pending;
+ debuginfo->ServerMonitorLatency =
+ monitorpage->Latency[monitor_group][monitor_offset];
+ debuginfo->ServerMonitorConnectionId =
+ monitorpage->Parameter[monitor_group]
+ [monitor_offset].ConnectionId.u.Id;
- monitorPage++;
+ monitorpage++;
- DebugInfo->ClientMonitorPending =
- monitorPage->TriggerGroup[monitorGroup].Pending;
- DebugInfo->ClientMonitorLatency =
- monitorPage->Latency[monitorGroup][monitorOffset];
- DebugInfo->ClientMonitorConnectionId =
- monitorPage->Parameter[monitorGroup]
- [monitorOffset].ConnectionId.u.Id;
+ debuginfo->ClientMonitorPending =
+ monitorpage->TriggerGroup[monitor_group].Pending;
+ debuginfo->ClientMonitorLatency =
+ monitorpage->Latency[monitor_group][monitor_offset];
+ debuginfo->ClientMonitorConnectionId =
+ monitorpage->Parameter[monitor_group]
+ [monitor_offset].ConnectionId.u.Id;
- RingBufferGetDebugInfo(&Channel->Inbound, &DebugInfo->Inbound);
- RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound);
+ RingBufferGetDebugInfo(&channel->Inbound, &debuginfo->Inbound);
+ RingBufferGetDebugInfo(&channel->Outbound, &debuginfo->Outbound);
}
/*
* VmbusChannelOpen - Open the specified channel.
*/
-int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
- u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
- void (*OnChannelCallback)(void *context), void *Context)
+int VmbusChannelOpen(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
+ u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
+ void (*onchannelcallback)(void *context), void *context)
{
struct vmbus_channel_open_channel *openMsg;
struct vmbus_channel_msginfo *openInfo = NULL;
@@ -176,30 +176,30 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
/* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
/* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */
- NewChannel->OnChannelCallback = OnChannelCallback;
- NewChannel->ChannelCallbackContext = Context;
+ newchannel->OnChannelCallback = onchannelcallback;
+ newchannel->ChannelCallbackContext = context;
/* Allocate the ring buffer */
- out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize)
+ out = osd_PageAlloc((send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
if (!out)
return -ENOMEM;
/* ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0); */
- in = (void *)((unsigned long)out + SendRingBufferSize);
+ in = (void *)((unsigned long)out + send_ringbuffer_size);
- NewChannel->RingBufferPages = out;
- NewChannel->RingBufferPageCount = (SendRingBufferSize +
- RecvRingBufferSize) >> PAGE_SHIFT;
+ newchannel->RingBufferPages = out;
+ newchannel->RingBufferPageCount = (send_ringbuffer_size +
+ recv_ringbuffer_size) >> PAGE_SHIFT;
- ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
+ ret = RingBufferInit(&newchannel->Outbound, out, send_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
}
- ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
+ ret = RingBufferInit(&newchannel->Inbound, in, recv_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
@@ -208,15 +208,15 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
/* Establish the gpadl for the ring buffer */
DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
- NewChannel);
+ newchannel);
- NewChannel->RingBufferGpadlHandle = 0;
+ newchannel->RingBufferGpadlHandle = 0;
- ret = VmbusChannelEstablishGpadl(NewChannel,
- NewChannel->Outbound.RingBuffer,
- SendRingBufferSize +
- RecvRingBufferSize,
- &NewChannel->RingBufferGpadlHandle);
+ ret = VmbusChannelEstablishGpadl(newchannel,
+ newchannel->Outbound.RingBuffer,
+ send_ringbuffer_size +
+ recv_ringbuffer_size,
+ &newchannel->RingBufferGpadlHandle);
if (ret != 0) {
err = ret;
@@ -225,13 +225,13 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
DPRINT_DBG(VMBUS, "channel %p <relid %d gpadl 0x%x send ring %p "
"size %d recv ring %p size %d, downstreamoffset %d>",
- NewChannel, NewChannel->OfferMsg.ChildRelId,
- NewChannel->RingBufferGpadlHandle,
- NewChannel->Outbound.RingBuffer,
- NewChannel->Outbound.RingSize,
- NewChannel->Inbound.RingBuffer,
- NewChannel->Inbound.RingSize,
- SendRingBufferSize);
+ newchannel, newchannel->OfferMsg.ChildRelId,
+ newchannel->RingBufferGpadlHandle,
+ newchannel->Outbound.RingBuffer,
+ newchannel->Outbound.RingSize,
+ newchannel->Inbound.RingBuffer,
+ newchannel->Inbound.RingSize,
+ send_ringbuffer_size);
/* Create and init the channel open message */
openInfo = kmalloc(sizeof(*openInfo) +
@@ -250,20 +250,20 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
openMsg = (struct vmbus_channel_open_channel *)openInfo->Msg;
openMsg->Header.MessageType = ChannelMessageOpenChannel;
- openMsg->OpenId = NewChannel->OfferMsg.ChildRelId; /* FIXME */
- openMsg->ChildRelId = NewChannel->OfferMsg.ChildRelId;
- openMsg->RingBufferGpadlHandle = NewChannel->RingBufferGpadlHandle;
- openMsg->DownstreamRingBufferPageOffset = SendRingBufferSize >>
+ openMsg->OpenId = newchannel->OfferMsg.ChildRelId; /* FIXME */
+ openMsg->ChildRelId = newchannel->OfferMsg.ChildRelId;
+ openMsg->RingBufferGpadlHandle = newchannel->RingBufferGpadlHandle;
+ openMsg->DownstreamRingBufferPageOffset = send_ringbuffer_size >>
PAGE_SHIFT;
openMsg->ServerContextAreaGpadlHandle = 0; /* TODO */
- if (UserDataLen > MAX_USER_DEFINED_BYTES) {
+ if (userdatalen > MAX_USER_DEFINED_BYTES) {
err = -EINVAL;
goto errorout;
}
- if (UserDataLen)
- memcpy(openMsg->UserData, UserData, UserDataLen);
+ if (userdatalen)
+ memcpy(openMsg->UserData, userdata, userdatalen);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&openInfo->MsgListEntry,
@@ -283,10 +283,10 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
osd_WaitEventWait(openInfo->WaitEvent);
if (openInfo->Response.OpenResult.Status == 0)
- DPRINT_INFO(VMBUS, "channel <%p> open success!!", NewChannel);
+ DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
else
DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!",
- NewChannel, openInfo->Response.OpenResult.Status);
+ newchannel, openInfo->Response.OpenResult.Status);
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
@@ -298,9 +298,9 @@ Cleanup:
return 0;
errorout:
- RingBufferCleanup(&NewChannel->Outbound);
- RingBufferCleanup(&NewChannel->Inbound);
- osd_PageFree(out, (SendRingBufferSize + RecvRingBufferSize)
+ RingBufferCleanup(&newchannel->Outbound);
+ RingBufferCleanup(&newchannel->Inbound);
+ osd_PageFree(out, (send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
kfree(openInfo);
return err;
@@ -310,126 +310,127 @@ errorout:
* DumpGpadlBody - Dump the gpadl body message to the console for
* debugging purposes.
*/
-static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len)
+static void DumpGpadlBody(struct vmbus_channel_gpadl_body *gpadl, u32 len)
{
int i;
- int pfnCount;
+ int pfncount;
- pfnCount = (Len - sizeof(struct vmbus_channel_gpadl_body)) /
+ pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
sizeof(u64);
- DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", Len, pfnCount);
+ DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
- for (i = 0; i < pfnCount; i++)
+ for (i = 0; i < pfncount; i++)
DPRINT_DBG(VMBUS, "gpadl body - %d) pfn %llu",
- i, Gpadl->Pfn[i]);
+ i, gpadl->Pfn[i]);
}
/*
* DumpGpadlHeader - Dump the gpadl header message to the console for
* debugging purposes.
*/
-static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl)
+static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *gpadl)
{
int i, j;
- int pageCount;
+ int pagecount;
DPRINT_DBG(VMBUS,
"gpadl header - relid %d, range count %d, range buflen %d",
- Gpadl->ChildRelId, Gpadl->RangeCount, Gpadl->RangeBufLen);
- for (i = 0; i < Gpadl->RangeCount; i++) {
- pageCount = Gpadl->Range[i].ByteCount >> PAGE_SHIFT;
- pageCount = (pageCount > 26) ? 26 : pageCount;
+ gpadl->ChildRelId, gpadl->RangeCount, gpadl->RangeBufLen);
+ for (i = 0; i < gpadl->RangeCount; i++) {
+ pagecount = gpadl->Range[i].ByteCount >> PAGE_SHIFT;
+ pagecount = (pagecount > 26) ? 26 : pagecount;
DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
- "page count %d", i, Gpadl->Range[i].ByteCount,
- Gpadl->Range[i].ByteOffset, pageCount);
+ "page count %d", i, gpadl->Range[i].ByteCount,
+ gpadl->Range[i].ByteOffset, pagecount);
- for (j = 0; j < pageCount; j++)
+ for (j = 0; j < pagecount; j++)
DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
- Gpadl->Range[i].PfnArray[j]);
+ gpadl->Range[i].PfnArray[j]);
}
}
/*
* VmbusChannelCreateGpadlHeader - Creates a gpadl for the specified buffer
*/
-static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
- struct vmbus_channel_msginfo **MsgInfo,
- u32 *MessageCount)
+static int VmbusChannelCreateGpadlHeader(void *kbuffer, u32 size,
+ struct vmbus_channel_msginfo **msginfo,
+ u32 *messagecount)
{
int i;
- int pageCount;
+ int pagecount;
unsigned long long pfn;
- struct vmbus_channel_gpadl_header *gpaHeader;
- struct vmbus_channel_gpadl_body *gpadlBody;
- struct vmbus_channel_msginfo *msgHeader;
- struct vmbus_channel_msginfo *msgBody = NULL;
- u32 msgSize;
+ struct vmbus_channel_gpadl_header *gpal_header;
+ struct vmbus_channel_gpadl_body *gpadl_body;
+ struct vmbus_channel_msginfo *msgheader;
+ struct vmbus_channel_msginfo *msgbody = NULL;
+ u32 msgsize;
- int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize;
+ int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;
/* ASSERT((kbuffer & (PAGE_SIZE-1)) == 0); */
/* ASSERT((Size & (PAGE_SIZE-1)) == 0); */
- pageCount = Size >> PAGE_SHIFT;
- pfn = virt_to_phys(Kbuffer) >> PAGE_SHIFT;
+ pagecount = size >> PAGE_SHIFT;
+ pfn = virt_to_phys(kbuffer) >> PAGE_SHIFT;
/* do we need a gpadl body msg */
- pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+ pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
sizeof(struct vmbus_channel_gpadl_header) -
sizeof(struct gpa_range);
- pfnCount = pfnSize / sizeof(u64);
+ pfncount = pfnsize / sizeof(u64);
- if (pageCount > pfnCount) {
+ if (pagecount > pfncount) {
/* we need a gpadl body */
/* fill in the header */
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_header) +
- sizeof(struct gpa_range) + pfnCount * sizeof(u64);
- msgHeader = kzalloc(msgSize, GFP_KERNEL);
- if (!msgHeader)
+ sizeof(struct gpa_range) + pfncount * sizeof(u64);
+ msgheader = kzalloc(msgsize, GFP_KERNEL);
+ if (!msgheader)
goto nomem;
- INIT_LIST_HEAD(&msgHeader->SubMsgList);
- msgHeader->MessageSize = msgSize;
+ INIT_LIST_HEAD(&msgheader->SubMsgList);
+ msgheader->MessageSize = msgsize;
- gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
- gpaHeader->RangeCount = 1;
- gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
- pageCount * sizeof(u64);
- gpaHeader->Range[0].ByteOffset = 0;
- gpaHeader->Range[0].ByteCount = Size;
- for (i = 0; i < pfnCount; i++)
- gpaHeader->Range[0].PfnArray[i] = pfn+i;
- *MsgInfo = msgHeader;
- *MessageCount = 1;
+ gpal_header = (struct vmbus_channel_gpadl_header *)
+ msgheader->Msg;
+ gpal_header->RangeCount = 1;
+ gpal_header->RangeBufLen = sizeof(struct gpa_range) +
+ pagecount * sizeof(u64);
+ gpal_header->Range[0].ByteOffset = 0;
+ gpal_header->Range[0].ByteCount = size;
+ for (i = 0; i < pfncount; i++)
+ gpal_header->Range[0].PfnArray[i] = pfn+i;
+ *msginfo = msgheader;
+ *messagecount = 1;
- pfnSum = pfnCount;
- pfnLeft = pageCount - pfnCount;
+ pfnsum = pfncount;
+ pfnleft = pagecount - pfncount;
/* how many pfns can we fit */
- pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+ pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
sizeof(struct vmbus_channel_gpadl_body);
- pfnCount = pfnSize / sizeof(u64);
+ pfncount = pfnsize / sizeof(u64);
/* fill in the body */
- while (pfnLeft) {
- if (pfnLeft > pfnCount)
- pfnCurr = pfnCount;
+ while (pfnleft) {
+ if (pfnleft > pfncount)
+ pfncurr = pfncount;
else
- pfnCurr = pfnLeft;
+ pfncurr = pfnleft;
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_body) +
- pfnCurr * sizeof(u64);
- msgBody = kzalloc(msgSize, GFP_KERNEL);
+ pfncurr * sizeof(u64);
+ msgbody = kzalloc(msgsize, GFP_KERNEL);
/* FIXME: we probably need to more if this fails */
- if (!msgBody)
+ if (!msgbody)
goto nomem;
- msgBody->MessageSize = msgSize;
- (*MessageCount)++;
- gpadlBody =
- (struct vmbus_channel_gpadl_body *)msgBody->Msg;
+ msgbody->MessageSize = msgsize;
+ (*messagecount)++;
+ gpadl_body =
+ (struct vmbus_channel_gpadl_body *)msgbody->Msg;
/*
* FIXME:
@@ -437,42 +438,43 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
* be 64-bit
*/
/* gpadlBody->Gpadl = kbuffer; */
- for (i = 0; i < pfnCurr; i++)
- gpadlBody->Pfn[i] = pfn + pfnSum + i;
+ for (i = 0; i < pfncurr; i++)
+ gpadl_body->Pfn[i] = pfn + pfnsum + i;
/* add to msg header */
- list_add_tail(&msgBody->MsgListEntry,
- &msgHeader->SubMsgList);
- pfnSum += pfnCurr;
- pfnLeft -= pfnCurr;
+ list_add_tail(&msgbody->MsgListEntry,
+ &msgheader->SubMsgList);
+ pfnsum += pfncurr;
+ pfnleft -= pfncurr;
}
} else {
/* everything fits in a header */
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_header) +
- sizeof(struct gpa_range) + pageCount * sizeof(u64);
- msgHeader = kzalloc(msgSize, GFP_KERNEL);
- if (msgHeader == NULL)
+ sizeof(struct gpa_range) + pagecount * sizeof(u64);
+ msgheader = kzalloc(msgsize, GFP_KERNEL);
+ if (msgheader == NULL)
goto nomem;
- msgHeader->MessageSize = msgSize;
-
- gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
- gpaHeader->RangeCount = 1;
- gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
- pageCount * sizeof(u64);
- gpaHeader->Range[0].ByteOffset = 0;
- gpaHeader->Range[0].ByteCount = Size;
- for (i = 0; i < pageCount; i++)
- gpaHeader->Range[0].PfnArray[i] = pfn+i;
-
- *MsgInfo = msgHeader;
- *MessageCount = 1;
+ msgheader->MessageSize = msgsize;
+
+ gpal_header = (struct vmbus_channel_gpadl_header *)
+ msgheader->Msg;
+ gpal_header->RangeCount = 1;
+ gpal_header->RangeBufLen = sizeof(struct gpa_range) +
+ pagecount * sizeof(u64);
+ gpal_header->Range[0].ByteOffset = 0;
+ gpal_header->Range[0].ByteCount = size;
+ for (i = 0; i < pagecount; i++)
+ gpal_header->Range[0].PfnArray[i] = pfn+i;
+
+ *msginfo = msgheader;
+ *messagecount = 1;
}
return 0;
nomem:
- kfree(msgHeader);
- kfree(msgBody);
+ kfree(msgheader);
+ kfree(msgbody);
return -ENOMEM;
}
@@ -484,108 +486,109 @@ nomem:
* @Size: page-size multiple
* @GpadlHandle: some funky thing
*/
-int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
- u32 Size, u32 *GpadlHandle)
+int VmbusChannelEstablishGpadl(struct vmbus_channel *channel, void *kbuffer,
+ u32 size, u32 *gpadl_handle)
{
- struct vmbus_channel_gpadl_header *gpadlMsg;
- struct vmbus_channel_gpadl_body *gpadlBody;
+ struct vmbus_channel_gpadl_header *gpadlmsg;
+ struct vmbus_channel_gpadl_body *gpadl_body;
/* struct vmbus_channel_gpadl_created *gpadlCreated; */
- struct vmbus_channel_msginfo *msgInfo = NULL;
- struct vmbus_channel_msginfo *subMsgInfo;
- u32 msgCount;
+ struct vmbus_channel_msginfo *msginfo = NULL;
+ struct vmbus_channel_msginfo *submsginfo;
+ u32 msgcount;
struct list_head *curr;
- u32 nextGpadlHandle;
+ u32 next_gpadl_handle;
unsigned long flags;
int ret = 0;
- nextGpadlHandle = atomic_read(&gVmbusConnection.NextGpadlHandle);
+ next_gpadl_handle = atomic_read(&gVmbusConnection.NextGpadlHandle);
atomic_inc(&gVmbusConnection.NextGpadlHandle);
- ret = VmbusChannelCreateGpadlHeader(Kbuffer, Size, &msgInfo, &msgCount);
+ ret = VmbusChannelCreateGpadlHeader(kbuffer, size, &msginfo, &msgcount);
if (ret)
return ret;
- msgInfo->WaitEvent = osd_WaitEventCreate();
- if (!msgInfo->WaitEvent) {
+ msginfo->WaitEvent = osd_WaitEventCreate();
+ if (!msginfo->WaitEvent) {
ret = -ENOMEM;
goto Cleanup;
}
- gpadlMsg = (struct vmbus_channel_gpadl_header *)msgInfo->Msg;
- gpadlMsg->Header.MessageType = ChannelMessageGpadlHeader;
- gpadlMsg->ChildRelId = Channel->OfferMsg.ChildRelId;
- gpadlMsg->Gpadl = nextGpadlHandle;
+ gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->Msg;
+ gpadlmsg->Header.MessageType = ChannelMessageGpadlHeader;
+ gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId;
+ gpadlmsg->Gpadl = next_gpadl_handle;
- DumpGpadlHeader(gpadlMsg);
+ DumpGpadlHeader(gpadlmsg);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&msgInfo->MsgListEntry,
+ list_add_tail(&msginfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
- Kbuffer, Size, msgCount);
+ kbuffer, size, msgcount);
DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
- msgInfo->MessageSize - sizeof(*msgInfo));
+ msginfo->MessageSize - sizeof(*msginfo));
- ret = VmbusPostMessage(gpadlMsg, msgInfo->MessageSize -
- sizeof(*msgInfo));
+ ret = VmbusPostMessage(gpadlmsg, msginfo->MessageSize -
+ sizeof(*msginfo));
if (ret != 0) {
DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
goto Cleanup;
}
- if (msgCount > 1) {
- list_for_each(curr, &msgInfo->SubMsgList) {
+ if (msgcount > 1) {
+ list_for_each(curr, &msginfo->SubMsgList) {
/* FIXME: should this use list_entry() instead ? */
- subMsgInfo = (struct vmbus_channel_msginfo *)curr;
- gpadlBody =
- (struct vmbus_channel_gpadl_body *)subMsgInfo->Msg;
+ submsginfo = (struct vmbus_channel_msginfo *)curr;
+ gpadl_body =
+ (struct vmbus_channel_gpadl_body *)submsginfo->Msg;
- gpadlBody->Header.MessageType = ChannelMessageGpadlBody;
- gpadlBody->Gpadl = nextGpadlHandle;
+ gpadl_body->Header.MessageType =
+ ChannelMessageGpadlBody;
+ gpadl_body->Gpadl = next_gpadl_handle;
DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd",
- subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
-
- DumpGpadlBody(gpadlBody, subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
- ret = VmbusPostMessage(gpadlBody,
- subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
+ submsginfo->MessageSize -
+ sizeof(*submsginfo));
+
+ DumpGpadlBody(gpadl_body, submsginfo->MessageSize -
+ sizeof(*submsginfo));
+ ret = VmbusPostMessage(gpadl_body,
+ submsginfo->MessageSize -
+ sizeof(*submsginfo));
if (ret != 0)
goto Cleanup;
}
}
- osd_WaitEventWait(msgInfo->WaitEvent);
+ osd_WaitEventWait(msginfo->WaitEvent);
/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created "
"(relid %d, status %d handle %x)",
- Channel->OfferMsg.ChildRelId,
- msgInfo->Response.GpadlCreated.CreationStatus,
- gpadlMsg->Gpadl);
+ channel->OfferMsg.ChildRelId,
+ msginfo->Response.GpadlCreated.CreationStatus,
+ gpadlmsg->Gpadl);
- *GpadlHandle = gpadlMsg->Gpadl;
+ *gpadl_handle = gpadlmsg->Gpadl;
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_del(&msgInfo->MsgListEntry);
+ list_del(&msginfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
- kfree(msgInfo->WaitEvent);
- kfree(msgInfo);
+ kfree(msginfo->WaitEvent);
+ kfree(msginfo);
return ret;
}
/*
* VmbusChannelTeardownGpadl -Teardown the specified GPADL handle
*/
-int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
+int VmbusChannelTeardownGpadl(struct vmbus_channel *channel, u32 gpadl_handle)
{
struct vmbus_channel_gpadl_teardown *msg;
struct vmbus_channel_msginfo *info;
@@ -608,8 +611,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
msg = (struct vmbus_channel_gpadl_teardown *)info->Msg;
msg->Header.MessageType = ChannelMessageGpadlTeardown;
- msg->ChildRelId = Channel->OfferMsg.ChildRelId;
- msg->Gpadl = GpadlHandle;
+ msg->ChildRelId = channel->OfferMsg.ChildRelId;
+ msg->Gpadl = gpadl_handle;
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&info->MsgListEntry,
@@ -638,7 +641,7 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
/*
* VmbusChannelClose - Close the specified channel
*/
-void VmbusChannelClose(struct vmbus_channel *Channel)
+void VmbusChannelClose(struct vmbus_channel *channel)
{
struct vmbus_channel_close_channel *msg;
struct vmbus_channel_msginfo *info;
@@ -646,8 +649,8 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
int ret;
/* Stop callback and cancel the timer asap */
- Channel->OnChannelCallback = NULL;
- del_timer_sync(&Channel->poll_timer);
+ channel->OnChannelCallback = NULL;
+ del_timer_sync(&channel->poll_timer);
/* Send a closing message */
info = kmalloc(sizeof(*info) +
@@ -661,7 +664,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
msg = (struct vmbus_channel_close_channel *)info->Msg;
msg->Header.MessageType = ChannelMessageCloseChannel;
- msg->ChildRelId = Channel->OfferMsg.ChildRelId;
+ msg->ChildRelId = channel->OfferMsg.ChildRelId;
ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
if (ret != 0) {
@@ -670,17 +673,17 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
}
/* Tear down the gpadl for the channel's ring buffer */
- if (Channel->RingBufferGpadlHandle)
- VmbusChannelTeardownGpadl(Channel,
- Channel->RingBufferGpadlHandle);
+ if (channel->RingBufferGpadlHandle)
+ VmbusChannelTeardownGpadl(channel,
+ channel->RingBufferGpadlHandle);
/* TODO: Send a msg to release the childRelId */
/* Cleanup the ring buffers for this channel */
- RingBufferCleanup(&Channel->Outbound);
- RingBufferCleanup(&Channel->Inbound);
+ RingBufferCleanup(&channel->Outbound);
+ RingBufferCleanup(&channel->Inbound);
- osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
+ osd_PageFree(channel->RingBufferPages, channel->RingBufferPageCount);
kfree(info);
@@ -690,12 +693,12 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
* caller will free the channel
*/
- if (Channel->State == CHANNEL_OPEN_STATE) {
+ if (channel->State == CHANNEL_OPEN_STATE) {
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_del(&Channel->ListEntry);
+ list_del(&channel->ListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
- FreeVmbusChannel(Channel);
+ FreeVmbusChannel(channel);
}
}
@@ -713,42 +716,43 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
*
* Mainly used by Hyper-V drivers.
*/
-int VmbusChannelSendPacket(struct vmbus_channel *Channel, const void *Buffer,
- u32 BufferLen, u64 RequestId,
- enum vmbus_packet_type Type, u32 Flags)
+int VmbusChannelSendPacket(struct vmbus_channel *channel, const void *buffer,
+ u32 bufferlen, u64 requestid,
+ enum vmbus_packet_type type, u32 flags)
{
struct vmpacket_descriptor desc;
- u32 packetLen = sizeof(struct vmpacket_descriptor) + BufferLen;
- u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
+ u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen;
+ u32 packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
int ret;
DPRINT_DBG(VMBUS, "channel %p buffer %p len %d",
- Channel, Buffer, BufferLen);
+ channel, buffer, bufferlen);
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.Type = Type; /* VmbusPacketTypeDataInBand; */
- desc.Flags = Flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
+ desc.Type = type; /* VmbusPacketTypeDataInBand; */
+ desc.Flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
/* in 8-bytes granularity */
desc.DataOffset8 = sizeof(struct vmpacket_descriptor) >> 3;
- desc.Length8 = (u16)(packetLenAligned >> 3);
- desc.TransactionId = RequestId;
+ desc.Length8 = (u16)(packetlen_aligned >> 3);
+ desc.TransactionId = requestid;
- sg_init_table(bufferList, 3);
- sg_set_buf(&bufferList[0], &desc, sizeof(struct vmpacket_descriptor));
- sg_set_buf(&bufferList[1], Buffer, BufferLen);
- sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, sizeof(struct vmpacket_descriptor));
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -758,61 +762,62 @@ EXPORT_SYMBOL(VmbusChannelSendPacket);
* VmbusChannelSendPacketPageBuffer - Send a range of single-page buffer
* packets using a GPADL Direct packet type.
*/
-int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
- struct hv_page_buffer PageBuffers[],
- u32 PageCount, void *Buffer, u32 BufferLen,
- u64 RequestId)
+int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel,
+ struct hv_page_buffer pagebuffers[],
+ u32 pagecount, void *buffer, u32 bufferlen,
+ u64 requestid)
{
int ret;
int i;
struct vmbus_channel_packet_page_buffer desc;
- u32 descSize;
- u32 packetLen;
- u32 packetLenAligned;
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
+ u32 descsize;
+ u32 packetlen;
+ u32 packetlen_aligned;
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
- if (PageCount > MAX_PAGE_BUFFER_COUNT)
+ if (pagecount > MAX_PAGE_BUFFER_COUNT)
return -EINVAL;
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/*
* Adjust the size down since vmbus_channel_packet_page_buffer is the
* largest size we support
*/
- descSize = sizeof(struct vmbus_channel_packet_page_buffer) -
- ((MAX_PAGE_BUFFER_COUNT - PageCount) *
+ descsize = sizeof(struct vmbus_channel_packet_page_buffer) -
+ ((MAX_PAGE_BUFFER_COUNT - pagecount) *
sizeof(struct hv_page_buffer));
- packetLen = descSize + BufferLen;
- packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+ packetlen = descsize + bufferlen;
+ packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
desc.type = VmbusPacketTypeDataUsingGpaDirect;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.length8 = (u16)(packetLenAligned >> 3);
- desc.transactionid = RequestId;
- desc.rangecount = PageCount;
-
- for (i = 0; i < PageCount; i++) {
- desc.range[i].Length = PageBuffers[i].Length;
- desc.range[i].Offset = PageBuffers[i].Offset;
- desc.range[i].Pfn = PageBuffers[i].Pfn;
+ desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetlen_aligned >> 3);
+ desc.transactionid = requestid;
+ desc.rangecount = pagecount;
+
+ for (i = 0; i < pagecount; i++) {
+ desc.range[i].Length = pagebuffers[i].Length;
+ desc.range[i].Offset = pagebuffers[i].Offset;
+ desc.range[i].Pfn = pagebuffers[i].Pfn;
}
- 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);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, descsize);
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -821,64 +826,66 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
* VmbusChannelSendPacketMultiPageBuffer - Send a multi-page buffer packet
* using a GPADL Direct packet type.
*/
-int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
- struct hv_multipage_buffer *MultiPageBuffer,
- void *Buffer, u32 BufferLen, u64 RequestId)
+int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
+ struct hv_multipage_buffer *multi_pagebuffer,
+ void *buffer, u32 bufferlen, u64 requestid)
{
int ret;
struct vmbus_channel_packet_multipage_buffer desc;
- u32 descSize;
- u32 packetLen;
- u32 packetLenAligned;
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
- u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset,
- MultiPageBuffer->Length);
+ u32 descsize;
+ u32 packetlen;
+ u32 packetlen_aligned;
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
+ u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->Offset,
+ multi_pagebuffer->Length);
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u",
- MultiPageBuffer->Offset, MultiPageBuffer->Length, PfnCount);
+ multi_pagebuffer->Offset,
+ multi_pagebuffer->Length, pfncount);
- if ((PfnCount < 0) || (PfnCount > MAX_MULTIPAGE_BUFFER_COUNT))
+ if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT))
return -EINVAL;
/*
* Adjust the size down since vmbus_channel_packet_multipage_buffer is
* the largest size we support
*/
- descSize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
- ((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount) *
+ descsize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
+ ((MAX_MULTIPAGE_BUFFER_COUNT - pfncount) *
sizeof(u64));
- packetLen = descSize + BufferLen;
- packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+ packetlen = descsize + bufferlen;
+ packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
desc.type = VmbusPacketTypeDataUsingGpaDirect;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.length8 = (u16)(packetLenAligned >> 3);
- desc.transactionid = RequestId;
+ desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetlen_aligned >> 3);
+ desc.transactionid = requestid;
desc.rangecount = 1;
- desc.range.Length = MultiPageBuffer->Length;
- desc.range.Offset = MultiPageBuffer->Offset;
+ desc.range.Length = multi_pagebuffer->Length;
+ desc.range.Offset = multi_pagebuffer->Offset;
- memcpy(desc.range.PfnArray, MultiPageBuffer->PfnArray,
- PfnCount * sizeof(u64));
+ memcpy(desc.range.PfnArray, multi_pagebuffer->PfnArray,
+ pfncount * sizeof(u64));
- 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);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, descsize);
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -897,24 +904,24 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
*
* Mainly used by Hyper-V drivers.
*/
-int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
- u32 BufferLen, u32 *BufferActualLen, u64 *RequestId)
+int VmbusChannelRecvPacket(struct vmbus_channel *channel, void *buffer,
+ u32 bufferlen, u32 *buffer_actual_len, u64 *requestid)
{
struct vmpacket_descriptor desc;
- u32 packetLen;
- u32 userLen;
+ u32 packetlen;
+ u32 userlen;
int ret;
unsigned long flags;
- *BufferActualLen = 0;
- *RequestId = 0;
+ *buffer_actual_len = 0;
+ *requestid = 0;
- spin_lock_irqsave(&Channel->inbound_lock, flags);
+ spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&Channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->Inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
return 0;
@@ -922,32 +929,32 @@ int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
/* VmbusChannelClearEvent(Channel); */
- packetLen = desc.Length8 << 3;
- userLen = packetLen - (desc.DataOffset8 << 3);
+ packetlen = desc.Length8 << 3;
+ userlen = packetlen - (desc.DataOffset8 << 3);
/* ASSERT(userLen > 0); */
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- Channel, Channel->OfferMsg.ChildRelId, desc.Type,
- desc.Flags, desc.TransactionId, packetLen, userLen);
+ channel, channel->OfferMsg.ChildRelId, desc.Type,
+ desc.Flags, desc.TransactionId, packetlen, userlen);
- *BufferActualLen = userLen;
+ *buffer_actual_len = userlen;
- if (userLen > BufferLen) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ if (userlen > bufferlen) {
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
DPRINT_ERR(VMBUS, "buffer too small - got %d needs %d",
- BufferLen, userLen);
+ bufferlen, userlen);
return -1;
}
- *RequestId = desc.TransactionId;
+ *requestid = desc.TransactionId;
/* Copy over the packet to the user buffer */
- ret = RingBufferRead(&Channel->Inbound, Buffer, userLen,
+ ret = RingBufferRead(&channel->Inbound, buffer, userlen,
(desc.DataOffset8 << 3));
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
}
@@ -956,25 +963,25 @@ EXPORT_SYMBOL(VmbusChannelRecvPacket);
/*
* VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel
*/
-int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
- u32 BufferLen, u32 *BufferActualLen,
- u64 *RequestId)
+int VmbusChannelRecvPacketRaw(struct vmbus_channel *channel, void *buffer,
+ u32 bufferlen, u32 *buffer_actual_len,
+ u64 *requestid)
{
struct vmpacket_descriptor desc;
- u32 packetLen;
- u32 userLen;
+ u32 packetlen;
+ u32 userlen;
int ret;
unsigned long flags;
- *BufferActualLen = 0;
- *RequestId = 0;
+ *buffer_actual_len = 0;
+ *requestid = 0;
- spin_lock_irqsave(&Channel->inbound_lock, flags);
+ spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&Channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->Inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
return 0;
@@ -982,44 +989,44 @@ int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
/* VmbusChannelClearEvent(Channel); */
- packetLen = desc.Length8 << 3;
- userLen = packetLen - (desc.DataOffset8 << 3);
+ packetlen = desc.Length8 << 3;
+ userlen = packetlen - (desc.DataOffset8 << 3);
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- Channel, Channel->OfferMsg.ChildRelId, desc.Type,
- desc.Flags, desc.TransactionId, packetLen, userLen);
+ channel, channel->OfferMsg.ChildRelId, desc.Type,
+ desc.Flags, desc.TransactionId, packetlen, userlen);
- *BufferActualLen = packetLen;
+ *buffer_actual_len = packetlen;
- if (packetLen > BufferLen) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ if (packetlen > bufferlen) {
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
DPRINT_ERR(VMBUS, "buffer too small - needed %d bytes but "
- "got space for only %d bytes", packetLen, BufferLen);
+ "got space for only %d bytes", packetlen, bufferlen);
return -2;
}
- *RequestId = desc.TransactionId;
+ *requestid = desc.TransactionId;
/* Copy over the entire packet to the user buffer */
- ret = RingBufferRead(&Channel->Inbound, Buffer, packetLen, 0);
+ ret = RingBufferRead(&channel->Inbound, buffer, packetlen, 0);
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
}
/*
* VmbusChannelOnChannelEvent - Channel event callback
*/
-void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel)
+void VmbusChannelOnChannelEvent(struct vmbus_channel *channel)
{
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/* ASSERT(Channel->OnChannelCallback); */
- Channel->OnChannelCallback(Channel->ChannelCallbackContext);
+ channel->OnChannelCallback(channel->ChannelCallbackContext);
- mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100));
+ mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100));
}
/*
@@ -1036,9 +1043,9 @@ void VmbusChannelOnTimer(unsigned long data)
/*
* DumpVmbusChannel - Dump vmbus channel info to the console
*/
-static void DumpVmbusChannel(struct vmbus_channel *Channel)
+static void DumpVmbusChannel(struct vmbus_channel *channel)
{
- DPRINT_DBG(VMBUS, "Channel (%d)", Channel->OfferMsg.ChildRelId);
- DumpRingInfo(&Channel->Outbound, "Outbound ");
- DumpRingInfo(&Channel->Inbound, "Inbound ");
+ DPRINT_DBG(VMBUS, "Channel (%d)", channel->OfferMsg.ChildRelId);
+ DumpRingInfo(&channel->Outbound, "Outbound ");
+ DumpRingInfo(&channel->Inbound, "Inbound ");
}
--
1.6.3.2
^ permalink raw reply related
* RE: [PATCH 1/1] Rename camel case variables in channel.c
From: Haiyang Zhang @ 2010-09-23 21:04 UTC (permalink / raw)
To: Joe Perches
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de',
Hank Janssen
In-Reply-To: <1285274468.25928.15.camel@Joe-Laptop>
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Thursday, September 23, 2010 4:41 PM
> > - struct hv_monitor_page *monitorPage;
> > + struct hv_monitor_page *monitorpage;
>
> Some of these renames would be better with a "_" for
> the CamelCase conversions (ie: CamelCase -> camel_case).
Yes, for longer names I usually insert underscore. For example,
I changed packetLenAligned to packetlen_aligned.
> > + struct hv_monitor_page *monitorpage;
> > + u8 monitorGroup = (u8)channel->OfferMsg.MonitorId / 32;
> > + u8 monitorOffset = (u8)channel->OfferMsg.MonitorId % 32;
>
> Why not convert these to monitor_(group|offset)?
That's a good catch. I will update it.
Thanks,
- Haiyang
^ permalink raw reply
* Re: [PATCH 1/1] Rename camel case variables in channel.c
From: Joe Perches @ 2010-09-23 20:41 UTC (permalink / raw)
To: Haiyang Zhang
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de',
Hank Janssen
In-Reply-To: <1FB5E1D5CA062146B38059374562DF7289EBB57C@TK5EX14MBXC128.redmond.corp.microsoft.com>
On Thu, 2010-09-23 at 20:24 +0000, Haiyang Zhang wrote:
> drivers/staging/hv/channel.c | 729 +++++++++++++++++++++---------------------
[]
> - struct hv_monitor_page *monitorPage;
> + struct hv_monitor_page *monitorpage;
Some of these renames would be better with a "_" for
the CamelCase conversions (ie: CamelCase -> camel_case).
perl regex: 's/\b([A-Z])([a-z]+)([A-Z])([a-z]+)\b/\L$1$2_\L$3$4/g'
For instance, I think this should be monitor_page;
> -void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
> - struct vmbus_channel_debug_info *DebugInfo)
> +void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
> + struct vmbus_channel_debug_info *debuginfo)
perhaps debug_info
> {
> - struct hv_monitor_page *monitorPage;
> - u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32;
> - u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32;
> + struct hv_monitor_page *monitorpage;
> + u8 monitorGroup = (u8)channel->OfferMsg.MonitorId / 32;
> + u8 monitorOffset = (u8)channel->OfferMsg.MonitorId % 32;
Why not convert these to monitor_(group|offset)?
etc...
^ permalink raw reply
* [PATCH 1/1] Rename camel case variables in channel.c
From: Haiyang Zhang @ 2010-09-23 20:24 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
"'virtualization@lists.osdl.org'" <virtualiz>
From: Haiyang Zhang <haiyangz@microsoft.com>
Rename camel case variables in channel.c
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 729 +++++++++++++++++++++---------------------
1 files changed, 368 insertions(+), 361 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 37b7b4c..e15cde0 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -28,10 +28,10 @@
/* Internal routines */
static int VmbusChannelCreateGpadlHeader(
- void *Kbuffer, /* must be phys and virt contiguous */
- u32 Size, /* page-size multiple */
- struct vmbus_channel_msginfo **msgInfo,
- u32 *MessageCount);
+ void *kbuffer, /* must be phys and virt contiguous */
+ u32 size, /* page-size multiple */
+ struct vmbus_channel_msginfo **msginfo,
+ u32 *messagecount);
static void DumpVmbusChannel(struct vmbus_channel *channel);
static void VmbusChannelSetEvent(struct vmbus_channel *channel);
@@ -70,25 +70,25 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
* VmbusChannelSetEvent - Trigger an event notification on the specified
* channel.
*/
-static void VmbusChannelSetEvent(struct vmbus_channel *Channel)
+static void VmbusChannelSetEvent(struct vmbus_channel *channel)
{
- struct hv_monitor_page *monitorPage;
+ struct hv_monitor_page *monitorpage;
- if (Channel->OfferMsg.MonitorAllocated) {
+ if (channel->OfferMsg.MonitorAllocated) {
/* Each u32 represents 32 channels */
- set_bit(Channel->OfferMsg.ChildRelId & 31,
+ set_bit(channel->OfferMsg.ChildRelId & 31,
(unsigned long *) gVmbusConnection.SendInterruptPage +
- (Channel->OfferMsg.ChildRelId >> 5));
+ (channel->OfferMsg.ChildRelId >> 5));
- monitorPage = gVmbusConnection.MonitorPages;
- monitorPage++; /* Get the child to parent monitor page */
+ monitorpage = gVmbusConnection.MonitorPages;
+ monitorpage++; /* Get the child to parent monitor page */
- set_bit(Channel->MonitorBit,
- (unsigned long *)&monitorPage->TriggerGroup
- [Channel->MonitorGroup].Pending);
+ set_bit(channel->MonitorBit,
+ (unsigned long *)&monitorpage->TriggerGroup
+ [channel->MonitorGroup].Pending);
} else {
- VmbusSetEvent(Channel->OfferMsg.ChildRelId);
+ VmbusSetEvent(channel->OfferMsg.ChildRelId);
}
}
@@ -117,54 +117,54 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
/*
* VmbusChannelGetDebugInfo -Retrieve various channel debug info
*/
-void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel,
- struct vmbus_channel_debug_info *DebugInfo)
+void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
+ struct vmbus_channel_debug_info *debuginfo)
{
- struct hv_monitor_page *monitorPage;
- u8 monitorGroup = (u8)Channel->OfferMsg.MonitorId / 32;
- u8 monitorOffset = (u8)Channel->OfferMsg.MonitorId % 32;
+ struct hv_monitor_page *monitorpage;
+ u8 monitorGroup = (u8)channel->OfferMsg.MonitorId / 32;
+ u8 monitorOffset = (u8)channel->OfferMsg.MonitorId % 32;
/* u32 monitorBit = 1 << monitorOffset; */
- DebugInfo->RelId = Channel->OfferMsg.ChildRelId;
- DebugInfo->State = Channel->State;
- memcpy(&DebugInfo->InterfaceType,
- &Channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
- memcpy(&DebugInfo->InterfaceInstance,
- &Channel->OfferMsg.Offer.InterfaceInstance,
+ debuginfo->RelId = channel->OfferMsg.ChildRelId;
+ debuginfo->State = channel->State;
+ memcpy(&debuginfo->InterfaceType,
+ &channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
+ memcpy(&debuginfo->InterfaceInstance,
+ &channel->OfferMsg.Offer.InterfaceInstance,
sizeof(struct hv_guid));
- monitorPage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
+ monitorpage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
- DebugInfo->MonitorId = Channel->OfferMsg.MonitorId;
+ debuginfo->MonitorId = channel->OfferMsg.MonitorId;
- DebugInfo->ServerMonitorPending =
- monitorPage->TriggerGroup[monitorGroup].Pending;
- DebugInfo->ServerMonitorLatency =
- monitorPage->Latency[monitorGroup][monitorOffset];
- DebugInfo->ServerMonitorConnectionId =
- monitorPage->Parameter[monitorGroup]
+ debuginfo->ServerMonitorPending =
+ monitorpage->TriggerGroup[monitorGroup].Pending;
+ debuginfo->ServerMonitorLatency =
+ monitorpage->Latency[monitorGroup][monitorOffset];
+ debuginfo->ServerMonitorConnectionId =
+ monitorpage->Parameter[monitorGroup]
[monitorOffset].ConnectionId.u.Id;
- monitorPage++;
+ monitorpage++;
- DebugInfo->ClientMonitorPending =
- monitorPage->TriggerGroup[monitorGroup].Pending;
- DebugInfo->ClientMonitorLatency =
- monitorPage->Latency[monitorGroup][monitorOffset];
- DebugInfo->ClientMonitorConnectionId =
- monitorPage->Parameter[monitorGroup]
+ debuginfo->ClientMonitorPending =
+ monitorpage->TriggerGroup[monitorGroup].Pending;
+ debuginfo->ClientMonitorLatency =
+ monitorpage->Latency[monitorGroup][monitorOffset];
+ debuginfo->ClientMonitorConnectionId =
+ monitorpage->Parameter[monitorGroup]
[monitorOffset].ConnectionId.u.Id;
- RingBufferGetDebugInfo(&Channel->Inbound, &DebugInfo->Inbound);
- RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound);
+ RingBufferGetDebugInfo(&channel->Inbound, &debuginfo->Inbound);
+ RingBufferGetDebugInfo(&channel->Outbound, &debuginfo->Outbound);
}
/*
* VmbusChannelOpen - Open the specified channel.
*/
-int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
- u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
- void (*OnChannelCallback)(void *context), void *Context)
+int VmbusChannelOpen(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
+ u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
+ void (*onchannelcallback)(void *context), void *context)
{
struct vmbus_channel_open_channel *openMsg;
struct vmbus_channel_msginfo *openInfo = NULL;
@@ -176,30 +176,30 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
/* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
/* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */
- NewChannel->OnChannelCallback = OnChannelCallback;
- NewChannel->ChannelCallbackContext = Context;
+ newchannel->OnChannelCallback = onchannelcallback;
+ newchannel->ChannelCallbackContext = context;
/* Allocate the ring buffer */
- out = osd_PageAlloc((SendRingBufferSize + RecvRingBufferSize)
+ out = osd_PageAlloc((send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
if (!out)
return -ENOMEM;
/* ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0); */
- in = (void *)((unsigned long)out + SendRingBufferSize);
+ in = (void *)((unsigned long)out + send_ringbuffer_size);
- NewChannel->RingBufferPages = out;
- NewChannel->RingBufferPageCount = (SendRingBufferSize +
- RecvRingBufferSize) >> PAGE_SHIFT;
+ newchannel->RingBufferPages = out;
+ newchannel->RingBufferPageCount = (send_ringbuffer_size +
+ recv_ringbuffer_size) >> PAGE_SHIFT;
- ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
+ ret = RingBufferInit(&newchannel->Outbound, out, send_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
}
- ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
+ ret = RingBufferInit(&newchannel->Inbound, in, recv_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
@@ -208,15 +208,15 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
/* Establish the gpadl for the ring buffer */
DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
- NewChannel);
+ newchannel);
- NewChannel->RingBufferGpadlHandle = 0;
+ newchannel->RingBufferGpadlHandle = 0;
- ret = VmbusChannelEstablishGpadl(NewChannel,
- NewChannel->Outbound.RingBuffer,
- SendRingBufferSize +
- RecvRingBufferSize,
- &NewChannel->RingBufferGpadlHandle);
+ ret = VmbusChannelEstablishGpadl(newchannel,
+ newchannel->Outbound.RingBuffer,
+ send_ringbuffer_size +
+ recv_ringbuffer_size,
+ &newchannel->RingBufferGpadlHandle);
if (ret != 0) {
err = ret;
@@ -225,13 +225,13 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
DPRINT_DBG(VMBUS, "channel %p <relid %d gpadl 0x%x send ring %p "
"size %d recv ring %p size %d, downstreamoffset %d>",
- NewChannel, NewChannel->OfferMsg.ChildRelId,
- NewChannel->RingBufferGpadlHandle,
- NewChannel->Outbound.RingBuffer,
- NewChannel->Outbound.RingSize,
- NewChannel->Inbound.RingBuffer,
- NewChannel->Inbound.RingSize,
- SendRingBufferSize);
+ newchannel, newchannel->OfferMsg.ChildRelId,
+ newchannel->RingBufferGpadlHandle,
+ newchannel->Outbound.RingBuffer,
+ newchannel->Outbound.RingSize,
+ newchannel->Inbound.RingBuffer,
+ newchannel->Inbound.RingSize,
+ send_ringbuffer_size);
/* Create and init the channel open message */
openInfo = kmalloc(sizeof(*openInfo) +
@@ -250,20 +250,20 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
openMsg = (struct vmbus_channel_open_channel *)openInfo->Msg;
openMsg->Header.MessageType = ChannelMessageOpenChannel;
- openMsg->OpenId = NewChannel->OfferMsg.ChildRelId; /* FIXME */
- openMsg->ChildRelId = NewChannel->OfferMsg.ChildRelId;
- openMsg->RingBufferGpadlHandle = NewChannel->RingBufferGpadlHandle;
- openMsg->DownstreamRingBufferPageOffset = SendRingBufferSize >>
+ openMsg->OpenId = newchannel->OfferMsg.ChildRelId; /* FIXME */
+ openMsg->ChildRelId = newchannel->OfferMsg.ChildRelId;
+ openMsg->RingBufferGpadlHandle = newchannel->RingBufferGpadlHandle;
+ openMsg->DownstreamRingBufferPageOffset = send_ringbuffer_size >>
PAGE_SHIFT;
openMsg->ServerContextAreaGpadlHandle = 0; /* TODO */
- if (UserDataLen > MAX_USER_DEFINED_BYTES) {
+ if (userdatalen > MAX_USER_DEFINED_BYTES) {
err = -EINVAL;
goto errorout;
}
- if (UserDataLen)
- memcpy(openMsg->UserData, UserData, UserDataLen);
+ if (userdatalen)
+ memcpy(openMsg->UserData, userdata, userdatalen);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&openInfo->MsgListEntry,
@@ -283,10 +283,10 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
osd_WaitEventWait(openInfo->WaitEvent);
if (openInfo->Response.OpenResult.Status == 0)
- DPRINT_INFO(VMBUS, "channel <%p> open success!!", NewChannel);
+ DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
else
DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!",
- NewChannel, openInfo->Response.OpenResult.Status);
+ newchannel, openInfo->Response.OpenResult.Status);
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
@@ -298,9 +298,9 @@ Cleanup:
return 0;
errorout:
- RingBufferCleanup(&NewChannel->Outbound);
- RingBufferCleanup(&NewChannel->Inbound);
- osd_PageFree(out, (SendRingBufferSize + RecvRingBufferSize)
+ RingBufferCleanup(&newchannel->Outbound);
+ RingBufferCleanup(&newchannel->Inbound);
+ osd_PageFree(out, (send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
kfree(openInfo);
return err;
@@ -310,126 +310,127 @@ errorout:
* DumpGpadlBody - Dump the gpadl body message to the console for
* debugging purposes.
*/
-static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len)
+static void DumpGpadlBody(struct vmbus_channel_gpadl_body *gpadl, u32 len)
{
int i;
- int pfnCount;
+ int pfncount;
- pfnCount = (Len - sizeof(struct vmbus_channel_gpadl_body)) /
+ pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
sizeof(u64);
- DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", Len, pfnCount);
+ DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
- for (i = 0; i < pfnCount; i++)
+ for (i = 0; i < pfncount; i++)
DPRINT_DBG(VMBUS, "gpadl body - %d) pfn %llu",
- i, Gpadl->Pfn[i]);
+ i, gpadl->Pfn[i]);
}
/*
* DumpGpadlHeader - Dump the gpadl header message to the console for
* debugging purposes.
*/
-static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl)
+static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *gpadl)
{
int i, j;
- int pageCount;
+ int pagecount;
DPRINT_DBG(VMBUS,
"gpadl header - relid %d, range count %d, range buflen %d",
- Gpadl->ChildRelId, Gpadl->RangeCount, Gpadl->RangeBufLen);
- for (i = 0; i < Gpadl->RangeCount; i++) {
- pageCount = Gpadl->Range[i].ByteCount >> PAGE_SHIFT;
- pageCount = (pageCount > 26) ? 26 : pageCount;
+ gpadl->ChildRelId, gpadl->RangeCount, gpadl->RangeBufLen);
+ for (i = 0; i < gpadl->RangeCount; i++) {
+ pagecount = gpadl->Range[i].ByteCount >> PAGE_SHIFT;
+ pagecount = (pagecount > 26) ? 26 : pagecount;
DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
- "page count %d", i, Gpadl->Range[i].ByteCount,
- Gpadl->Range[i].ByteOffset, pageCount);
+ "page count %d", i, gpadl->Range[i].ByteCount,
+ gpadl->Range[i].ByteOffset, pagecount);
- for (j = 0; j < pageCount; j++)
+ for (j = 0; j < pagecount; j++)
DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
- Gpadl->Range[i].PfnArray[j]);
+ gpadl->Range[i].PfnArray[j]);
}
}
/*
* VmbusChannelCreateGpadlHeader - Creates a gpadl for the specified buffer
*/
-static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
- struct vmbus_channel_msginfo **MsgInfo,
- u32 *MessageCount)
+static int VmbusChannelCreateGpadlHeader(void *kbuffer, u32 size,
+ struct vmbus_channel_msginfo **msginfo,
+ u32 *messagecount)
{
int i;
- int pageCount;
+ int pagecount;
unsigned long long pfn;
- struct vmbus_channel_gpadl_header *gpaHeader;
- struct vmbus_channel_gpadl_body *gpadlBody;
- struct vmbus_channel_msginfo *msgHeader;
- struct vmbus_channel_msginfo *msgBody = NULL;
- u32 msgSize;
+ struct vmbus_channel_gpadl_header *gpal_header;
+ struct vmbus_channel_gpadl_body *gpadl_body;
+ struct vmbus_channel_msginfo *msgheader;
+ struct vmbus_channel_msginfo *msgbody = NULL;
+ u32 msgsize;
- int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize;
+ int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;
/* ASSERT((kbuffer & (PAGE_SIZE-1)) == 0); */
/* ASSERT((Size & (PAGE_SIZE-1)) == 0); */
- pageCount = Size >> PAGE_SHIFT;
- pfn = virt_to_phys(Kbuffer) >> PAGE_SHIFT;
+ pagecount = size >> PAGE_SHIFT;
+ pfn = virt_to_phys(kbuffer) >> PAGE_SHIFT;
/* do we need a gpadl body msg */
- pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+ pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
sizeof(struct vmbus_channel_gpadl_header) -
sizeof(struct gpa_range);
- pfnCount = pfnSize / sizeof(u64);
+ pfncount = pfnsize / sizeof(u64);
- if (pageCount > pfnCount) {
+ if (pagecount > pfncount) {
/* we need a gpadl body */
/* fill in the header */
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_header) +
- sizeof(struct gpa_range) + pfnCount * sizeof(u64);
- msgHeader = kzalloc(msgSize, GFP_KERNEL);
- if (!msgHeader)
+ sizeof(struct gpa_range) + pfncount * sizeof(u64);
+ msgheader = kzalloc(msgsize, GFP_KERNEL);
+ if (!msgheader)
goto nomem;
- INIT_LIST_HEAD(&msgHeader->SubMsgList);
- msgHeader->MessageSize = msgSize;
+ INIT_LIST_HEAD(&msgheader->SubMsgList);
+ msgheader->MessageSize = msgsize;
- gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
- gpaHeader->RangeCount = 1;
- gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
- pageCount * sizeof(u64);
- gpaHeader->Range[0].ByteOffset = 0;
- gpaHeader->Range[0].ByteCount = Size;
- for (i = 0; i < pfnCount; i++)
- gpaHeader->Range[0].PfnArray[i] = pfn+i;
- *MsgInfo = msgHeader;
- *MessageCount = 1;
+ gpal_header = (struct vmbus_channel_gpadl_header *)
+ msgheader->Msg;
+ gpal_header->RangeCount = 1;
+ gpal_header->RangeBufLen = sizeof(struct gpa_range) +
+ pagecount * sizeof(u64);
+ gpal_header->Range[0].ByteOffset = 0;
+ gpal_header->Range[0].ByteCount = size;
+ for (i = 0; i < pfncount; i++)
+ gpal_header->Range[0].PfnArray[i] = pfn+i;
+ *msginfo = msgheader;
+ *messagecount = 1;
- pfnSum = pfnCount;
- pfnLeft = pageCount - pfnCount;
+ pfnsum = pfncount;
+ pfnleft = pagecount - pfncount;
/* how many pfns can we fit */
- pfnSize = MAX_SIZE_CHANNEL_MESSAGE -
+ pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
sizeof(struct vmbus_channel_gpadl_body);
- pfnCount = pfnSize / sizeof(u64);
+ pfncount = pfnsize / sizeof(u64);
/* fill in the body */
- while (pfnLeft) {
- if (pfnLeft > pfnCount)
- pfnCurr = pfnCount;
+ while (pfnleft) {
+ if (pfnleft > pfncount)
+ pfncurr = pfncount;
else
- pfnCurr = pfnLeft;
+ pfncurr = pfnleft;
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_body) +
- pfnCurr * sizeof(u64);
- msgBody = kzalloc(msgSize, GFP_KERNEL);
+ pfncurr * sizeof(u64);
+ msgbody = kzalloc(msgsize, GFP_KERNEL);
/* FIXME: we probably need to more if this fails */
- if (!msgBody)
+ if (!msgbody)
goto nomem;
- msgBody->MessageSize = msgSize;
- (*MessageCount)++;
- gpadlBody =
- (struct vmbus_channel_gpadl_body *)msgBody->Msg;
+ msgbody->MessageSize = msgsize;
+ (*messagecount)++;
+ gpadl_body =
+ (struct vmbus_channel_gpadl_body *)msgbody->Msg;
/*
* FIXME:
@@ -437,42 +438,43 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
* be 64-bit
*/
/* gpadlBody->Gpadl = kbuffer; */
- for (i = 0; i < pfnCurr; i++)
- gpadlBody->Pfn[i] = pfn + pfnSum + i;
+ for (i = 0; i < pfncurr; i++)
+ gpadl_body->Pfn[i] = pfn + pfnsum + i;
/* add to msg header */
- list_add_tail(&msgBody->MsgListEntry,
- &msgHeader->SubMsgList);
- pfnSum += pfnCurr;
- pfnLeft -= pfnCurr;
+ list_add_tail(&msgbody->MsgListEntry,
+ &msgheader->SubMsgList);
+ pfnsum += pfncurr;
+ pfnleft -= pfncurr;
}
} else {
/* everything fits in a header */
- msgSize = sizeof(struct vmbus_channel_msginfo) +
+ msgsize = sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_gpadl_header) +
- sizeof(struct gpa_range) + pageCount * sizeof(u64);
- msgHeader = kzalloc(msgSize, GFP_KERNEL);
- if (msgHeader == NULL)
+ sizeof(struct gpa_range) + pagecount * sizeof(u64);
+ msgheader = kzalloc(msgsize, GFP_KERNEL);
+ if (msgheader == NULL)
goto nomem;
- msgHeader->MessageSize = msgSize;
-
- gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
- gpaHeader->RangeCount = 1;
- gpaHeader->RangeBufLen = sizeof(struct gpa_range) +
- pageCount * sizeof(u64);
- gpaHeader->Range[0].ByteOffset = 0;
- gpaHeader->Range[0].ByteCount = Size;
- for (i = 0; i < pageCount; i++)
- gpaHeader->Range[0].PfnArray[i] = pfn+i;
-
- *MsgInfo = msgHeader;
- *MessageCount = 1;
+ msgheader->MessageSize = msgsize;
+
+ gpal_header = (struct vmbus_channel_gpadl_header *)
+ msgheader->Msg;
+ gpal_header->RangeCount = 1;
+ gpal_header->RangeBufLen = sizeof(struct gpa_range) +
+ pagecount * sizeof(u64);
+ gpal_header->Range[0].ByteOffset = 0;
+ gpal_header->Range[0].ByteCount = size;
+ for (i = 0; i < pagecount; i++)
+ gpal_header->Range[0].PfnArray[i] = pfn+i;
+
+ *msginfo = msgheader;
+ *messagecount = 1;
}
return 0;
nomem:
- kfree(msgHeader);
- kfree(msgBody);
+ kfree(msgheader);
+ kfree(msgbody);
return -ENOMEM;
}
@@ -484,108 +486,109 @@ nomem:
* @Size: page-size multiple
* @GpadlHandle: some funky thing
*/
-int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
- u32 Size, u32 *GpadlHandle)
+int VmbusChannelEstablishGpadl(struct vmbus_channel *channel, void *kbuffer,
+ u32 size, u32 *gpadl_handle)
{
- struct vmbus_channel_gpadl_header *gpadlMsg;
- struct vmbus_channel_gpadl_body *gpadlBody;
+ struct vmbus_channel_gpadl_header *gpadlmsg;
+ struct vmbus_channel_gpadl_body *gpadl_body;
/* struct vmbus_channel_gpadl_created *gpadlCreated; */
- struct vmbus_channel_msginfo *msgInfo = NULL;
- struct vmbus_channel_msginfo *subMsgInfo;
- u32 msgCount;
+ struct vmbus_channel_msginfo *msginfo = NULL;
+ struct vmbus_channel_msginfo *submsginfo;
+ u32 msgcount;
struct list_head *curr;
- u32 nextGpadlHandle;
+ u32 next_gpadl_handle;
unsigned long flags;
int ret = 0;
- nextGpadlHandle = atomic_read(&gVmbusConnection.NextGpadlHandle);
+ next_gpadl_handle = atomic_read(&gVmbusConnection.NextGpadlHandle);
atomic_inc(&gVmbusConnection.NextGpadlHandle);
- ret = VmbusChannelCreateGpadlHeader(Kbuffer, Size, &msgInfo, &msgCount);
+ ret = VmbusChannelCreateGpadlHeader(kbuffer, size, &msginfo, &msgcount);
if (ret)
return ret;
- msgInfo->WaitEvent = osd_WaitEventCreate();
- if (!msgInfo->WaitEvent) {
+ msginfo->WaitEvent = osd_WaitEventCreate();
+ if (!msginfo->WaitEvent) {
ret = -ENOMEM;
goto Cleanup;
}
- gpadlMsg = (struct vmbus_channel_gpadl_header *)msgInfo->Msg;
- gpadlMsg->Header.MessageType = ChannelMessageGpadlHeader;
- gpadlMsg->ChildRelId = Channel->OfferMsg.ChildRelId;
- gpadlMsg->Gpadl = nextGpadlHandle;
+ gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->Msg;
+ gpadlmsg->Header.MessageType = ChannelMessageGpadlHeader;
+ gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId;
+ gpadlmsg->Gpadl = next_gpadl_handle;
- DumpGpadlHeader(gpadlMsg);
+ DumpGpadlHeader(gpadlmsg);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&msgInfo->MsgListEntry,
+ list_add_tail(&msginfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
- Kbuffer, Size, msgCount);
+ kbuffer, size, msgcount);
DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
- msgInfo->MessageSize - sizeof(*msgInfo));
+ msginfo->MessageSize - sizeof(*msginfo));
- ret = VmbusPostMessage(gpadlMsg, msgInfo->MessageSize -
- sizeof(*msgInfo));
+ ret = VmbusPostMessage(gpadlmsg, msginfo->MessageSize -
+ sizeof(*msginfo));
if (ret != 0) {
DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
goto Cleanup;
}
- if (msgCount > 1) {
- list_for_each(curr, &msgInfo->SubMsgList) {
+ if (msgcount > 1) {
+ list_for_each(curr, &msginfo->SubMsgList) {
/* FIXME: should this use list_entry() instead ? */
- subMsgInfo = (struct vmbus_channel_msginfo *)curr;
- gpadlBody =
- (struct vmbus_channel_gpadl_body *)subMsgInfo->Msg;
+ submsginfo = (struct vmbus_channel_msginfo *)curr;
+ gpadl_body =
+ (struct vmbus_channel_gpadl_body *)submsginfo->Msg;
- gpadlBody->Header.MessageType = ChannelMessageGpadlBody;
- gpadlBody->Gpadl = nextGpadlHandle;
+ gpadl_body->Header.MessageType =
+ ChannelMessageGpadlBody;
+ gpadl_body->Gpadl = next_gpadl_handle;
DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd",
- subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
-
- DumpGpadlBody(gpadlBody, subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
- ret = VmbusPostMessage(gpadlBody,
- subMsgInfo->MessageSize -
- sizeof(*subMsgInfo));
+ submsginfo->MessageSize -
+ sizeof(*submsginfo));
+
+ DumpGpadlBody(gpadl_body, submsginfo->MessageSize -
+ sizeof(*submsginfo));
+ ret = VmbusPostMessage(gpadl_body,
+ submsginfo->MessageSize -
+ sizeof(*submsginfo));
if (ret != 0)
goto Cleanup;
}
}
- osd_WaitEventWait(msgInfo->WaitEvent);
+ osd_WaitEventWait(msginfo->WaitEvent);
/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created "
"(relid %d, status %d handle %x)",
- Channel->OfferMsg.ChildRelId,
- msgInfo->Response.GpadlCreated.CreationStatus,
- gpadlMsg->Gpadl);
+ channel->OfferMsg.ChildRelId,
+ msginfo->Response.GpadlCreated.CreationStatus,
+ gpadlmsg->Gpadl);
- *GpadlHandle = gpadlMsg->Gpadl;
+ *gpadl_handle = gpadlmsg->Gpadl;
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_del(&msgInfo->MsgListEntry);
+ list_del(&msginfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
- kfree(msgInfo->WaitEvent);
- kfree(msgInfo);
+ kfree(msginfo->WaitEvent);
+ kfree(msginfo);
return ret;
}
/*
* VmbusChannelTeardownGpadl -Teardown the specified GPADL handle
*/
-int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
+int VmbusChannelTeardownGpadl(struct vmbus_channel *channel, u32 gpadl_handle)
{
struct vmbus_channel_gpadl_teardown *msg;
struct vmbus_channel_msginfo *info;
@@ -608,8 +611,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
msg = (struct vmbus_channel_gpadl_teardown *)info->Msg;
msg->Header.MessageType = ChannelMessageGpadlTeardown;
- msg->ChildRelId = Channel->OfferMsg.ChildRelId;
- msg->Gpadl = GpadlHandle;
+ msg->ChildRelId = channel->OfferMsg.ChildRelId;
+ msg->Gpadl = gpadl_handle;
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&info->MsgListEntry,
@@ -638,7 +641,7 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
/*
* VmbusChannelClose - Close the specified channel
*/
-void VmbusChannelClose(struct vmbus_channel *Channel)
+void VmbusChannelClose(struct vmbus_channel *channel)
{
struct vmbus_channel_close_channel *msg;
struct vmbus_channel_msginfo *info;
@@ -646,8 +649,8 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
int ret;
/* Stop callback and cancel the timer asap */
- Channel->OnChannelCallback = NULL;
- del_timer_sync(&Channel->poll_timer);
+ channel->OnChannelCallback = NULL;
+ del_timer_sync(&channel->poll_timer);
/* Send a closing message */
info = kmalloc(sizeof(*info) +
@@ -661,7 +664,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
msg = (struct vmbus_channel_close_channel *)info->Msg;
msg->Header.MessageType = ChannelMessageCloseChannel;
- msg->ChildRelId = Channel->OfferMsg.ChildRelId;
+ msg->ChildRelId = channel->OfferMsg.ChildRelId;
ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
if (ret != 0) {
@@ -670,17 +673,17 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
}
/* Tear down the gpadl for the channel's ring buffer */
- if (Channel->RingBufferGpadlHandle)
- VmbusChannelTeardownGpadl(Channel,
- Channel->RingBufferGpadlHandle);
+ if (channel->RingBufferGpadlHandle)
+ VmbusChannelTeardownGpadl(channel,
+ channel->RingBufferGpadlHandle);
/* TODO: Send a msg to release the childRelId */
/* Cleanup the ring buffers for this channel */
- RingBufferCleanup(&Channel->Outbound);
- RingBufferCleanup(&Channel->Inbound);
+ RingBufferCleanup(&channel->Outbound);
+ RingBufferCleanup(&channel->Inbound);
- osd_PageFree(Channel->RingBufferPages, Channel->RingBufferPageCount);
+ osd_PageFree(channel->RingBufferPages, channel->RingBufferPageCount);
kfree(info);
@@ -690,12 +693,12 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
* caller will free the channel
*/
- if (Channel->State == CHANNEL_OPEN_STATE) {
+ if (channel->State == CHANNEL_OPEN_STATE) {
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_del(&Channel->ListEntry);
+ list_del(&channel->ListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
- FreeVmbusChannel(Channel);
+ FreeVmbusChannel(channel);
}
}
@@ -713,42 +716,43 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
*
* Mainly used by Hyper-V drivers.
*/
-int VmbusChannelSendPacket(struct vmbus_channel *Channel, const void *Buffer,
- u32 BufferLen, u64 RequestId,
- enum vmbus_packet_type Type, u32 Flags)
+int VmbusChannelSendPacket(struct vmbus_channel *channel, const void *buffer,
+ u32 bufferlen, u64 requestid,
+ enum vmbus_packet_type type, u32 flags)
{
struct vmpacket_descriptor desc;
- u32 packetLen = sizeof(struct vmpacket_descriptor) + BufferLen;
- u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
+ u32 packetlen = sizeof(struct vmpacket_descriptor) + bufferlen;
+ u32 packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
int ret;
DPRINT_DBG(VMBUS, "channel %p buffer %p len %d",
- Channel, Buffer, BufferLen);
+ channel, buffer, bufferlen);
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
- desc.Type = Type; /* VmbusPacketTypeDataInBand; */
- desc.Flags = Flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
+ desc.Type = type; /* VmbusPacketTypeDataInBand; */
+ desc.Flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
/* in 8-bytes granularity */
desc.DataOffset8 = sizeof(struct vmpacket_descriptor) >> 3;
- desc.Length8 = (u16)(packetLenAligned >> 3);
- desc.TransactionId = RequestId;
+ desc.Length8 = (u16)(packetlen_aligned >> 3);
+ desc.TransactionId = requestid;
- sg_init_table(bufferList, 3);
- sg_set_buf(&bufferList[0], &desc, sizeof(struct vmpacket_descriptor));
- sg_set_buf(&bufferList[1], Buffer, BufferLen);
- sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, sizeof(struct vmpacket_descriptor));
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -758,61 +762,62 @@ EXPORT_SYMBOL(VmbusChannelSendPacket);
* VmbusChannelSendPacketPageBuffer - Send a range of single-page buffer
* packets using a GPADL Direct packet type.
*/
-int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
- struct hv_page_buffer PageBuffers[],
- u32 PageCount, void *Buffer, u32 BufferLen,
- u64 RequestId)
+int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel,
+ struct hv_page_buffer pagebuffers[],
+ u32 pagecount, void *buffer, u32 bufferlen,
+ u64 requestid)
{
int ret;
int i;
struct vmbus_channel_packet_page_buffer desc;
- u32 descSize;
- u32 packetLen;
- u32 packetLenAligned;
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
+ u32 descsize;
+ u32 packetlen;
+ u32 packetlen_aligned;
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
- if (PageCount > MAX_PAGE_BUFFER_COUNT)
+ if (pagecount > MAX_PAGE_BUFFER_COUNT)
return -EINVAL;
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/*
* Adjust the size down since vmbus_channel_packet_page_buffer is the
* largest size we support
*/
- descSize = sizeof(struct vmbus_channel_packet_page_buffer) -
- ((MAX_PAGE_BUFFER_COUNT - PageCount) *
+ descsize = sizeof(struct vmbus_channel_packet_page_buffer) -
+ ((MAX_PAGE_BUFFER_COUNT - pagecount) *
sizeof(struct hv_page_buffer));
- packetLen = descSize + BufferLen;
- packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+ packetlen = descsize + bufferlen;
+ packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
desc.type = VmbusPacketTypeDataUsingGpaDirect;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.length8 = (u16)(packetLenAligned >> 3);
- desc.transactionid = RequestId;
- desc.rangecount = PageCount;
-
- for (i = 0; i < PageCount; i++) {
- desc.range[i].Length = PageBuffers[i].Length;
- desc.range[i].Offset = PageBuffers[i].Offset;
- desc.range[i].Pfn = PageBuffers[i].Pfn;
+ desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetlen_aligned >> 3);
+ desc.transactionid = requestid;
+ desc.rangecount = pagecount;
+
+ for (i = 0; i < pagecount; i++) {
+ desc.range[i].Length = pagebuffers[i].Length;
+ desc.range[i].Offset = pagebuffers[i].Offset;
+ desc.range[i].Pfn = pagebuffers[i].Pfn;
}
- 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);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, descsize);
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -821,64 +826,66 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel,
* VmbusChannelSendPacketMultiPageBuffer - Send a multi-page buffer packet
* using a GPADL Direct packet type.
*/
-int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
- struct hv_multipage_buffer *MultiPageBuffer,
- void *Buffer, u32 BufferLen, u64 RequestId)
+int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
+ struct hv_multipage_buffer *multi_pagebuffer,
+ void *buffer, u32 bufferlen, u64 requestid)
{
int ret;
struct vmbus_channel_packet_multipage_buffer desc;
- u32 descSize;
- u32 packetLen;
- u32 packetLenAligned;
- struct scatterlist bufferList[3];
- u64 alignedData = 0;
- u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset,
- MultiPageBuffer->Length);
+ u32 descsize;
+ u32 packetlen;
+ u32 packetlen_aligned;
+ struct scatterlist bufferlist[3];
+ u64 aligned_data = 0;
+ u32 pfncount = NUM_PAGES_SPANNED(multi_pagebuffer->Offset,
+ multi_pagebuffer->Length);
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u",
- MultiPageBuffer->Offset, MultiPageBuffer->Length, PfnCount);
+ multi_pagebuffer->Offset,
+ multi_pagebuffer->Length, pfncount);
- if ((PfnCount < 0) || (PfnCount > MAX_MULTIPAGE_BUFFER_COUNT))
+ if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT))
return -EINVAL;
/*
* Adjust the size down since vmbus_channel_packet_multipage_buffer is
* the largest size we support
*/
- descSize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
- ((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount) *
+ descsize = sizeof(struct vmbus_channel_packet_multipage_buffer) -
+ ((MAX_MULTIPAGE_BUFFER_COUNT - pfncount) *
sizeof(u64));
- packetLen = descSize + BufferLen;
- packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
+ packetlen = descsize + bufferlen;
+ packetlen_aligned = ALIGN_UP(packetlen, sizeof(u64));
/* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
/* Setup the descriptor */
desc.type = VmbusPacketTypeDataUsingGpaDirect;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
- desc.dataoffset8 = descSize >> 3; /* in 8-bytes grandularity */
- desc.length8 = (u16)(packetLenAligned >> 3);
- desc.transactionid = RequestId;
+ desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+ desc.length8 = (u16)(packetlen_aligned >> 3);
+ desc.transactionid = requestid;
desc.rangecount = 1;
- desc.range.Length = MultiPageBuffer->Length;
- desc.range.Offset = MultiPageBuffer->Offset;
+ desc.range.Length = multi_pagebuffer->Length;
+ desc.range.Offset = multi_pagebuffer->Offset;
- memcpy(desc.range.PfnArray, MultiPageBuffer->PfnArray,
- PfnCount * sizeof(u64));
+ memcpy(desc.range.PfnArray, multi_pagebuffer->PfnArray,
+ pfncount * sizeof(u64));
- 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);
+ sg_init_table(bufferlist, 3);
+ sg_set_buf(&bufferlist[0], &desc, descsize);
+ sg_set_buf(&bufferlist[1], buffer, bufferlen);
+ sg_set_buf(&bufferlist[2], &aligned_data,
+ packetlen_aligned - packetlen);
- ret = RingBufferWrite(&Channel->Outbound, bufferList, 3);
+ ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&Channel->Outbound))
- VmbusChannelSetEvent(Channel);
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ VmbusChannelSetEvent(channel);
return ret;
}
@@ -897,24 +904,24 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel,
*
* Mainly used by Hyper-V drivers.
*/
-int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
- u32 BufferLen, u32 *BufferActualLen, u64 *RequestId)
+int VmbusChannelRecvPacket(struct vmbus_channel *channel, void *buffer,
+ u32 bufferlen, u32 *buffer_actual_len, u64 *requestid)
{
struct vmpacket_descriptor desc;
- u32 packetLen;
- u32 userLen;
+ u32 packetlen;
+ u32 userlen;
int ret;
unsigned long flags;
- *BufferActualLen = 0;
- *RequestId = 0;
+ *buffer_actual_len = 0;
+ *requestid = 0;
- spin_lock_irqsave(&Channel->inbound_lock, flags);
+ spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&Channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->Inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
return 0;
@@ -922,32 +929,32 @@ int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer,
/* VmbusChannelClearEvent(Channel); */
- packetLen = desc.Length8 << 3;
- userLen = packetLen - (desc.DataOffset8 << 3);
+ packetlen = desc.Length8 << 3;
+ userlen = packetlen - (desc.DataOffset8 << 3);
/* ASSERT(userLen > 0); */
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- Channel, Channel->OfferMsg.ChildRelId, desc.Type,
- desc.Flags, desc.TransactionId, packetLen, userLen);
+ channel, channel->OfferMsg.ChildRelId, desc.Type,
+ desc.Flags, desc.TransactionId, packetlen, userlen);
- *BufferActualLen = userLen;
+ *buffer_actual_len = userlen;
- if (userLen > BufferLen) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ if (userlen > bufferlen) {
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
DPRINT_ERR(VMBUS, "buffer too small - got %d needs %d",
- BufferLen, userLen);
+ bufferlen, userlen);
return -1;
}
- *RequestId = desc.TransactionId;
+ *requestid = desc.TransactionId;
/* Copy over the packet to the user buffer */
- ret = RingBufferRead(&Channel->Inbound, Buffer, userLen,
+ ret = RingBufferRead(&channel->Inbound, buffer, userlen,
(desc.DataOffset8 << 3));
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
}
@@ -956,25 +963,25 @@ EXPORT_SYMBOL(VmbusChannelRecvPacket);
/*
* VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel
*/
-int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
- u32 BufferLen, u32 *BufferActualLen,
- u64 *RequestId)
+int VmbusChannelRecvPacketRaw(struct vmbus_channel *channel, void *buffer,
+ u32 bufferlen, u32 *buffer_actual_len,
+ u64 *requestid)
{
struct vmpacket_descriptor desc;
- u32 packetLen;
- u32 userLen;
+ u32 packetlen;
+ u32 userlen;
int ret;
unsigned long flags;
- *BufferActualLen = 0;
- *RequestId = 0;
+ *buffer_actual_len = 0;
+ *requestid = 0;
- spin_lock_irqsave(&Channel->inbound_lock, flags);
+ spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&Channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->Inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
/* DPRINT_DBG(VMBUS, "nothing to read!!"); */
return 0;
@@ -982,44 +989,44 @@ int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer,
/* VmbusChannelClearEvent(Channel); */
- packetLen = desc.Length8 << 3;
- userLen = packetLen - (desc.DataOffset8 << 3);
+ packetlen = desc.Length8 << 3;
+ userlen = packetlen - (desc.DataOffset8 << 3);
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- Channel, Channel->OfferMsg.ChildRelId, desc.Type,
- desc.Flags, desc.TransactionId, packetLen, userLen);
+ channel, channel->OfferMsg.ChildRelId, desc.Type,
+ desc.Flags, desc.TransactionId, packetlen, userlen);
- *BufferActualLen = packetLen;
+ *buffer_actual_len = packetlen;
- if (packetLen > BufferLen) {
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ if (packetlen > bufferlen) {
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
DPRINT_ERR(VMBUS, "buffer too small - needed %d bytes but "
- "got space for only %d bytes", packetLen, BufferLen);
+ "got space for only %d bytes", packetlen, bufferlen);
return -2;
}
- *RequestId = desc.TransactionId;
+ *requestid = desc.TransactionId;
/* Copy over the entire packet to the user buffer */
- ret = RingBufferRead(&Channel->Inbound, Buffer, packetLen, 0);
+ ret = RingBufferRead(&channel->Inbound, buffer, packetlen, 0);
- spin_unlock_irqrestore(&Channel->inbound_lock, flags);
+ spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
}
/*
* VmbusChannelOnChannelEvent - Channel event callback
*/
-void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel)
+void VmbusChannelOnChannelEvent(struct vmbus_channel *channel)
{
- DumpVmbusChannel(Channel);
+ DumpVmbusChannel(channel);
/* ASSERT(Channel->OnChannelCallback); */
- Channel->OnChannelCallback(Channel->ChannelCallbackContext);
+ channel->OnChannelCallback(channel->ChannelCallbackContext);
- mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100));
+ mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100));
}
/*
@@ -1036,9 +1043,9 @@ void VmbusChannelOnTimer(unsigned long data)
/*
* DumpVmbusChannel - Dump vmbus channel info to the console
*/
-static void DumpVmbusChannel(struct vmbus_channel *Channel)
+static void DumpVmbusChannel(struct vmbus_channel *channel)
{
- DPRINT_DBG(VMBUS, "Channel (%d)", Channel->OfferMsg.ChildRelId);
- DumpRingInfo(&Channel->Outbound, "Outbound ");
- DumpRingInfo(&Channel->Inbound, "Inbound ");
+ DPRINT_DBG(VMBUS, "Channel (%d)", channel->OfferMsg.ChildRelId);
+ DumpRingInfo(&channel->Outbound, "Outbound ");
+ DumpRingInfo(&channel->Inbound, "Inbound ");
}
--
1.6.3.2
^ permalink raw reply related
* Re: [E1000-eedc] [PATCH 02/10] implementation of IEEE 802.1Qbg in lldpad, part 1
From: John Fastabend @ 2010-09-23 19:34 UTC (permalink / raw)
To: Jens Osterkamp
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <4C9AA43B.9000702@intel.com>
On 9/22/2010 5:50 PM, John Fastabend wrote:
> On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
>> This patch contains the first part of an initial implementation of the
>> IEEE 802.1Qbg standard: it implements code for the exchange of EVB
>> capabilities between a host with virtual machines and an adjacent switch.
>> For this it adds a new EVB TLV to LLDP.
>>
>> Exchange of EVB TLV may be enabled or disabled on a per port basis.
>> Information about the information negotiated by the protocol can be
>> queried on the commandline with lldptool.
>>
>> This patch adds support for querying and setting parameters used in
>> the exchange of EVB TLV messages.
>> The parameters that can be set are:
>>
>> - forwarding mode
>> - host protocol capabilities (RTE, ECP, VDP)
>> - no. of supported VSIs
>> - retransmission timer exponent (RTE)
>>
>> The parameters are implemented as a local policy: all frames received by
>> an adjacent switch are validated against this policy and taken over where
>> appropriate. Negotiated parameters are stored in lldpads config, picked up
>> again and used at the next start.
>>
>> The patch applies to lldpad 0.9.38 and still contains code to log protocol
>> activity more verbosely than it would be necessary in the final version.
>>
>> Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
>> ---
>> Makefile.am | 10 +-
>> include/lldp.h | 19 ++
>> include/lldp_evb.h | 80 ++++++
>> include/lldp_evb_clif.h | 51 ++++
>> include/lldp_evb_cmds.h | 31 +++
>> include/lldp_tlv.h | 1 +
>> lldp_evb.c | 658 +++++++++++++++++++++++++++++++++++++++++++++++
>> lldp_evb_clif.c | 226 ++++++++++++++++
>> lldp_evb_cmds.c | 512 ++++++++++++++++++++++++++++++++++++
>> lldpad.c | 2 +
>> lldptool.c | 2 +
>> 11 files changed, 1588 insertions(+), 4 deletions(-)
>> create mode 100644 include/lldp_evb.h
>> create mode 100644 include/lldp_evb_clif.h
>> create mode 100644 include/lldp_evb_cmds.h
>> create mode 100644 lldp_evb.c
>> create mode 100644 lldp_evb_clif.c
>> create mode 100644 lldp_evb_cmds.c
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index 743e16f..d59a6fa 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -37,7 +37,7 @@ lldpad_include_HEADERS = include/dcb_types.h include/dcbtool.h \
>> include/dcb_osdep.h include/clif.h include/lldp_dcbx_cmds.h include/common.h \
>> include/lldpad.h include/os.h include/includes.h include/lldp_mand_cmds.h \
>> include/clif_msgs.h include/lldp_basman_cmds.h include/lldp_8023_cmds.h \
>> -include/lldp_med_cmds.h include/lldp_dcbx_cfg.h
>> +include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h
>>
>> noinst_HEADERS = include/config.h include/ctrl_iface.h \
>> include/dcb_driver_if_types.h include/dcb_driver_interface.h \
>> @@ -47,7 +47,7 @@ include/event_iface.h include/messages.h include/parse_cli.h include/version.h \
>> include/lldptool_cli.h include/list.h \
>> include/lldp_mand_clif.h include/lldp_basman_clif.h include/lldp_med_clif.h \
>> include/lldp_8023_clif.h include/lldp_dcbx_clif.h include/lldptool.h \
>> -include/lldp_rtnl.h
>> +include/lldp_rtnl.h include/lldp_evb_clif.h
>>
>> lldpad_SOURCES = lldpad.c config.c drv_cfg.c ctrl_iface.c event_iface.c eloop.c \
>> common.c os_unix.c lldp_dcbx_cmds.c log.c lldpad_shm.c \
>> @@ -62,10 +62,12 @@ lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
>> lldp_util.c include/lldp_util.h \
>> lldp_mand.c include/lldp_mand.h \
>> lldp_mand_cmds.c lldp_basman_cmds.c lldp_8023_cmds.c lldp_med_cmds.c \
>> +lldp_evb_cmds.c \
>> lldp_tlv.c include/lldp_tlv.h \
>> lldp_basman.c include/lldp_basman.h \
>> lldp_med.c include/lldp_med.h \
>> -lldp_8023.c include/lldp_8023.h
>> +lldp_8023.c include/lldp_8023.h \
>> +lldp_evb.c include/lldp_evb.h
>>
>>
>>
>> @@ -74,7 +76,7 @@ $(lldpad_include_HEADERS) $(noinst_HEADERS)
>>
>> lldptool_SOURCES = lldptool.c clif.c lldptool_cmds.c common.c os_unix.c \
>> lldp_mand_clif.c lldp_basman_clif.c lldp_med_clif.c lldp_8023_clif.c \
>> -lldp_dcbx_clif.c $(lldpad_include_HEADERS) $(noinst_HEADERS)
>> +lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) $(noinst_HEADERS)
>>
>> nltest_SOURCES = nltest.c nltest.h
>>
>> diff --git a/include/lldp.h b/include/lldp.h
>> index 66532bd..e00ba7a 100644
>> --- a/include/lldp.h
>> +++ b/include/lldp.h
>> @@ -45,6 +45,8 @@
>> /* Telecommunications Industry Association TR-41 Committee */
>> #define OUI_TIA_TR41 0x0012bb
>>
>> +#define OUI_IEEE_8021Qbg 0x001b3f
>> +
>> /* IEEE 802.3AB Clause 9: TLV Types */
>> #define CHASSIS_ID_TLV 1
>> #define PORT_ID_TLV 2
>> @@ -186,5 +188,22 @@ enum {
>> #define LLDP_8023_LINKAGG_CAPABLE (1 << 0)
>> #define LLDP_8023_LINKAGG_ENABLED (1 << 1)
>>
>> +/* IEEE 802.1Qbg subtype */
>> +#define LLDP_EVB_SUBTYPE 0
>> +
>> +/* forwarding mode */
>> +#define LLDP_EVB_CAPABILITY_FORWARD_STANDARD (1 << 7)
>> +#define LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY (1 << 6)
>> +
>> +/* EVB supported protocols */
>> +#define LLDP_EVB_CAPABILITY_PROTOCOL_RTE (1 << 2)
>> +#define LLDP_EVB_CAPABILITY_PROTOCOL_ECP (1 << 1)
>> +#define LLDP_EVB_CAPABILITY_PROTOCOL_VDP (1 << 0)
>> +
>> +/* EVB specific values */
>> +#define LLDP_EVB_DEFAULT_MAX_VSI 4096
>> +#define LLDP_EVB_DEFAULT_SVSI 3295
>> +#define LLDP_EVB_DEFAULT_RTE 15
>> +
>> void somethingChangedLocal(char *ifname);
>> #endif /* _LLDP_H */
>> diff --git a/include/lldp_evb.h b/include/lldp_evb.h
>> new file mode 100644
>> index 0000000..667f9ad
>> --- /dev/null
>> +++ b/include/lldp_evb.h
>> @@ -0,0 +1,80 @@
>> +/*******************************************************************************
>> +
>> + implementation of EVB TLVs for LLDP
>> + (c) Copyright IBM Corp. 2010
>> +
>> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
>> +
>> + This program is free software; you can redistribute it and/or modify it
>> + under the terms and conditions of the GNU General Public License,
>> + version 2, as published by the Free Software Foundation.
>> +
>> + This program is distributed in the hope it will be useful, but WITHOUT
>> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
>> + more details.
>> +
>> + You should have received a copy of the GNU General Public License along with
>> + this program; if not, write to the Free Software Foundation, Inc.,
>> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
>> +
>> + The full GNU General Public License is included in this distribution in
>> + the file called "COPYING".
>> +
>> +*******************************************************************************/
>> +
>> +#ifndef _LLDP_EVB_H
>> +#define _LLDP_EVB_H
>> +
>> +#include "lldp_mod.h"
>> +
>> +#define LLDP_MOD_EVB OUI_IEEE_8021Qbg
>> +#define LLDP_OUI_SUBTYPE { 0x00, 0x1b, 0x3f, 0x00 }
>> +
>> +typedef enum {
>> + EVB_OFFER_CAPABILITIES = 0,
>> + EVB_CONFIGURE,
>> + EVB_CONFIRMATION
>> +} evb_state;
>> +
>> +struct tlv_info_evb {
>> + u8 oui[3];
>> + u8 sub;
>> + /* supported forwarding mode */
>> + u8 smode;
>> + /* supported capabilities */
>> + u8 scap;
>> + /* currently configured forwarding mode */
>> + u8 cmode;
>> + /* currently configured capabilities */
>> + u8 ccap;
>> + /* supported no. of vsi */
>> + u16 svsi;
>> + /* currently configured no. of vsi */
>> + u16 cvsi;
>> + /* retransmission exponent */
>> + u8 rte;
>> +} __attribute__ ((__packed__));
>> +
>> +struct evb_data {
>> + char ifname[IFNAMSIZ];
>> + struct unpacked_tlv *evb;
>> + struct tlv_info_evb *tie;
>> + /* local policy */
>> + struct tlv_info_evb *policy;
>> + int state;
>> + LIST_ENTRY(evb_data) entry;
>> +};
>> +
>> +struct evb_user_data {
>> + LIST_HEAD(evb_head, evb_data) head;
>> +};
>> +
>> +struct lldp_module *evb_register(void);
>> +void evb_unregister(struct lldp_module *mod);
>> +struct packed_tlv *evb_gettlv(struct port *port);
>> +void evb_ifdown(char *);
>> +void evb_ifup(char *);
>> +struct evb_data *evb_data(char *ifname);
>> +
>> +#endif /* _LLDP_EVB_H */
>> diff --git a/include/lldp_evb_clif.h b/include/lldp_evb_clif.h
>> new file mode 100644
>> index 0000000..acaee5e
>> --- /dev/null
>> +++ b/include/lldp_evb_clif.h
>> @@ -0,0 +1,51 @@
>> +/*******************************************************************************
>> +
>> + implementation of EVB TLVs for LLDP
>> + (c) Copyright IBM Corp. 2010
>> +
>> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
>> +
>> + This program is free software; you can redistribute it and/or modify it
>> + under the terms and conditions of the GNU General Public License,
>> + version 2, as published by the Free Software Foundation.
>> +
>> + This program is distributed in the hope it will be useful, but WITHOUT
>> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
>> + more details.
>> +
>> + You should have received a copy of the GNU General Public License along with
>> + this program; if not, write to the Free Software Foundation, Inc.,
>> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
>> +
>> + The full GNU General Public License is included in this distribution in
>> + the file called "COPYING".
>> +
>> +*******************************************************************************/
>> +
>> +#ifndef _LLDP_EVB_CLIF_H
>> +#define _LLDP_EVB_CLIF_H
>> +
>> +struct lldp_module *evb_cli_register(void);
>> +void evb_cli_unregister(struct lldp_module *);
>> +int evb_print_tlv(u32, u16, char *);
>> +
>> +#define EVB_BUF_SIZE 256
>> +
>> +#define ARG_EVB_FORWARDING_MODE "fmode"
>> +
>> +#define VAL_EVB_FMODE_BRIDGE "bridge"
>> +#define VAL_EVB_FMODE_REFLECTIVE_RELAY "reflectiverelay"
>> +
>> +#define ARG_EVB_CAPABILITIES "capabilities"
>> +
>> +#define VAL_EVB_CAPA_RTE "rte"
>> +#define VAL_EVB_CAPA_ECP "ecp"
>> +#define VAL_EVB_CAPA_VDP "vdp"
>> +#define VAL_EVB_CAPA_NONE "none"
>> +
>> +#define ARG_EVB_VSIS "vsis"
>> +
>> +#define ARG_EVB_RTE "rte"
>> +
>> +#endif
>> diff --git a/include/lldp_evb_cmds.h b/include/lldp_evb_cmds.h
>> new file mode 100644
>> index 0000000..1367e5d
>> --- /dev/null
>> +++ b/include/lldp_evb_cmds.h
>> @@ -0,0 +1,31 @@
>> +/*******************************************************************************
>> +
>> + implementation of EVB TLVs for LLDP
>> + (c) Copyright IBM Corp. 2010
>> +
>> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
>> +
>> + This program is free software; you can redistribute it and/or modify it
>> + under the terms and conditions of the GNU General Public License,
>> + version 2, as published by the Free Software Foundation.
>> +
>> + This program is distributed in the hope it will be useful, but WITHOUT
>> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
>> + more details.
>> +
>> + You should have received a copy of the GNU General Public License along with
>> + this program; if not, write to the Free Software Foundation, Inc.,
>> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
>> +
>> + The full GNU General Public License is included in this distribution in
>> + the file called "COPYING".
>> +
>> +*******************************************************************************/
>> +
>> +#ifndef _LLDP_EVB_CMDS_H
>> +#define _LLDP_EVB_CMDS_H
>> +
>> +struct arg_handlers *evb_get_arg_handlers();
>> +
>> +#endif
>> diff --git a/include/lldp_tlv.h b/include/lldp_tlv.h
>> index a32cc71..fe3a75a 100644
>> --- a/include/lldp_tlv.h
>> +++ b/include/lldp_tlv.h
>> @@ -144,6 +144,7 @@ int tlv_ok(struct unpacked_tlv *tlv);
>> #define TLVID_8021(sub) TLVID(OUI_IEEE_8021, (sub))
>> #define TLVID_8023(sub) TLVID(OUI_IEEE_8023, (sub))
>> #define TLVID_MED(sub) TLVID(OUI_TIA_TR41, (sub))
>> +#define TLVID_8021Qbg(sub) TLVID(OUI_IEEE_8021Qbg, (sub))
>>
>> /* the size in bytes needed for a packed tlv from unpacked tlv */
>> #define TLVSIZE(t) ((t) ? (2 + (t)->length) : 0)
>> diff --git a/lldp_evb.c b/lldp_evb.c
>> new file mode 100644
>> index 0000000..4213137
>> --- /dev/null
>> +++ b/lldp_evb.c
>> @@ -0,0 +1,658 @@
>> +/*******************************************************************************
>> +
>> + implementation of EVB TLVs for LLDP
>> + (c) Copyright IBM Corp. 2010
>> +
>> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
>> +
>> + This program is free software; you can redistribute it and/or modify it
>> + under the terms and conditions of the GNU General Public License,
>> + version 2, as published by the Free Software Foundation.
>> +
>> + This program is distributed in the hope it will be useful, but WITHOUT
>> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
>> + more details.
>> +
>> + You should have received a copy of the GNU General Public License along with
>> + this program; if not, write to the Free Software Foundation, Inc.,
>> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
>> +
>> + The full GNU General Public License is included in this distribution in
>> + the file called "COPYING".
>> +
>> +*******************************************************************************/
>> +
>> +#include <net/if.h>
>> +#include <sys/queue.h>
>> +#include <sys/socket.h>
>> +#include <sys/ioctl.h>
>> +#include <sys/utsname.h>
>> +#include <linux/if_bridge.h>
>> +#include <string.h>
>> +#include "lldp.h"
>> +#include "lldp_evb.h"
>> +#include "messages.h"
>> +#include "config.h"
>> +#include "common.h"
>> +#include "lldp_mand_clif.h"
>> +#include "lldp_evb_clif.h"
>> +#include "lldp_evb_cmds.h"
>> +
>> +extern struct lldp_head lldp_head;
>> +
>> +struct evb_data *evb_data(char *ifname)
>> +{
>> + struct evb_user_data *ud;
>> + struct evb_data *ed = NULL;
>> +
>> + ud = find_module_user_data_by_if(ifname, &lldp_head, LLDP_MOD_EVB);
>> + if (ud) {
>> + LIST_FOREACH(ed, &ud->head, entry) {
>> + if (!strncmp(ifname, ed->ifname, IFNAMSIZ))
>> + return ed;
>> + }
>> + }
>> + return NULL;
>> +}
>> +
>> +static void evb_print_tlvinfo(struct tlv_info_evb *tie)
>> +{
>> + printf("%s(%i): supported forwarding mode: %02x\n", __FILE__, __LINE__, tie->smode);
>> + printf("%s(%i): configured forwarding mode: %02x\n", __FILE__, __LINE__, tie->cmode);
>> + printf("%s(%i): supported capabilities: %02x\n", __FILE__, __LINE__, tie->scap);
>> + printf("%s(%i): configured capabilities: %02x\n", __FILE__, __LINE__, tie->ccap);
>> + printf("%s(%i): supported no. of vsis: %04i\n", __FILE__, __LINE__, tie->svsi);
>> + printf("%s(%i): configured no. of vsis: %04i\n", __FILE__, __LINE__, tie->cvsi);
>> + printf("%s(%i): rte: %02i\n\n", __FILE__, __LINE__, tie->rte);
>> +}
>> +
>> +/*
>> + * evb_bld_cfg_tlv - build the EVB TLV
>> + * @ed: the evb data struct
>> + *
>> + * Returns 0 on success
>> + */
>> +static int evb_bld_cfg_tlv(struct evb_data *ed)
>> +{
>> + int rc = 0;
>> + int i;
>> + struct unpacked_tlv *tlv = NULL;
>> +
>> + /* free ed->evb if it exists */
>> + FREE_UNPKD_TLV(ed, evb);
>> +
>> + if (!is_tlv_txenabled(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
>> + fprintf(stderr, "%s:%s:EVB tx is currently disabled !\n",
>> + __func__, ed->ifname);
>> + rc = EINVAL;
>> + goto out_err;
>> + }
>> +
>> + tlv = create_tlv();
>> + if (!tlv)
>> + goto out_err;
>> +
>> + tlv->type = ORG_SPECIFIC_TLV;
>> + tlv->length = sizeof(struct tlv_info_evb);
>> + tlv->info = (u8 *)malloc(tlv->length);
>> + if(!tlv->info) {
>> + free(tlv);
>> + tlv = NULL;
>> + rc = ENOMEM;
>> + goto out_err;
>> + }
>> + memcpy(tlv->info, ed->tie, tlv->length);
>> +
>> + printf("### %s:type %i, length %i, info ", __func__, tlv->type, tlv->length);
>> +
>> + for (i=0; i < tlv->length; i++) {
>> + printf("%02x ", tlv->info[i]);
>> + }
>> +
>
> Remove the extra braces around the for statement. Granted the rest of
> lldpad may not follow a consistent coding style but lets try going
> forward and hopefully I get around to lldpad soon.
>
>
>> + printf("\n");
>> +
>> + ed->evb = tlv;
>> +out_err:
>> + return rc;
>> +}
>> +
>> +static void evb_free_tlv(struct evb_data *ed)
>> +{
>> + if (ed) {
>> + FREE_UNPKD_TLV(ed, evb);
>> + }
>
> Same here extra braces.
>
>> +}
>> +
>> +/* evb_init_cfg_tlv:
>> + *
>> + * fill up tlv_info_evb structure with reasonable info
>> + */
>> +static int evb_init_cfg_tlv(struct evb_data *ed)
>> +{
>> + char arg_path[EVB_BUF_SIZE];
>> + char *param;
>> +
>> + /* load policy from config */
>> + ed->policy = (struct tlv_info_evb *) calloc(1, sizeof(struct tlv_info_evb));
>
> Use malloc instead of callod() of one.
>
On second thought disregard this nit. Keep the calloc() calls if you want and ignore the comment. I guess you save a memset() this way...
Thanks,
John
^ permalink raw reply
* Re: [E1000-eedc] [PATCH 06/10] VDP commandline interface
From: John Fastabend @ 2010-09-23 0:57 UTC (permalink / raw)
To: Jens Osterkamp
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <1282739262-14968-7-git-send-email-jens@linux.vnet.ibm.com>
On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
> This patch implements the command line interface to control the VDP module.
> In station role, it allows to register a new VSI (guest interface) profile
> and query its state. In bridge role, it allows to query the state of all
> registered profiles.
> With lldptool it is possible to set the role from default "station" to
> "bridge".
> The configuration of the role for a port is saved to lldpads config file.
>
> Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
> ---
> Makefile.am | 12 +-
> include/lldp_vdp_clif.h | 39 +++++
> include/lldp_vdp_cmds.h | 44 ++++++
> lldp_vdp_clif.c | 136 ++++++++++++++++
> lldp_vdp_cmds.c | 394 +++++++++++++++++++++++++++++++++++++++++++++++
> lldptool.c | 2 +
> 6 files changed, 622 insertions(+), 5 deletions(-)
> create mode 100644 include/lldp_vdp_clif.h
> create mode 100644 include/lldp_vdp_cmds.h
> create mode 100644 lldp_vdp_clif.c
> create mode 100644 lldp_vdp_cmds.c
>
> diff --git a/Makefile.am b/Makefile.am
> index 4b69389..9a3baf4 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -37,7 +37,8 @@ lldpad_include_HEADERS = include/dcb_types.h include/dcbtool.h \
> include/dcb_osdep.h include/clif.h include/lldp_dcbx_cmds.h include/common.h \
> include/lldpad.h include/os.h include/includes.h include/lldp_mand_cmds.h \
> include/clif_msgs.h include/lldp_basman_cmds.h include/lldp_8023_cmds.h \
> -include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h
> +include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h \
> +include/lldp_vdp_cmds.h
>
> noinst_HEADERS = include/config.h include/ctrl_iface.h \
> include/dcb_driver_if_types.h include/dcb_driver_interface.h \
> @@ -47,7 +48,7 @@ include/event_iface.h include/messages.h include/parse_cli.h include/version.h \
> include/lldptool_cli.h include/list.h \
> include/lldp_mand_clif.h include/lldp_basman_clif.h include/lldp_med_clif.h \
> include/lldp_8023_clif.h include/lldp_dcbx_clif.h include/lldptool.h \
> -include/lldp_rtnl.h include/lldp_evb_clif.h
> +include/lldp_rtnl.h include/lldp_evb_clif.h include/lldp_vdp_clif.h
>
> lldpad_SOURCES = lldpad.c config.c drv_cfg.c ctrl_iface.c event_iface.c eloop.c \
> common.c os_unix.c lldp_dcbx_cmds.c log.c lldpad_shm.c \
> @@ -64,20 +65,21 @@ lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
> lldp_util.c include/lldp_util.h \
> lldp_mand.c include/lldp_mand.h \
> lldp_mand_cmds.c lldp_basman_cmds.c lldp_8023_cmds.c lldp_med_cmds.c \
> -lldp_evb_cmds.c \
> +lldp_evb_cmds.c lldp_vdp_cmds.c \
> lldp_tlv.c include/lldp_tlv.h \
> lldp_basman.c include/lldp_basman.h \
> lldp_med.c include/lldp_med.h \
> lldp_8023.c include/lldp_8023.h \
> lldp_evb.c include/lldp_evb.h \
> -lldp_vdp.c include/lldp_vdp.h
> +lldp_vdp.c include/lldp_vdp.h \
> +lldp_vdp_cmds.h
>
> dcbtool_SOURCES = dcbtool.c clif.c dcbtool_cmds.c parse_cli.l \
> $(lldpad_include_HEADERS) $(noinst_HEADERS)
>
> lldptool_SOURCES = lldptool.c clif.c lldptool_cmds.c common.c os_unix.c \
> lldp_mand_clif.c lldp_basman_clif.c lldp_med_clif.c lldp_8023_clif.c \
> -lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) \
> +lldp_dcbx_clif.c lldp_evb_clif.c lldp_vdp_clif.c $(lldpad_include_HEADERS) \
> $(noinst_HEADERS)
>
> nltest_SOURCES = nltest.c nltest.h
> diff --git a/include/lldp_vdp_clif.h b/include/lldp_vdp_clif.h
> new file mode 100644
> index 0000000..adb6333
> --- /dev/null
> +++ b/include/lldp_vdp_clif.h
> @@ -0,0 +1,39 @@
> +/*******************************************************************************
> +
> + implementation of VDP according to IEEE 802.1Qbg
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#ifndef _LLDP_VDP_CLIF_H
> +#define _LLDP_VDP_CLIF_H
> +
> +struct lldp_module *vdp_cli_register(void);
> +void vdp_cli_unregister(struct lldp_module *);
> +int vdp_print_tlv(u32, u16, char *);
> +
> +#define VDP_BUF_SIZE 256
> +
> +#define VDP_PREFIX "vdp"
> +#define ARG_VDP_MODE "mode"
> +#define ARG_VDP_ROLE "role"
> +
> +#endif
> diff --git a/include/lldp_vdp_cmds.h b/include/lldp_vdp_cmds.h
> new file mode 100644
> index 0000000..5e64c27
> --- /dev/null
> +++ b/include/lldp_vdp_cmds.h
> @@ -0,0 +1,44 @@
> +/*******************************************************************************
> +
> + implementation of VDP according to IEEE 802.1Qbg
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#ifndef _LLDP_VDP_CMDS_H
> +#define _LLDP_VDP_CMDS_H
> +
> +struct arg_handlers *vdp_get_arg_handlers();
> +
> +enum {
> + MODE = 0,
> + MGRID,
> + TYPEID,
> + TYPEIDVERSION,
> + INSTANCEID,
> + MAC,
> + VLAN,
> +};
> +
> +#define VAL_STATION "station"
> +#define VAL_BRIDGE "bridge"
> +
> +#endif
> diff --git a/lldp_vdp_clif.c b/lldp_vdp_clif.c
> new file mode 100644
> index 0000000..aa357e9
> --- /dev/null
> +++ b/lldp_vdp_clif.c
> @@ -0,0 +1,136 @@
> +/*******************************************************************************
> +
> + implementation of VDP according to IEEE 802.1Qbg
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#include "includes.h"
> +#include "common.h"
> +#include <stdio.h>
> +#include <syslog.h>
> +#include <sys/un.h>
> +#include <sys/stat.h>
> +#include "lldp_mod.h"
> +#include "lldptool.h"
> +#include "lldp.h"
> +#include "lldp_vdp.h"
> +#include "lldp_vdp_clif.h"
> +
> +void vdp_print_cfg_tlv(u16, char *info);
> +int vdp_print_help();
> +
> +u32 vdp_lookup_tlv_name(char *tlvid_str);
> +
snip
> +
> +static int get_arg_mode(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + char *s, *t;
> + struct vsi_profile *np;
> + struct vdp_data *vd;
> +
> + if (cmd->cmd != cmd_gettlv)
> + return cmd_invalid;
> +
> + switch (cmd->tlvid) {
> + case ((LLDP_MOD_VDP) << 8) | LLDP_VDP_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + s = t = malloc(VDP_BUF_SIZE);
memory leak on s or maybe I missed something.
> + if (!s)
> + return cmd_invalid;
> + memset(s, 0, VDP_BUF_SIZE);
> +
> + vd = vdp_data(cmd->ifname);
> + if (!vd) {
> + printf("%s(%i): vdp_data for %s not found !\n", __func__, __LINE__,
> + cmd->ifname);
> + return cmd_invalid;
> + }
> +
> + LIST_FOREACH(np, &vd->profile_head, profile) {
> + PRINT_PROFILE(t, np);
> + }
> +
> + sprintf(obuf, "%02x%s%04x%s", (unsigned int) strlen(arg), arg,
> + (unsigned int) strlen(s), s);
> +
> + return cmd_success;
> +}
> +
Thanks,
John.
^ permalink raw reply
* Re: [E1000-eedc] [PATCH 05/10] implementation of VDP
From: John Fastabend @ 2010-09-23 0:55 UTC (permalink / raw)
To: Jens Osterkamp
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <1282739262-14968-6-git-send-email-jens@linux.vnet.ibm.com>
On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
> This patch contains an initial implemention of VDP as specified in IEEE
> 802.1Qbg.
> VDP serves as the upper layer protocol (ULP) for TLVs communicated via the
> ECP protocol.
> For this it registers as a new module in lldpad. The VDP module supports a
> station and a bridge role. As a station, new VSI (virtual station interface)
> profiles can be registered to the VDP module using lldptool or libvirt.
> These profiles are then announced to an adjacent switch. Transmitted profiles
> are processed to the desired state by the VDP station state machine.
> As a bridge, the VDP module waits for new profiles received in TLVs by ECP.
> The received profiles are processed to the desired state by a VDP bridge
> state machine.
>
> VDP module parameters are stored in the "vdp" section under the appropriate
> interface.
>
> The patch still contains a lot of debug code to allow analysis of VDP
> protocol behavior.
>
> Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
> ---
> Makefile.am | 8 +-
> ecp/ecp.c | 22 +-
> ecp/ecp.h | 19 +-
> ecp/ecp_rx.c | 350 ++++++++--------
> ecp/ecp_tx.c | 292 ++++++++------
> include/lldp.h | 1 +
> include/lldp_vdp.h | 10 +-
> lldp/ports.h | 14 -
> lldp_vdp.c | 1140 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> lldpad.c | 2 +
> 10 files changed, 1517 insertions(+), 341 deletions(-)
> create mode 100644 lldp_vdp.c
>
>
snip
>
> /* ecp_build_ECPDU - create an ecp protocol data unit
> - * @port: currently used port
> + * @vd: currently used port
> * @mode: mode to create pdu with (REQ or ACK)
> *
> * returns true on success, false on failure
> @@ -86,7 +88,7 @@ void ecp_print_frameout(struct port *port)
> * or ACK mode, plus a list of packed TLVs created from the profiles on this
> * port.
> */
> -bool ecp_build_ECPDU(struct port *port, int mode)
> +bool ecp_build_ECPDU(struct vdp_data *vd, int mode)
> {
> struct l2_ethhdr eth;
> struct ecp_hdr ecp_hdr;
> @@ -94,28 +96,26 @@ bool ecp_build_ECPDU(struct port *port, int mode)
> u32 fb_offset = 0;
> u32 datasize = 0;
> struct packed_tlv *ptlv = NULL;
> - struct lldp_module *np;
> - struct vdp_data *vd;
> struct vsi_profile *p;
>
> - if (port->ecp.tx.frameout) {
> - free(port->ecp.tx.frameout);
> - port->ecp.tx.frameout = NULL;
> + if (vd->ecp.tx.frameout) {
> + free(vd->ecp.tx.frameout);
> + vd->ecp.tx.frameout = NULL;
> }
>
> /* TODO: different multicast address for sending ECP over S-channel (multi_cast_source_s)
> * S-channels to implement later */
> memcpy(eth.h_dest, multi_cast_source, ETH_ALEN);
> - l2_packet_get_own_src_addr(port->ecp.l2,(u8 *)&own_addr);
> + l2_packet_get_own_src_addr(vd->ecp.l2,(u8 *)&own_addr);
> memcpy(eth.h_source, &own_addr, ETH_ALEN);
> eth.h_proto = htons(ETH_P_ECP);
> - port->ecp.tx.frameout = (u8 *)malloc(ETH_FRAME_LEN);
> - if (port->ecp.tx.frameout == NULL) {
> + vd->ecp.tx.frameout = (u8 *)malloc(ETH_FRAME_LEN);
> + if (vd->ecp.tx.frameout == NULL) {
> printf("InfoECPDU: Failed to malloc frame buffer \n");
> return false;
> }
> - memset(port->ecp.tx.frameout,0,ETH_FRAME_LEN);
> - memcpy(port->ecp.tx.frameout, (void *)ð, sizeof(struct l2_ethhdr));
> + memset(vd->ecp.tx.frameout,0,ETH_FRAME_LEN);
> + memcpy(vd->ecp.tx.frameout, (void *)ð, sizeof(struct l2_ethhdr));
> fb_offset += sizeof(struct l2_ethhdr);
>
> ecp_hdr.oui[0] = 0x0;
> @@ -134,111 +134,140 @@ bool ecp_build_ECPDU(struct port *port, int mode)
> break;
> default:
> printf("%s(%i): unknown mode for %s !\n", __func__, __LINE__,
> - port->ifname);
> + vd->ifname);
> }
>
> - ecp_hdr.seqnr = port->ecp.lastSequence;
> + ecp_hdr.seqnr = vd->ecp.lastSequence;
>
> if ((sizeof(struct ecp_hdr)+fb_offset) > ETH_MAX_DATA_LEN)
> goto error;
> - memcpy(port->ecp.tx.frameout+fb_offset, (void *)&ecp_hdr, sizeof(struct ecp_hdr));
> + memcpy(vd->ecp.tx.frameout+fb_offset, (void *)&ecp_hdr, sizeof(struct ecp_hdr));
> datasize += sizeof(struct ecp_hdr);
> fb_offset += sizeof(struct ecp_hdr);
>
> - /* TODO: create tlvs from profiles here */
> + /* create packed_tlvs for all profiles on this interface */
> + LIST_FOREACH(p, &vd->profile_head, profile) {
> + if(!p) {
> + printf("%s(%i): list vd->profile_head empty !\n", __func__, __LINE__);
> + continue;
> + }
> +
> + if (p->localChange != mode) {
> + printf("%s(%i): not sending out profile !\n", __func__, __LINE__);
> + continue;
> + }
> +
> + ptlv = vdp_gettlv(vd, p);
> +
> + if(!ptlv) {
> + printf("%s(%i): ptlv not created !\n", __func__, __LINE__);
> + continue;
> + }
> +
> + if (ptlv) {
> + if ((ptlv->size+fb_offset) > ETH_MAX_DATA_LEN)
> + goto error;
> + memcpy(vd->ecp.tx.frameout+fb_offset,
> + ptlv->tlv, ptlv->size);
> + datasize += ptlv->size;
> + fb_offset += ptlv->size;
> + }
> + }
>
> /* The End TLV marks the end of the LLDP PDU */
> ptlv = pack_end_tlv();
> if (!ptlv || ((ptlv->size + fb_offset) > ETH_MAX_DATA_LEN))
> goto error;
> - memcpy(port->ecp.tx.frameout + fb_offset, ptlv->tlv, ptlv->size);
> + memcpy(vd->ecp.tx.frameout + fb_offset, ptlv->tlv, ptlv->size);
> datasize += ptlv->size;
> fb_offset += ptlv->size;
> ptlv = free_pkd_tlv(ptlv);
>
> if (datasize < ETH_MIN_DATA_LEN)
> - port->ecp.tx.sizeout = ETH_MIN_PKT_LEN;
> + vd->ecp.tx.sizeout = ETH_MIN_PKT_LEN;
check ETH_MAX_DATA_LEN here as well as min length.
> else
> - port->ecp.tx.sizeout = fb_offset;
> + vd->ecp.tx.sizeout = fb_offset;
>
> return true;
>
> error:
> ptlv = free_pkd_tlv(ptlv);
> - if (port->ecp.tx.frameout)
> - free(port->ecp.tx.frameout);
> - port->ecp.tx.frameout = NULL;
> + if (vd->ecp.tx.frameout)
> + free(vd->ecp.tx.frameout);
> + vd->ecp.tx.frameout = NULL;
> printf("InfoECPDU: packed TLV too large for tx frame\n");
> return false;
> }
>
> /* ecp_tx_Initialize - initializes the ecp tx state machine
> - * @port: currently used port
> + * @vd: currently used port
> *
> * no return value
> *
> * initializes some variables for the ecp tx state machine.
> */
> -void ecp_tx_Initialize(struct port *port)
> +void ecp_tx_Initialize(struct vdp_data *vd)
> {
> - if (port->ecp.tx.frameout) {
> - free(port->ecp.tx.frameout);
> - port->ecp.tx.frameout = NULL;
> + if (vd->ecp.tx.frameout) {
> + free(vd->ecp.tx.frameout);
> + vd->ecp.tx.frameout = NULL;
> }
> - port->ecp.tx.localChange = VDP_PROFILE_REQ;
> - port->ecp.lastSequence = ECP_SEQUENCE_NR_START;
> - port->ecp.stats.statsFramesOutTotal = 0;
> - port->ecp.ackTimerExpired = false;
> - port->ecp.retries = 0;
> - l2_packet_get_port_state(port->ecp.l2, (u8 *)&(port->portEnabled));
> + vd->ecp.tx.localChange = VDP_PROFILE_REQ;
> + vd->ecp.lastSequence = ECP_SEQUENCE_NR_START;
> + vd->ecp.stats.statsFramesOutTotal = 0;
> + vd->ecp.ackTimerExpired = false;
> + vd->ecp.retries = 0;
> +
> + struct port *port = port_find_by_name(vd->ifname);
> + l2_packet_get_port_state(vd->ecp.l2, (u8 *)&(port->portEnabled));
>
> return;
> }
>
> /* ecp_txFrame - transmit ecp frame
> - * @port: currently used port
> + * @vd: currently used port
> *
> * returns the number of characters sent on success, -1 on failure
> *
> * sends out the frame stored in the frameout structure using l2_packet_send.
> */
> -u8 ecp_txFrame(struct port *port)
> +u8 ecp_txFrame(struct vdp_data *vd)
> {
> int status = 0;
>
> - status = l2_packet_send(port->ecp.l2, (u8 *)&multi_cast_source,
> - htons(ETH_P_ECP),port->ecp.tx.frameout,port->ecp.tx.sizeout);
> - port->ecp.stats.statsFramesOutTotal++;
> + status = l2_packet_send(vd->ecp.l2, (u8 *)&multi_cast_source,
> + htons(ETH_P_ECP),vd->ecp.tx.frameout,vd->ecp.tx.sizeout);
> + vd->ecp.stats.statsFramesOutTotal++;
>
> return status;
> }
>
> /* ecp_tx_create_frame - create ecp frame
> - * @port: currently used port
> + * @vd: currently used port
> *
> * no return value
> *
> *
> */
> -void ecp_tx_create_frame(struct port *port)
> +void ecp_tx_create_frame(struct vdp_data *vd)
> {
> /* send REQs */
> - if (port->ecp.tx.localChange & VDP_PROFILE_REQ) {
> - printf("%s(%i)-%s: sending REQs\n", __func__, __LINE__, port->ifname);
> - ecp_build_ECPDU(port, VDP_PROFILE_REQ);
> - ecp_print_frameout(port);
> - ecp_txFrame(port);
> + if (vd->ecp.tx.localChange & VDP_PROFILE_REQ) {
> + printf("%s(%i)-%s: sending REQs\n", __func__, __LINE__, vd->ifname);
> + ecp_build_ECPDU(vd, VDP_PROFILE_REQ);
> + ecp_print_frameout(vd);
> + ecp_txFrame(vd);
> }
>
> /* send ACKs */
> - if (port->ecp.tx.localChange & VDP_PROFILE_ACK) {
> - printf("%s(%i)-%s: sending ACKs\n", __func__, __LINE__, port->ifname);
> - ecp_build_ECPDU(port, VDP_PROFILE_ACK);
> - ecp_print_frameout(port);
> - ecp_txFrame(port);
> + if (vd->ecp.tx.localChange & VDP_PROFILE_ACK) {
> + printf("%s(%i)-%s: sending ACKs\n", __func__, __LINE__, vd->ifname);
> + ecp_build_ECPDU(vd, VDP_PROFILE_ACK);
> + ecp_print_frameout(vd);
> + ecp_txFrame(vd);
> }
>
> - port->ecp.tx.localChange = 0;
> + vd->ecp.tx.localChange = 0;
> return;
> }
>
> @@ -253,32 +282,32 @@ void ecp_tx_create_frame(struct port *port)
> */
> static void ecp_tx_timeout_handler(void *eloop_data, void *user_ctx)
> {
> - struct port *port;
> + struct vdp_data *vd;
>
> - port = (struct port *) user_ctx;
> + vd = (struct vdp_data *) user_ctx;
>
> - port->ecp.ackTimerExpired = true;
> + vd->ecp.ackTimerExpired = true;
>
> printf("%s(%i)-%s: timer expired\n", __func__, __LINE__,
> - port->ifname);
> + vd->ifname);
>
> - ecp_tx_run_sm(port);
> + ecp_tx_run_sm(vd);
> }
>
> /* ecp_tx_stop_ackTimer - stop the ECP ack timer
> - * @port: currently used port
> + * @vd: currently used port
> *
> * returns the number of removed handlers
> *
> * stops the ECP ack timer. used when a ack frame for the port has been
> * received.
> */
> -static int ecp_tx_stop_ackTimer(struct port *port)
> +static int ecp_tx_stop_ackTimer(struct vdp_data *vd)
> {
> printf("%s(%i)-%s: stopping timer\n", __func__, __LINE__,
> - port->ifname);
> + vd->ifname);
>
> - return eloop_cancel_timeout(ecp_tx_timeout_handler, NULL, (void *) port);
> + return eloop_cancel_timeout(ecp_tx_timeout_handler, NULL, (void *) vd);
> }
>
> /* ecp_tx_start_ackTimer - starts the ECP ack timer
> @@ -288,23 +317,23 @@ static int ecp_tx_stop_ackTimer(struct port *port)
> *
> * starts the ack timer when a frame has been sent out.
> */
> -static void ecp_tx_start_ackTimer(struct port *port)
> +static void ecp_tx_start_ackTimer(struct vdp_data *vd)
> {
> unsigned int secs, usecs;
>
> - port->ecp.ackTimerExpired = false;
> + vd->ecp.ackTimerExpired = false;
>
> secs = ECP_TRANSMISSION_TIMER / ECP_TRANSMISSION_DIVIDER;
> usecs = ECP_TRANSMISSION_TIMER % ECP_TRANSMISSION_DIVIDER;
>
> printf("%s(%i)-%s: starting timer\n", __func__, __LINE__,
> - port->ifname);
> + vd->ifname);
>
> - eloop_register_timeout(secs, usecs, ecp_tx_timeout_handler, NULL, (void *) port);
> + eloop_register_timeout(secs, usecs, ecp_tx_timeout_handler, NULL, (void *) vd);
> }
>
> /* ecp_tx_change_state - changes the ecp tx sm state
> - * @port: currently used port
> + * @vd: currently used port
> * @newstate: new state for the sm
> *
> * no return value
> @@ -312,39 +341,36 @@ static void ecp_tx_start_ackTimer(struct port *port)
> * checks state transistion for consistency and finally changes the state of
> * the profile.
> */
> -static void ecp_tx_change_state(struct port *port, u8 newstate)
> +static void ecp_tx_change_state(struct vdp_data *vd, u8 newstate)
> {
> switch(newstate) {
> - case ECP_TX_IDLE:
> - break;
> case ECP_TX_INIT_TRANSMIT:
> - assert(port->ecp.tx.state == ECP_TX_IDLE);
> break;
> case ECP_TX_TRANSMIT_ECPDU:
> - assert((port->ecp.tx.state == ECP_TX_INIT_TRANSMIT) ||
> - (port->ecp.tx.state == ECP_TX_WAIT_FOR_ACK) ||
> - (port->ecp.tx.state == ECP_TX_REQUEST_PDU));
> + assert((vd->ecp.tx.state == ECP_TX_INIT_TRANSMIT) ||
> + (vd->ecp.tx.state == ECP_TX_WAIT_FOR_ACK) ||
> + (vd->ecp.tx.state == ECP_TX_REQUEST_PDU));
> break;
> case ECP_TX_WAIT_FOR_ACK:
> - assert(port->ecp.tx.state == ECP_TX_TRANSMIT_ECPDU);
> + assert(vd->ecp.tx.state == ECP_TX_TRANSMIT_ECPDU);
> break;
> case ECP_TX_REQUEST_PDU:
> - assert(port->ecp.tx.state == ECP_TX_WAIT_FOR_ACK);
> + assert(vd->ecp.tx.state == ECP_TX_WAIT_FOR_ACK);
> break;
> default:
> printf("ERROR: The ECP_TX State Machine is broken!\n");
> - log_message(MSG_ERR_TX_SM_INVALID, "%s", port->ifname);
> + log_message(MSG_ERR_TX_SM_INVALID, "%s", vd->ifname);
> }
>
> printf("%s(%i)-%s: state change %s -> %s\n", __func__, __LINE__,
> - port->ifname, ecp_tx_states[port->ecp.tx.state], ecp_tx_states[newstate]);
> + vd->ifname, ecp_tx_states[vd->ecp.tx.state], ecp_tx_states[newstate]);
>
> - port->ecp.tx.state = newstate;
> + vd->ecp.tx.state = newstate;
> return;
> }
>
> /* ecp_set_tx_state - sets the ecp tx sm state
> - * @port: currently used port
> + * @vd: currently used port
> *
> * returns true or false
> *
> @@ -352,116 +378,116 @@ static void ecp_tx_change_state(struct port *port, u8 newstate)
> * variables. returns true or false depending on wether the state machine
> * can be run again with the new state or can stop at the current state.
> */
> -static bool ecp_set_tx_state(struct port *port)
> +static bool ecp_set_tx_state(struct vdp_data *vd)
> {
> + struct port *port = port_find_by_name(vd->ifname);
> +
> + if (!port) {
> + printf("%s(%i): port not found !\n", __func__, __LINE__);
> + return 0;
> + }
> +
> if ((port->portEnabled == false) && (port->prevPortEnabled == true)) {
> printf("set_tx_state: port was disabled\n");
> - ecp_tx_change_state(port, ECP_TX_INIT_TRANSMIT);
> + ecp_tx_change_state(vd, ECP_TX_INIT_TRANSMIT);
> }
> port->prevPortEnabled = port->portEnabled;
>
> - switch (port->ecp.tx.state) {
> - case ECP_TX_IDLE:
> - if (port->portEnabled) {
> - ecp_tx_change_state(port, ECP_TX_INIT_TRANSMIT);
> - return true;
> - }
> - return false;
> + switch (vd->ecp.tx.state) {
> case ECP_TX_INIT_TRANSMIT:
> if (port->portEnabled && ((port->adminStatus == enabledRxTx) ||
> (port->adminStatus == enabledTxOnly))) {
> - ecp_tx_change_state(port, ECP_TX_TRANSMIT_ECPDU);
> + ecp_somethingChangedLocal(vd, VDP_PROFILE_REQ);
> + ecp_tx_change_state(vd, ECP_TX_TRANSMIT_ECPDU);
> return true;
> }
> return false;
> case ECP_TX_TRANSMIT_ECPDU:
> if ((port->adminStatus == disabled) ||
> (port->adminStatus == enabledRxOnly)) {
> - ecp_tx_change_state(port, ECP_TX_INIT_TRANSMIT);
> + ecp_tx_change_state(vd, ECP_TX_INIT_TRANSMIT);
> return true;
> }
> - ecp_tx_change_state(port, ECP_TX_WAIT_FOR_ACK);
> + ecp_tx_change_state(vd, ECP_TX_WAIT_FOR_ACK);
> return true;
> case ECP_TX_WAIT_FOR_ACK:
> - if (port->ecp.ackTimerExpired) {
> - port->ecp.retries++;
> - if (port->ecp.retries < ECP_MAX_RETRIES) {
> - ecp_somethingChangedLocal(port, VDP_PROFILE_REQ);
> - ecp_tx_change_state(port, ECP_TX_TRANSMIT_ECPDU);
> + if (vd->ecp.ackTimerExpired) {
> + vd->ecp.retries++;
> + if (vd->ecp.retries < ECP_MAX_RETRIES) {
> + ecp_somethingChangedLocal(vd, VDP_PROFILE_REQ);
> + ecp_tx_change_state(vd, ECP_TX_TRANSMIT_ECPDU);
> return true;
> }
> - if (port->ecp.retries == ECP_MAX_RETRIES) {
> + if (vd->ecp.retries == ECP_MAX_RETRIES) {
> printf("%s(%i)-%s: 1 \n", __func__, __LINE__,
> - port->ifname);
> - ecp_tx_change_state(port, ECP_TX_REQUEST_PDU);
> + vd->ifname);
> + ecp_tx_change_state(vd, ECP_TX_REQUEST_PDU);
> return true;
> }
> }
> - if (port->ecp.ackReceived && port->ecp.seqECPDU == port->ecp.lastSequence) {
> - port->ecp.ackReceived = false;
> - ecp_tx_change_state(port, ECP_TX_REQUEST_PDU);
> + if (vd->ecp.ackReceived && vd->ecp.seqECPDU == vd->ecp.lastSequence) {
> + vd->ecp.ackReceived = false;
> + ecp_tx_change_state(vd, ECP_TX_REQUEST_PDU);
> return true;
> }
> return false;
> case ECP_TX_REQUEST_PDU:
> - if (port->ecp.tx.localChange & VDP_PROFILE_REQ) {
> - ecp_tx_change_state(port, ECP_TX_TRANSMIT_ECPDU);
> + if (vd->ecp.tx.localChange & VDP_PROFILE_REQ) {
> + ecp_tx_change_state(vd, ECP_TX_TRANSMIT_ECPDU);
> return true;
> }
> return false;
> default:
> printf("ERROR: The TX State Machine is broken!\n");
> - log_message(MSG_ERR_TX_SM_INVALID, "%s", port->ifname);
> + log_message(MSG_ERR_TX_SM_INVALID, "%s", vd->ifname);
> return false;
> }
> }
>
> /* ecp_tx_run_sm - state machine for ecp tx
> - * @port: currently used port
> + * @vd: currently used vdp_data
> *
> * no return value
> *
> * runs the state machine for ecp tx.
> */
> -void ecp_tx_run_sm(struct port *port)
> +void ecp_tx_run_sm(struct vdp_data *vd)
> {
> do {
> printf("%s(%i)-%s: ecp_tx - %s\n", __func__, __LINE__,
> - port->ifname, ecp_tx_states[port->ecp.tx.state]);
> + vd->ifname, ecp_tx_states[vd->ecp.tx.state]);
>
> - switch(port->ecp.tx.state) {
> - case ECP_TX_IDLE:
> - break;
> + switch(vd->ecp.tx.state) {
> case ECP_TX_INIT_TRANSMIT:
> - ecp_tx_Initialize(port);
> + ecp_tx_Initialize(vd);
> break;
> case ECP_TX_TRANSMIT_ECPDU:
> - ecp_tx_create_frame(port);
> - ecp_tx_start_ackTimer(port);
> + ecp_tx_create_frame(vd);
> + ecp_tx_start_ackTimer(vd);
> break;
> case ECP_TX_WAIT_FOR_ACK:
> - if (port->ecp.ackReceived) {
> + if (vd->ecp.ackReceived) {
> printf("%s(%i)-%s: ECP_TX_WAIT_FOR_ACK ackReceived\n", __func__, __LINE__,
> - port->ifname);
> + vd->ifname);
> printf("%s(%i)-%s: 2: seqECPDU %x lastSequence %x \n", __func__, __LINE__,
> - port->ifname, port->ecp.seqECPDU, port->ecp.lastSequence);
> - port->ecp.tx.localChange = 0;
> - ecp_tx_stop_ackTimer(port);
> - ecp_rx_ProcessFrame(port);
> + vd->ifname, vd->ecp.seqECPDU, vd->ecp.lastSequence);
> + vd->ecp.tx.localChange = 0;
> + ecp_tx_stop_ackTimer(vd);
> + ecp_rx_ProcessFrame(vd);
> }
> break;
> case ECP_TX_REQUEST_PDU:
> - port->ecp.retries = 0;
> - port->ecp.lastSequence++;
> + vd->ecp.retries = 0;
> + vd->ecp.lastSequence++;
> printf("%s(%i)-%s: ECP_TX_REQUEST_PDU lastSequence %x\n", __func__, __LINE__,
> - port->ifname, port->ecp.lastSequence++);
> + vd->ifname, vd->ecp.lastSequence++);
> break;
> default:
> printf("%s(%i): ERROR The TX State Machine is broken!\n", __func__,
> __LINE__);
> - log_message(MSG_ERR_TX_SM_INVALID, "%s", port->ifname);
> + log_message(MSG_ERR_TX_SM_INVALID, "%s", vd->ifname);
> }
> - } while (ecp_set_tx_state(port) == true);
> + } while (ecp_set_tx_state(vd) == true);
>
> return;
> }
> diff --git a/include/lldp.h b/include/lldp.h
> index e00ba7a..fd515cd 100644
> --- a/include/lldp.h
> +++ b/include/lldp.h
> @@ -190,6 +190,7 @@ enum {
>
> /* IEEE 802.1Qbg subtype */
> #define LLDP_EVB_SUBTYPE 0
> +#define LLDP_VDP_SUBTYPE 0x2
>
> /* forwarding mode */
> #define LLDP_EVB_CAPABILITY_FORWARD_STANDARD (1 << 7)
> diff --git a/include/lldp_vdp.h b/include/lldp_vdp.h
> index 43200af..b97d8c0 100644
> --- a/include/lldp_vdp.h
> +++ b/include/lldp_vdp.h
> @@ -27,6 +27,7 @@
> #define _LLDP_VDP_H
>
> #include "lldp_mod.h"
> +#include "ecp/ecp.h"
>
> #define LLDP_MOD_VDP OUI_IEEE_8021Qbg+1
>
> @@ -101,7 +102,7 @@ struct vsi_profile {
> int mode;
> int response;
> u8 mgrid;
> - u8 id[3];
> + int id;
> u8 version;
> u8 instance[16];
> u8 mac[6]; /* TODO: currently only one MAC/VLAN pair supported, more later */
> @@ -116,6 +117,7 @@ struct vsi_profile {
>
> struct vdp_data {
> char ifname[IFNAMSIZ];
> + struct ecp ecp;
> struct unpacked_tlv *vdp;
> int role;
> LIST_HEAD(profile_head, vsi_profile) profile_head;
> @@ -129,7 +131,7 @@ struct vdp_user_data {
> struct lldp_module *vdp_register(void);
> void vdp_unregister(struct lldp_module *mod);
> struct vdp_data *vdp_data(char *ifname);
> -struct packed_tlv *vdp_gettlv(struct port *port, struct vsi_profile *profile);
> +struct packed_tlv *vdp_gettlv(struct vdp_data *vd, struct vsi_profile *profile);
> void vdp_vsi_sm_station(struct vsi_profile *profile);
> struct vsi_profile *vdp_add_profile(struct vsi_profile *profile);
>
> @@ -142,12 +144,12 @@ struct vsi_profile *vdp_add_profile(struct vsi_profile *profile);
> c = sprintf(s, "response: %i\n", p->response); s += c; \
> c = sprintf(s, "state: %i\n", p->state); s += c; \
> c = sprintf(s, "mgrid: %i\n", p->mgrid); s += c; \
> - c = sprintf(s, "id: %x%x%x\n", p->id[2], p->id[1], p->id[0]); \
> + c = sprintf(s, "id: %x\n", p->id); \
> s += c; \
> c = sprintf(s, "version: %i\n", p->version); s += c; \
> char instance[INSTANCE_STRLEN+2]; \
> instance2str(p->instance, instance, sizeof(instance)); \
> - c = sprintf(s, "instance: %s\n", &instance); s += c; \
> + c = sprintf(s, "instance: %s\n", &instance[0]); s += c; \
> char macbuf[MAC_ADDR_STRLEN+1]; \
> mac2str(p->mac, macbuf, MAC_ADDR_STRLEN); \
> c = sprintf(s, "mac: %s\n", macbuf); s += c; \
> diff --git a/lldp/ports.h b/lldp/ports.h
> index c2e18ec..44dc5f1 100644
> --- a/lldp/ports.h
> +++ b/lldp/ports.h
> @@ -136,19 +136,6 @@ struct porttlvs{
> struct unpacked_tlv *last_peer;
> };
>
> -struct ecp {
> - struct l2_packet_data *l2;
> - int sequence;
> - int retries;
> - int ackReceived;
> - int ackTimerExpired;
> - u16 lastSequence;
> - u16 seqECPDU;
> - struct portrx rx;
> - struct porttx tx;
> - struct portstats stats;
> -};
> -
> struct port {
> char *ifname;
> u8 hw_resetting;
> @@ -169,7 +156,6 @@ struct port {
> /* not sure */
> struct porttlvs tlvs;
>
> - struct ecp ecp;
> struct port *next;
> };
>
> diff --git a/lldp_vdp.c b/lldp_vdp.c
> new file mode 100644
> index 0000000..7d5936b
> --- /dev/null
> +++ b/lldp_vdp.c
> @@ -0,0 +1,1140 @@
> +/*******************************************************************************
> +
> + implementation of VDP according to IEEE 802.1Qbg
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#include <net/if.h>
> +#include <sys/queue.h>
> +#include <sys/socket.h>
> +#include <sys/ioctl.h>
> +#include <sys/utsname.h>
> +#include <linux/if_bridge.h>
> +#include "lldp.h"
> +#include "lldp_vdp.h"
> +#include "ecp/ecp.h"
> +#include "eloop.h"
> +#include "lldp_evb.h"
> +#include "messages.h"
> +#include "config.h"
> +#include "common.h"
> +#include "lldp_vdp_clif.h"
> +#include "lldp_vdp_cmds.h"
> +
> +/* vdp_data - searches vdp_data in the list of modules for this port
> + * @ifname: interface name to search for
> + *
> + * returns vdp_data on success, NULL on error
> + *
> + * searches the list of user_data for the VDP module user_data.
> + */
> +struct vdp_data *vdp_data(char *ifname)
> +{
> + struct vdp_user_data *ud;
> + struct vdp_data *vd = NULL;
> +
> + ud = find_module_user_data_by_if(ifname, &lldp_head, LLDP_MOD_VDP);
> + if (ud) {
> + LIST_FOREACH(vd, &ud->head, entry) {
> + if (!strncmp(ifname, vd->ifname, IFNAMSIZ))
> + return vd;
> + }
> + }
> + return NULL;
> +}
> +
> +/* vdp_free_tlv - free tlv in vdp_data
> + * @vd: vdp_data
> + *
> + * no return value
> + *
> + * frees up tlv in vdp_data. used in vdp_free_data.
> + */
> +static void vdp_free_tlv(struct vdp_data *vd)
> +{
> + if (vd) {
> + FREE_UNPKD_TLV(vd, vdp);
> + }
> +}
> +
> +/* vdp_free_data - frees up vdp data
> + * @ud: user data structure
> + *
> + * no return value
> + *
> + * removes vd_structure from the user_data list. frees up tlv in vdp_data.
> + * used in vdp_unregister.
> + */
> +static void vdp_free_data(struct vdp_user_data *ud)
> +{
> + struct vdp_data *vd;
> + if (ud) {
> + while (!LIST_EMPTY(&ud->head)) {
> + vd = LIST_FIRST(&ud->head);
> + LIST_REMOVE(vd, entry);
> + vdp_free_tlv(vd);
> + free(vd);
> + }
> + }
> +}
> +
> +/* vdp_print_profile - print a vsi profile
> + * @profile: profile to print
> + *
> + * no return value
> + *
> + * prints the contents of a profile first to a string using the PRINT_PROFILE
> + * macro, and then to the screen. Used for debug purposes.
> + */
> +static inline void vdp_print_profile(struct vsi_profile *profile)
> +{
> + char *s, *t;
> +
> + s = t = malloc(VDP_BUF_SIZE);
> +
> + if (!s) {
> + printf("%s(%i): unable to allocate string !\n", __func__, __LINE__);
> + }
> +
> + PRINT_PROFILE(t, profile);
> +
> + printf("profile: %s\n", s);
> +
> + free(s);
> +}
> +
> +/* vdp_somethingChangedLocal - set flag if profile has changed
> + * @profile: profile to set the flag for
> + * @mode: mode to set the flag to
> + *
> + * no return value
> + *
> + * set the localChange flag with a mode to indicate a profile has changed.
> + * used next time when a ecpdu with profiles is sent out.
> + */
> +void vdp_somethingChangedLocal(struct vsi_profile *profile, int mode)
> +{
> + profile->localChange = mode;
> +}
> +
> +/* vdp_ackTimer_expired - checks for expired ack timer
> + * @profile: profile to be checked
> + *
> + * returns true or false
> + *
> + * returns value of profile->ackTimerExpired, true if ack timer has expired,
> + * false otherwise.
> + */
> +static bool vdp_ackTimer_expired(struct vsi_profile *profile)
> +{
> + return profile->ackTimerExpired;
> +}
> +
> +/* vdp_timeout_handler - handles the ack timer expiry
> + * @eloop_data: data structure of event loop
> + * @user_ctx: user context, profile here
> + *
> + * no return value
> + *
> + * called when the VDP ack timer has expired. sets a flag and calls the VDP
> + * state machine.
> + */
> +void vdp_timeout_handler(void *eloop_data, void *user_ctx)
> +{
> + struct vsi_profile *profile;
> +
> + profile = (struct vsi_profile *) user_ctx;
> +
> + profile->ackTimerExpired = true;
> +
> + printf("%s(%i)-%s: timer expired\n", __func__, __LINE__,
> + profile->port->ifname);
> +
> + vdp_vsi_sm_station(profile);
> +}
> +
> +/* vdp_stop_ackTimer - stop the VDP ack timer
> + * @profile: profile to process
> + *
> + * returns the number of removed handlers
> + *
> + * stops the VDP ack timer. used when a ack frame for the profile has been
> + * received.
> + */
> +static int vdp_stop_ackTimer(struct vsi_profile *profile)
> +{
> + printf("%s(%i)-%s: stopping timer\n", __func__, __LINE__,
> + profile->port->ifname);
> +
> + return eloop_cancel_timeout(vdp_timeout_handler, NULL, (void *) profile);
> +}
> +
> +/* vdp_start_ackTimer - starts the VDP ack timer
> + * @profile: profile to process
> + *
> + * returns 0 on success, -1 on error
> + *
> + * starts the ack timer when a frame has been sent out.
> + */
> +static int vdp_start_ackTimer(struct vsi_profile *profile)
> +{
> + unsigned int secs, usecs;
> +
> + profile->ackTimerExpired = false;
> +
> + secs = VDP_TRANSMISSION_TIMER / VDP_TRANSMISSION_DIVIDER;
> + usecs = VDP_TRANSMISSION_TIMER % VDP_TRANSMISSION_DIVIDER;
> +
> + printf("%s(%i)-%s: starting timer\n", __func__, __LINE__,
> + profile->port->ifname);
> +
> + return eloop_register_timeout(secs, usecs, vdp_timeout_handler, NULL, (void *) profile);
> +}
> +
> +/* vdp_vsi_change_station_state - changes the VDP station sm state
> + * @profile: profile to process
> + * @newstate: new state for the sm
> + *
> + * no return value
> + *
> + * actually changes the state of the profile
> + */
> +void vdp_vsi_change_station_state(struct vsi_profile *profile, u8 newstate)
> +{
> + switch(newstate) {
> + case VSI_UNASSOCIATED:
> + break;
> + case VSI_ASSOC_PROCESSING:
> + assert((profile->state == VSI_PREASSOCIATED) ||
> + (profile->state == VSI_UNASSOCIATED));
> + break;
> + case VSI_ASSOCIATED:
> + assert(profile->state == VSI_ASSOC_PROCESSING);
> + break;
> + case VSI_PREASSOC_PROCESSING:
> + assert(profile->state == VSI_UNASSOCIATED);
> + break;
> + case VSI_PREASSOCIATED:
> + assert(profile->state == VSI_PREASSOC_PROCESSING);
> + break;
> + case VSI_DEASSOC_PROCESSING:
> + assert((profile->state == VSI_PREASSOCIATED) ||
> + (profile->state == VSI_ASSOCIATED));
> + break;
> + case VSI_EXIT:
> + assert((profile->state == VSI_ASSOC_PROCESSING) ||
> + (profile->state == VSI_PREASSOC_PROCESSING) ||
> + (profile->state == VSI_DEASSOC_PROCESSING) ||
> + (profile->state == VSI_PREASSOCIATED) ||
> + (profile->state == VSI_ASSOCIATED));
> + break;
> + default:
> + printf("ERROR: The VDP station State Machine is broken!\n");
> + break;
> + }
> +
> + printf("%s(%i)-%s: state change %s -> %s\n", __func__, __LINE__,
> + profile->port->ifname, vsi_states[profile->state], vsi_states[newstate]);
> +
> + profile->state = newstate;
> +}
> +
> +/* vdp_vsi_set_station_state - sets the vdp sm station state
> + * @profile: profile to process
> + *
> + * returns true or false
> + *
> + * switches the state machine to the next state depending on the input
> + * variables. returns true or false depending on wether the state machine
> + * can be run again with the new state or can stop at the current state.
> + */
> +static bool vdp_vsi_set_station_state(struct vsi_profile *profile)
> +{
> + switch(profile->state) {
> + case VSI_UNASSOCIATED:
> + if ((profile->mode == VDP_MODE_PREASSOCIATE) ||
> + (profile->mode == VDP_MODE_PREASSOCIATE_WITH_RR)) {
> + vdp_vsi_change_station_state(profile, VSI_PREASSOC_PROCESSING);
> + return true;
> + } else if (profile->mode == VDP_MODE_ASSOCIATE) {
> + vdp_vsi_change_station_state(profile, VSI_ASSOC_PROCESSING);
> + return true;
> + }
> + return false;
> + case VSI_ASSOC_PROCESSING:
> + if (profile->ackReceived) {
> + vdp_vsi_change_station_state(profile, VSI_ASSOCIATED);
> + return true;
> + } else if (!profile->ackReceived && vdp_ackTimer_expired(profile)) {
> + vdp_vsi_change_station_state(profile, VSI_EXIT);
> + return true;
> + }
> + return false;
> + case VSI_ASSOCIATED:
> + if (profile->mode == VDP_MODE_PREASSOCIATE) {
> + vdp_vsi_change_station_state(profile, VSI_PREASSOC_PROCESSING);
> + return true;
> + } else if (profile->mode == VDP_MODE_DEASSOCIATE) {
> + vdp_vsi_change_station_state(profile, VSI_DEASSOC_PROCESSING);
> + return true;
> + }
> + return false;
> + case VSI_PREASSOC_PROCESSING:
> + if (profile->ackReceived) {
> + vdp_vsi_change_station_state(profile, VSI_PREASSOCIATED);
> + return true;
> + } else if (vdp_ackTimer_expired(profile)) {
> + vdp_vsi_change_station_state(profile, VSI_EXIT);
> + return true;
> + }
> + case VSI_PREASSOCIATED:
> + if (profile->mode == VDP_MODE_DEASSOCIATE) {
> + vdp_vsi_change_station_state(profile, VSI_DEASSOC_PROCESSING);
> + return true;
> + }
> + if (profile->mode == VDP_MODE_ASSOCIATE) {
> + vdp_vsi_change_station_state(profile, VSI_ASSOC_PROCESSING);
> + return true;
> + }
> + return false;
> + case VSI_DEASSOC_PROCESSING:
> + if ((profile->ackReceived) || vdp_ackTimer_expired(profile)) {
> + vdp_vsi_change_station_state(profile, VSI_EXIT);
> + return true;
> + }
> + return false;
> + case VSI_EXIT:
> + return false;
> + default:
> + printf("ERROR: The VSI RX State Machine is broken!\n");
> + log_message(MSG_ERR_RX_SM_INVALID, "");
> + return false;
> + }
> +}
> +
> +/* vdp_vsi_sm_station - state machine for vdp station role
> + * @profile: profile for which the state is processed
> + *
> + * no return value
> + *
> + * runs the state machine for the station role of VDP.
> + */
> +void vdp_vsi_sm_station(struct vsi_profile *profile)
> +{
> + struct vdp_data *vd = vdp_data(profile->port->ifname);
> +
> + vdp_vsi_set_station_state(profile);
> + do {
> + printf("%s(%i)-%s: station - %s\n", __func__, __LINE__,
> + profile->port->ifname, vsi_states[profile->state]);
> +
> + switch(profile->state) {
> + case VSI_UNASSOCIATED:
> + break;
> + case VSI_ASSOC_PROCESSING:
> + vdp_somethingChangedLocal(profile, VDP_PROFILE_REQ);
> + ecp_somethingChangedLocal(vd, VDP_PROFILE_REQ);
> + ecp_tx_run_sm(vd);
> + vdp_start_ackTimer(profile);
> + break;
> + case VSI_ASSOCIATED:
> + vdp_stop_ackTimer(profile);
> + /* TODO:
> + * vsiError = ProcRxandSetCfg(remoteTLV, localtlv, vsistate);
> + * if (!vsiError) vsistate=ASSOCIATED */
> + break;
> + case VSI_PREASSOC_PROCESSING:
> + /* send out profile */
> + vdp_somethingChangedLocal(profile, VDP_PROFILE_REQ);
> + ecp_somethingChangedLocal(vd, VDP_PROFILE_REQ);
> + ecp_tx_run_sm(vd);
> + vdp_start_ackTimer(profile);
> + break;
> + case VSI_PREASSOCIATED:
> + profile->ackReceived = false;
> + vdp_somethingChangedLocal(profile, VDP_PROFILE_NOCHANGE);
> + vdp_stop_ackTimer(profile);
> + /* TODO vsiError = ProcRxandSetCfg(remoteTLV, localtlv, vsistate);
> + * if (!vsiError) vsistate=PREASSOCIATED */
> + break;
> + case VSI_DEASSOC_PROCESSING:
> + vdp_somethingChangedLocal(profile, VDP_PROFILE_REQ);
> + vdp_start_ackTimer(profile);
> + break;
> + case VSI_EXIT:
> + /* TODO: something went wrong, remove this profile */
> + break;
> + default:
> + printf("ERROR: The VSI RX station State Machine is broken!\n");
> + log_message(MSG_ERR_TX_SM_INVALID, "");
> + }
> + } while (vdp_vsi_set_station_state(profile) == true);
> +
> +}
> +
> +/* vdp_vsi_change_bridge_state - changes the VDP bridge sm state
> + * @profile: profile to process
> + * @newstate: new state for the sm
> + *
> + * no return value
> + *
> + * actually changes the state of the profile
> + */
> +static void vdp_vsi_change_bridge_state(struct vsi_profile *profile, u8 newstate)
> +{
> + switch(newstate) {
> + case VSI_UNASSOCIATED:
> + break;
> + case VSI_ASSOC_PROCESSING:
> + assert((profile->state == VSI_UNASSOCIATED) ||
> + (profile->state == VSI_PREASSOCIATED) ||
> + (profile->state == VSI_ASSOCIATED));
> + break;
> + case VSI_ASSOCIATED:
> + assert(profile->state == VSI_ASSOC_PROCESSING);
> + break;
> + case VSI_PREASSOC_PROCESSING:
> + assert((profile->state == VSI_UNASSOCIATED) ||
> + (profile->state == VSI_PREASSOCIATED) ||
> + (profile->state == VSI_ASSOCIATED));
> + break;
> + case VSI_PREASSOCIATED:
> + assert(profile->state == VSI_PREASSOC_PROCESSING);
> + break;
> + case VSI_DEASSOC_PROCESSING:
> + assert((profile->state == VSI_UNASSOCIATED) ||
> + (profile->state == VSI_PREASSOCIATED) ||
> + (profile->state == VSI_ASSOCIATED));
> + break;
> + case VSI_EXIT:
> + assert((profile->state == VSI_DEASSOC_PROCESSING) ||
> + (profile->state == VSI_PREASSOC_PROCESSING) ||
> + (profile->state == VSI_ASSOC_PROCESSING));
> + break;
> + default:
> + printf("ERROR: The VDP bridge State Machine is broken!\n");
> + break;
> + }
> + profile->state = newstate;
> +}
> +
> +/* vdp_vsi_set_bridge_state - sets the vdp sm bridge state
> + * @profile: profile to process
> + *
> + * returns true or false
> + *
> + * switches the state machine to the next state depending on the input
> + * variables. returns true or false depending on wether the state machine
> + * can be run again with the new state or can stop at the current state.
> + */
> +static bool vdp_vsi_set_bridge_state(struct vsi_profile *profile)
> +{
> + switch(profile->state) {
> + case VSI_UNASSOCIATED:
> + if ((profile->mode == VDP_MODE_DEASSOCIATE)) /* || (INACTIVE)) */ {
> + vdp_vsi_change_bridge_state(profile, VSI_DEASSOC_PROCESSING);
> + return true;
> + } else if (profile->mode == VDP_MODE_ASSOCIATE) {
> + vdp_vsi_change_bridge_state(profile, VSI_ASSOC_PROCESSING);
> + return true;
> + } else if (profile->mode == VDP_MODE_PREASSOCIATE) {
> + vdp_vsi_change_bridge_state(profile, VSI_PREASSOC_PROCESSING);
> + return true;
> + }
> + return false;
> + case VSI_ASSOC_PROCESSING:
> + /* TODO: handle error case
> + if (!vsiError) ||
> + (vsiError && vsiState == Assoc) {
> + */
> + if (profile->mode == VDP_MODE_ASSOCIATE) {
> + vdp_vsi_change_bridge_state(profile, VSI_ASSOCIATED);
> + return true;
> + }
> + return false;
> + case VSI_ASSOCIATED:
> + if (profile->mode == VDP_MODE_ASSOCIATE) /* || ( INACTIVE )*/ {
> + vdp_vsi_change_bridge_state(profile, VSI_DEASSOC_PROCESSING);
> + return true;
> + } else if (profile->mode == VDP_MODE_PREASSOCIATE) {
> + vdp_vsi_change_bridge_state(profile, VSI_PREASSOC_PROCESSING);
> + return true;
> + } else if (profile->mode == VDP_MODE_ASSOCIATE) {
> + vdp_vsi_change_bridge_state(profile, VSI_ASSOC_PROCESSING);
> + return true;
> + }
> + return false;
> + case VSI_PREASSOC_PROCESSING:
> + if (profile->response != VDP_RESPONSE_SUCCESS) {
> + vdp_vsi_change_bridge_state(profile, VSI_EXIT);
> + return true;
> + }
> + vdp_vsi_change_bridge_state(profile, VSI_PREASSOCIATED);
> + return false;
> + case VSI_PREASSOCIATED:
> + if (profile->mode == VDP_MODE_ASSOCIATE) {
> + vdp_vsi_change_bridge_state(profile, VSI_ASSOC_PROCESSING);
> + return true;
> + } else if (profile->mode == VDP_MODE_DEASSOCIATE ) {
> + vdp_vsi_change_bridge_state(profile, VSI_DEASSOC_PROCESSING);
> + return true;
> + } else if (profile->mode == VDP_MODE_PREASSOCIATE ) {
> + vdp_vsi_change_bridge_state(profile, VSI_PREASSOC_PROCESSING);
> + return true;
> + }
> + return false;
> + case VSI_DEASSOC_PROCESSING:
> + vdp_vsi_change_bridge_state(profile, VSI_EXIT);
> + return false;
> + case VSI_EXIT:
> + return false;
> + default:
> + printf("ERROR: The VSI RX State Machine (bridge) is broken!\n");
> + log_message(MSG_ERR_RX_SM_INVALID, "");
> + return false;
> + }
> +}
> +
> +/* vdp_vsi_sm_bridge - state machine for vdp bridge role
> + * @profile: profile for which the state is processed
> + *
> + * no return value
> + *
> + * runs the state machine for the bridge role of VDP.
> + */
> +static void vdp_vsi_sm_bridge(struct vsi_profile *profile)
> +{
> + struct vdp_data *vd = vdp_data(profile->port->ifname);
> +
> + vdp_vsi_set_bridge_state(profile);
> + do {
> + printf("%s(%i)-%s: bridge - %s\n", __func__, __LINE__,
> + profile->port->ifname, vsi_states[profile->state]);
> + switch(profile->state) {
> + case VSI_UNASSOCIATED:
> + break;
> + case VSI_ASSOC_PROCESSING:
> + /* TODO: vsiError = ProcRxandSetCfg(remoteTLV, localtlv, vsistate);
> + * if (vsiError)
> + * txTLV(Assoc NACK)
> + * else
> + * txTLV(Assoc ACK) */
*/
move the */ to a line on its own.
> + break;
> + case VSI_ASSOCIATED:
> + break;
> + case VSI_PREASSOC_PROCESSING:
> + /* TODO: vsiError = ProcRxandSetCfg(remoteTLV, localtlv, vsistate);
> + * if (vsiError)
> + * txTLV(PreAssoc NACK)
> + * else
> + * txTLV(PreAssoc ACK) */
same here.
> + /* for now, we always succeed */
> + profile->response = VDP_RESPONSE_SUCCESS;
> + printf("%s(%i)-%s: framein %p, sizein %i\n", __func__, __LINE__,
> + profile->port->ifname, vd->ecp.rx.framein,
> + vd->ecp.rx.sizein);
> + ecp_rx_send_ack_frame(profile->port);
> + break;
> + case VSI_PREASSOCIATED:
> + printf("%s(%i)-%s: \n", __func__, __LINE__, profile->port->ifname);
> + break;
> + case VSI_DEASSOC_PROCESSING:
> + /* TODO: txTLV(DeAssoc ACK) */
> + break;
> + case VSI_EXIT:
> + /* TODO: something went wrong, remove this profile */
> + break;
> + default:
> + printf("ERROR: The VSI RX bridge State Machine is broken!\n");
> + log_message(MSG_ERR_TX_SM_INVALID, "");
> + }
> + } while (vdp_vsi_set_bridge_state(profile) == true);
> +
> +}
> +
> +/*
> + * vdp_print_vsi_tlv - print the raw contents of a VSI TLV
> + * @tlv: the unpacked tlv which gets printed
> + *
> + * No return value
> + *
> + * used for protocol debug purposes
> + */
> +static void vdp_print_vsi_tlv(struct unpacked_tlv *tlv)
> +{
> + int i;
> +
> + printf("### %s:type %i, length %i, info:\n", __func__, tlv->type, tlv->length);
> +
> + for (i=0; i < tlv->length; i++) {
> + printf("%02x ", tlv->info[i]);
> + if (!((i+1) % 16))
> + printf("\n");
> + }
> +
> + printf("\n");
> +}
> +
> +/*
> + * vdp_validate_tlv - validates vsi tlvs
> + * @vdp: decoded vsi tlv
> + *
> + * Returns 0 on success, 1 on error
> + *
> + * checks the contents of an already decoded vsi tlv for inconsistencies
> + */
> +static int vdp_validate_tlv(struct tlv_info_vdp *vdp)
> +{
> + if (ntoh24(vdp->oui) != OUI_IEEE_8021Qbg) {
> + printf("vdp->oui %06x \n", ntoh24(vdp->oui));
> + goto out_err;
> + }
> +
> + if (vdp->sub != LLDP_VDP_SUBTYPE) {
> + printf("vdp->sub %02x \n", vdp->sub);
> + goto out_err;
> + }
> +
> + if ((vdp->mode < VDP_MODE_PREASSOCIATE) ||
> + (vdp->mode > VDP_MODE_DEASSOCIATE)) {
> + printf("Unknown mode %02x in vsi tlv !\n", vdp->mode);
> + goto out_err;
> + }
> +
> + if ((vdp->response < VDP_RESPONSE_SUCCESS) ||
> + (vdp->response > VDP_RESPONSE_OUT_OF_SYNC)) {
> + printf("Unknown response %02x \n", vdp->response);
> + goto out_err;
> + }
> +
> + if (vdp->format != VDP_MACVLAN_FORMAT_1) {
> + printf("Unknown format %02x in vsi tlv !\n", vdp->format);
> + goto out_err;
> + }
> +
> + if (ntohs(vdp->entries) != 1) {
> + printf("Multiple entries %02x in vsi tlv !\n", vdp->entries);
> + goto out_err;
> + }
> +
> + return 0;
> +
> +out_err:
> + return 1;
> +}
> +
> +/*
> + * vdp_indicate - receive VSI TLVs from ECP
> + * @port: the port on which the tlv was received
> + * @tlv: the unpacked tlv to receive
> + * @ecp_mode: the mode under which the tlv was received (ACK or REQ)
> + *
> + * Returns 0 on success
> + *
> + * receives a vsi tlv and creates a profile. Take appropriate action
> + * depending on the role of the (receive) port
> + */
> +int vdp_indicate(struct vdp_data *vd, struct unpacked_tlv *tlv, int ecp_mode)
> +{
> + struct tlv_info_vdp *vdp;
> + struct vsi_profile *p, *profile;
> + struct port *port = port_find_by_name(vd->ifname);
> +
> + printf("%s(%i): indicating vdp for for %s !\n", __func__, __LINE__, vd->ifname);
> +
> + if (!port) {
> + printf("%s(%i): port not found for %s !\n", __func__, __LINE__, vd->ifname);
> + goto out_err;
> + }
> +
> + vdp = malloc(sizeof(struct tlv_info_vdp));
> +
> + if (!vdp) {
> + printf("%s(%i): unable to allocate vdp !\n", __func__, __LINE__);
> + goto out_err;
> + }
> +
> + memset(vdp, 0, sizeof(struct tlv_info_vdp));
> + memcpy(vdp, tlv->info, tlv->length);
> +
> + if (vdp_validate_tlv(vdp)) {
> + printf("%s(%i): Invalid TLV received !\n", __func__, __LINE__);
> + goto out_err;
> + }
> +
> + profile = malloc(sizeof(struct vsi_profile));
> +
> + if (!profile) {
> + printf("%s(%i): unable to allocate profile !\n", __func__, __LINE__);
> + goto out_vdp;
> + }
> +
> + memset(profile, 0, sizeof(struct vsi_profile));
> +
> + profile->mode = vdp->mode;
> + profile->response = vdp->response;
> +
> + profile->mgrid = vdp->mgrid;
> + profile->id = ntoh24(vdp->id);
> + profile->version = vdp->version;
> + memcpy(&profile->instance, &vdp->instance, 16);
> + memcpy(&profile->mac, &vdp->mac_vlan.mac, MAC_ADDR_LEN);
> + profile->vlan = ntohs(vdp->mac_vlan.vlan);
> +
> + profile->port = port;
> + printf("%s(%i):\n", __func__, __LINE__);
> +
> + if (vd->role == VDP_ROLE_STATION) {
> + /* do we have the profile already ? */
> + LIST_FOREACH(p, &vd->profile_head, profile) {
> + if (vdp_profile_equal(p, profile)) {
> + printf("%s(%i): station: profile found, localChange %i ackReceived %i!\n",
> + __func__, __LINE__, p->localChange, p->ackReceived);
> +
> + if (ecp_mode == ECP_ACK)
> + p->ackReceived = true;
> +
> + vdp_vsi_sm_station(p);
> + } else {
> + printf("%s(%i): station: profile not found !\n", __func__, __LINE__);
> + /* ignore profile */
> + }
> + }
> + }
> +
> + if (vd->role == VDP_ROLE_BRIDGE) {
> + /* do we have the profile already ? */
> + LIST_FOREACH(p, &vd->profile_head, profile) {
> + if (vdp_profile_equal(p, profile)) {
> + break;
> + }
> + }
> +
> + if (p) {
> + printf("%s(%i): bridge: profile found !\n", __func__, __LINE__);
> + } else {
> + printf("%s(%i): bridge: profile not found !\n", __func__, __LINE__);
> + /* put it in the list */
> + profile->state = VSI_UNASSOCIATED;
> + LIST_INSERT_HEAD(&vd->profile_head, profile, profile );
> + }
> +
> + vdp_vsi_sm_bridge(profile);
> + }
> +
> + return 0;
> +
> +out_vdp:
> + free(vdp);
> +out_err:
> + printf("%s(%i): error !\n", __func__, __LINE__);
> + return 1;
> +
> +}
> +
> +/*
> + * vdp_bld_vsi_tlv - build the VDP VSI TLV
> + * @vd: vdp_data structure for this port
> + * @profile: profile the vsi tlv is created from
> + *
> + * Returns 0 on success, ENOMEM otherwise
> + *
> + * creates a vdp structure from an existing profile
> + */
> +static int vdp_bld_vsi_tlv(struct vdp_data *vd, struct vsi_profile *profile)
> +{
> + int rc = 0;
> + struct unpacked_tlv *tlv = NULL;
> + struct tlv_info_vdp vdp;
> +
> + FREE_UNPKD_TLV(vd, vdp);
> +
> + memset(&vdp, 0, sizeof(vdp));
> +
> + hton24(vdp.oui, OUI_IEEE_8021Qbg);
> + vdp.sub = LLDP_VDP_SUBTYPE;
> + vdp.mode = profile->mode;
> + vdp.response = 0;
> + vdp.mgrid = profile->mgrid;
> + hton24(vdp.id, profile->id);
> + vdp.version = profile->version;
> + memcpy(&vdp.instance,&profile->instance, 16);
> + vdp.format = VDP_MACVLAN_FORMAT_1;
> + vdp.entries = htons(1);
> + memcpy(&vdp.mac_vlan.mac,&profile->mac, MAC_ADDR_LEN);
> + vdp.mac_vlan.vlan = htons(profile->vlan);
> +
> + tlv = create_tlv();
> + if (!tlv)
> + goto out_err;
> +
> + tlv->type = ORG_SPECIFIC_TLV;
> + tlv->length = sizeof(vdp);
> + tlv->info = (u8 *)malloc(tlv->length);
> + if(!tlv->info) {
> + free(tlv);
> + tlv = NULL;
> + rc = ENOMEM;
> + goto out_err;
> + }
> + memcpy(tlv->info, &vdp, tlv->length);
> +
> + vd->vdp = tlv;
> +
> +out_err:
> + return rc;
> +}
> +
> +/* vdp_bld_tlv - builds a tlv from a profile
> + * @vd: vdp_data structure for this port
> + * @profile: profile the vsi tlv is created from
> + *
> + * returns 0 on success, != 0 on error
> + *
> + * wrapper function around vdp_bld_vsi_tlv. adds some checks and calls
> + * vdp_bld_vsi_tlv.
> +*/
> +
> +static int vdp_bld_tlv(struct vdp_data *vd, struct vsi_profile *profile)
> +{
> + int rc = 0;
> +
> + if (!port_find_by_name(vd->ifname)) {
> + rc = EEXIST;
> + goto out_err;
> + }
> +
> + if (!init_cfg()) {
> + rc = ENOENT;
> + goto out_err;
> + }
> +
> + if (vdp_bld_vsi_tlv(vd, profile)) {
> + fprintf(stderr, "### %s:%s:vdp_bld_cfg_tlv() failed\n",
should be "vdp_bld_vsi_tlv failed".
> + __func__, vd->ifname);
> + rc = EINVAL;
> + goto out_err_destroy;
> + }
> +
> +out_err_destroy:
> + destroy_cfg();
> +
> +out_err:
> + return rc;
> +}
> +
> +/* vdp_gettlv - get the tlv for a profile
> + * @port: the port on which the tlv was received
> + * @profile: profile the vsi tlv is created from
> + *
> + * returns 0 on success
> + *
> + * this is the interface function called from ecp_build_ECPDU. It returns the
> + * packed tlv for a profile.
> + */
> +struct packed_tlv *vdp_gettlv(struct vdp_data *vd, struct vsi_profile *profile)
> +{
> + int size;
> + struct packed_tlv *ptlv = NULL;
> +
> + /* frees the unpacked_tlv in vdp_data
> + * also done in vdp_bld_vsi_tlv */
> + vdp_free_tlv(vd);
> +
> + if (vdp_bld_tlv(vd, profile)) {
> + fprintf(stderr, "### %s:%s vdp_bld_tlv failed\n",
> + __func__, vd->ifname);
> + goto out_err;
> + }
> +
> + size = TLVSIZE(vd->vdp);
> +
> + if (!size) {
> + printf("%s(%i): size %i of unpacked_tlv not correct !\n", __func__, __LINE__,
> + size);
> + goto out_err;
> + }
> +
> + ptlv = create_ptlv();
> + if (!ptlv)
> + goto out_err;
> +
> + ptlv->tlv = malloc(size);
> + if (!ptlv->tlv)
> + goto out_free;
> +
> + ptlv->size = 0;
> + PACK_TLV_AFTER(vd->vdp, ptlv, size, out_free);
> +
> + return ptlv;
> +
> +out_free:
> + ptlv = free_pkd_tlv(ptlv);
> +out_err:
> + fprintf(stderr,"### %s:%s: failed\n", __func__, vd->ifname);
> + return NULL;
> +}
> +
> +/* vdp_profile_equal - checks for equality of 2 profiles
> + * @p1: profile 1
> + * @p2: profile 2
> + *
> + * returns 1 on success, 0 on error
> + *
> + * compares mgrid, id, version, instance, mac and vlan of 2 profiles to find
> + * out if they are equal.
> + */
> +int vdp_profile_equal(struct vsi_profile *p1, struct vsi_profile *p2)
> +{
> + if (p1->mgrid != p2->mgrid)
> + return 0;
> +
> + if (p1->id == p2->id)
> + return 0;
> +
> + if (p1->version != p2->version)
> + return 0;
> +
> + if (memcmp(p1->instance, p2->instance, 16))
> + return 0;
> +
> + if (memcmp(p1->mac, p2->mac, MAC_ADDR_LEN))
> + return 0;
> +
> + if (p1->vlan != p2->vlan)
> + return 0;
> +
> + return 1;
> +}
> +
> +/* vdp_add_profile - adds a profile to a per port list
> + * @profile: profile to add
> + *
> + * returns the profile that has been found or added
> + *
> + * main interface function which adds a profile to a list kept on a per-port
> + * basis. Checks if the profile is already in the list, adds it if necessary.
> + */
> +struct vsi_profile *vdp_add_profile(struct vsi_profile *profile)
> +{
> + struct vsi_profile *p;
> + struct vdp_data *vd;
> +
> + printf("%s(%i): adding vdp profile for %s !\n", __func__, __LINE__,
> + profile->port->ifname);
> +
> + vd = vdp_data(profile->port->ifname);
> + if (!vd) {
> + printf("%s(%i): Could not find vdp_data for %s !\n", __func__, __LINE__,
> + profile->port->ifname);
> + return NULL;
> + }
> +
> + vdp_print_profile(profile);
> +
> + /* loop over all existing profiles and check wether
> + * one for this combination already exists. If yes, check,
> + * if the MAC/VLAN pair already exists. If not, add it.
> + * Note: currently only one MAC/VLAN pair supported ! */
> + LIST_FOREACH(p, &vd->profile_head, profile) {
> + if (p) {
> + vdp_print_profile(p);
This is a lot of debug output.
> + if (vdp_profile_equal(p, profile)) {
> + if (p->mode == profile->mode) {
> + printf("%s(%i): profile already exists, ignoring !\n",
> + __func__, __LINE__);
> + return NULL;
comment at top of function "return the profile that has been found or added" seems to indicate this should return the profile not NULL. I suspect a fix to the comment should suffice.
> + } else {
> + printf("%s(%i): taking new mode !\n", __func__,
> + __LINE__);
> + p->mode = profile->mode;
> + return p;
> + }
> + }
> + }
> + }
> +
> + LIST_INSERT_HEAD(&vd->profile_head, profile, profile );
> +
> + return profile;
> +}
> +
> +/* vdp_ifdown - tear down vdp structures for a interface
> + * @ifname: name of the interface
> + *
> + * no return value
> + *
> + * interface function to lldpad. tears down vdp specific structures if
> + * interface "ifname" goes down.
> + */
> +void vdp_ifdown(char *ifname)
> +{
> + struct vdp_data *vd;
> + struct vsi_profile *p;
> +
> + vd = vdp_data(ifname);
> + if (!vd)
> + goto out_err;
> +
> + LIST_REMOVE(vd, entry);
> +
> + LIST_FOREACH(p, &vd->profile_head, profile) {
> + free(p);
> + LIST_REMOVE(p, profile);
This is should be
LIST_REMOVE(p, profile);
free(p);
not the other way around.
> + }
> + vdp_free_tlv(vd);
> + free(vd);
> + fprintf(stderr, "### %s:port %s removed\n", __func__, ifname);
> + return;
> +out_err:
> + fprintf(stderr, "### %s:port %s adding failed\n", __func__, ifname);
this is not adding a port and nothing failed the ifname has not been added.
> +
> + return;
> +}
> +
> +/* vdp_ifup - build up vdp structures for a interface
> + * @ifname: name of the interface
> + *
> + * no return value
> + *
> + * interface function to lldpad. builds up vdp specific structures if
> + * interface "ifname" goes down.
> + */
> +void vdp_ifup(char *ifname)
> +{
> + char *p;
> + struct vdp_data *vd;
> + struct vdp_user_data *ud;
> +
> + printf("%s(%i): starting VDP for if %s !\n", __func__, __LINE__, ifname);
> +
> + vd = vdp_data(ifname);
> + if (vd) {
> + fprintf(stderr, "%s:%s already exists\n", __func__, ifname);
> + goto out_err;
This prints the error in out_err incorrectly.
> + }
> +
> + /* not found, alloc/init per-port module data */
> + vd = (struct vdp_data *) calloc(1, sizeof(struct vdp_data));
Use malloc instead of calloc() of one.
> + if (!vd) {
> + fprintf(stderr, "### %s:%s malloc %ld failed\n",
> + __func__, ifname, sizeof(*vd));
> + goto out_err;
> + }
> + strncpy(vd->ifname, ifname, IFNAMSIZ);
> +
> + if (!init_cfg())
> + goto out_err;
memory leak of 'vd' if init_cfg fails.
> +
> + vd->role = VDP_ROLE_STATION;
> +
> + if (!get_cfg(ifname, "vdp.role", (void *)&p,
> + CONFIG_TYPE_STRING)) {
> + if (!strcasecmp(p, VAL_BRIDGE)) {
> + vd->role = VDP_ROLE_BRIDGE;
> + }
> + }
> +
> + printf("%s: configured for %s mode !\n", ifname,
> + (vd->role ==VDP_ROLE_BRIDGE) ? "bridge" : "station");
> +
> + LIST_INIT(&vd->profile_head);
> +
> + ud = find_module_user_data_by_if(ifname, &lldp_head, LLDP_MOD_VDP);
> + LIST_INSERT_HEAD(&ud->head, vd, entry);
> +
> + ecp_init(ifname);
> +
> + fprintf(stderr, "### %s:port %s added\n", __func__, ifname);
> + return;
> +
> +out_err:
> + fprintf(stderr, "### %s:port %s adding failed\n", __func__, ifname);
> + return;
> +}
> +
> +static const struct lldp_mod_ops vdp_ops = {
> + .lldp_mod_register = vdp_register,
> + .lldp_mod_unregister = vdp_unregister,
> + .lldp_mod_ifup = vdp_ifup,
> + .lldp_mod_ifdown = vdp_ifdown,
> + .get_arg_handler = vdp_get_arg_handlers,
> +};
> +
> +/* vdp_register - register vdp module to lldpad
> + * @none
> + *
> + * returns lldp_module struct on success, NULL on error
> + *
> + * allocates a module structure with vdp module information and returns it
> + * to lldpad.
> + */
> +struct lldp_module *vdp_register(void)
> +{
> + struct lldp_module *mod;
> + struct vdp_user_data *ud;
> +
> + mod = malloc(sizeof(*mod));
> + if (!mod) {
> + fprintf(stderr, "failed to malloc module data\n");
> + log_message(MSG_ERR_SERVICE_START_FAILURE,
> + "%s", "failed to malloc module data");
> + goto out_err;
> + }
> + ud = malloc(sizeof(struct vdp_user_data));
> + if (!ud) {
> + free(mod);
> + fprintf(stderr, "failed to malloc module user data\n");
> + log_message(MSG_ERR_SERVICE_START_FAILURE,
> + "%s", "failed to malloc module user data");
> + goto out_err;
> + }
> + LIST_INIT(&ud->head);
> + mod->id = LLDP_MOD_VDP;
> + mod->ops = &vdp_ops;
> + mod->data = ud;
> + fprintf(stderr, "### %s:done\n", __func__);
> + return mod;
> +
> +out_err:
> + fprintf(stderr, "### %s:failed\n", __func__);
> + return NULL;
> +}
> +
> +/* vdp_unregister - unregister vdp module from lldpad
> + * @none
> + *
> + * no return value
> + *
> + * frees vdp module structure.
> + */
> +void vdp_unregister(struct lldp_module *mod)
> +{
> + if (mod->data) {
> + vdp_free_data((struct vdp_user_data *) mod->data);
> + free(mod->data);
> + }
> + free(mod);
> + fprintf(stderr, "### %s:done\n", __func__);
> +}
> +
> +
> diff --git a/lldpad.c b/lldpad.c
> index 571da31..c0938af 100644
> --- a/lldpad.c
> +++ b/lldpad.c
> @@ -50,6 +50,7 @@
> #include "lldp_med.h"
> #include "lldp_8023.h"
> #include "lldp_evb.h"
> +#include "lldp_vdp.h"
> #include "config.h"
> #include "lldpad_shm.h"
> #include "clif.h"
> @@ -65,6 +66,7 @@ struct lldp_module *(*register_tlv_table[])(void) = {
> med_register,
> ieee8023_register,
> evb_register,
> + vdp_register,
> NULL,
> };
>
> --
Few minor nits otherwise looks good. Please merge relevant parts with patch 4 though.
Thanks!
John
^ permalink raw reply
* Re: [E1000-eedc] [PATCH 04/10] ECP implementation
From: John Fastabend @ 2010-09-23 0:50 UTC (permalink / raw)
To: Jens Osterkamp
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <1282739262-14968-5-git-send-email-jens@linux.vnet.ibm.com>
On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
> This is the implementation of the edge control protocol (ECP) as specified
> in IEEE 802.1Qbg.
>
> For this it extends the infrastructure defined lldpad to send and receive
> ECP frames with a new (yet to be defined) ethertype.
> Received frames are validated and analyzed before the content is handed to the
> upper layer protocol (ULP, VDP in this case) for further processing. Frames
> to be transmitted are compiled from VSI (guest interface) profiles registered
> on a interface.
> Reception and transmission of ECP frames is controlled by RX and TX state
> machines, timeouts are handled timeout functions.
> The patch still contains a lot of debug code to allow low-level protocol
> analysis.
>
> Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
I am hesitant to apply these without a defined ethertype. Presumably this will come out of the IEEE DCB task group.
> ---
> Makefile.am | 2 +
> ecp/ecp.c | 77 +++++++
> ecp/ecp.h | 92 ++++++++
> ecp/ecp_rx.c | 597 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> ecp/ecp_tx.c | 467 ++++++++++++++++++++++++++++++++++++++++
> include/lldp_evb.h | 6 +
> include/lldp_vdp.h | 157 ++++++++++++++
> lldp/l2_packet.h | 2 +
> lldp/ports.h | 25 ++-
> 9 files changed, 1422 insertions(+), 3 deletions(-)
> create mode 100644 ecp/ecp.c
> create mode 100644 ecp/ecp.h
> create mode 100644 ecp/ecp_rx.c
> create mode 100644 ecp/ecp_tx.c
> create mode 100644 include/lldp_vdp.h
>
> diff --git a/Makefile.am b/Makefile.am
> index d59a6fa..061f2ee 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -56,6 +56,8 @@ $(lldpad_include_HEADERS) $(noinst_HEADERS) \
> lldp/ports.c lldp/agent.c lldp/l2_packet_linux.c lldp/tx.c \
> lldp/rx.c lldp/agent.h lldp/l2_packet.h lldp/mibdata.h lldp/ports.h \
> lldp/states.h \
> +ecp/ecp.c ecp/ecp_tx.c \
> +ecp/ecp_rx.c \
> include/lldp.h include/lldp_mod.h \
> lldp_dcbx.c include/lldp_dcbx.h tlv_dcbx.c include/tlv_dcbx.h \
> lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
> diff --git a/ecp/ecp.c b/ecp/ecp.c
> new file mode 100644
> index 0000000..ecf68f9
> --- /dev/null
> +++ b/ecp/ecp.c
> @@ -0,0 +1,77 @@
snip snip
> +}
> +
> +/* ecp_rx_validate_frame - wrapper around ecp_rx_validateFrame
> + * @port: currently used port
> + *
> + * no return value
> + *
> + * sets rcvFrame to false and validates frame. used in ECP_RX_RECEIVE_ECPDU
> + * state of ecp_rx_run_sm
> + */
> +void ecp_rx_validate_frame(struct port *port)
> +{
> + port->ecp.rx.rcvFrame = false;
> + ecp_rx_validateFrame(port);
> + return;
> +}
> +
> +/* ecp_rx_ProcessFrame - process received ecp frames
> + * @port: currently used port
> + *
> + * no return value
> + *
> + * walks through the packed vsi tlvs in an ecp frame, extracts them
> + * and passes them to the VDP ULP with vdp_indicate.
> + */
> +void ecp_rx_ProcessFrame(struct port * port)
> +{
> + u16 tlv_cnt = 0;
> + u8 tlv_type = 0;
> + u16 tlv_length = 0;
> + u16 tlv_offset = 0;
> + u16 *tlv_head_ptr = NULL;
> + u8 frame_error = 0;
> + bool tlv_stored = false;
> + int err;
> + struct lldp_module *np;
> + struct ecp_hdr *ecp_hdr;
> +
> + printf("%s(%i)-%s: processing frame \n", __func__, __LINE__, port->ifname);
> +
> + assert(port->ecp.rx.framein && port->ecp.rx.sizein);
> +
> + tlv_offset = sizeof(struct l2_ethhdr);
> +
> + ecp_print_framein(port);
> +
> + ecp_hdr = (struct ecp_hdr *)&port->ecp.rx.framein[tlv_offset];
> +
> + printf("%s(%i)-%s: ecp packet with subtype %04x, mode %02x, sequence nr %04x\n",
> + __func__, __LINE__, port->ifname, ecp_hdr->subtype, ecp_hdr->mode, ecp_hdr->seqnr);
> +
> + /* FIXME: already done in ecp_rx_validateFrame ? */
> + if (ecp_hdr->subtype != ECP_SUBTYPE) {
> + printf("ERROR: unknown subtype !\n");
> + frame_error++;
> + goto out;
> + }
Agreed looks like above can be removed.
> +
> + /* processing of VSI_TLVs starts here */
> +
> + tlv_offset += sizeof(struct ecp_hdr);
> +
> + do {
> + tlv_cnt++;
> + if (tlv_offset > port->ecp.rx.sizein) {
> + printf("%s(%i)-%s: ERROR: Frame overrun! tlv_offset %i, sizein %i cnt %i\n",
> + __func__, __LINE__, port->ifname, tlv_offset, port->ecp.rx.sizein, tlv_cnt);
> + frame_error++;
> + goto out;
> + }
> +
> + tlv_head_ptr = (u16 *)&port->ecp.rx.framein[tlv_offset];
> + tlv_length = htons(*tlv_head_ptr) & 0x01FF;
> + tlv_type = (u8)(htons(*tlv_head_ptr) >> 9);
> +
> + u16 tmp_offset = tlv_offset + tlv_length;
> + if (tmp_offset > port->ecp.rx.sizein) {
> + printf("ERROR: Frame overflow error: offset=%d, "
> + "rx.size=%d \n", tmp_offset, port->ecp.rx.sizein);
> + frame_error++;
> + goto out;
> + }
> +
> + u8 *info = (u8 *)&port->ecp.rx.framein[tlv_offset +
> + sizeof(*tlv_head_ptr)];
> +
> + struct unpacked_tlv *tlv = create_tlv();
> +
> + if (!tlv) {
> + printf("ERROR: Failed to malloc space for "
> + "incoming TLV. \n");
> + goto out;
> + }
> +
> + if ((tlv_length == 0) && (tlv->type != TYPE_0)) {
> + printf("ERROR: tlv_length == 0\n");
> + free_unpkd_tlv(tlv);
> + goto out;
> + }
> +
> + tlv->type = tlv_type;
> + tlv->length = tlv_length;
> + tlv->info = (u8 *)malloc(tlv_length);
> + if (tlv->info) {
> + memset(tlv->info,0, tlv_length);
> + memcpy(tlv->info, info, tlv_length);
> + } else {
> + printf("ERROR: Failed to malloc space for incoming "
> + "TLV info \n");
> + free_unpkd_tlv(tlv);
> + goto out;
> + }
> +
> + /* Validate the TLV */
> + tlv_offset += sizeof(*tlv_head_ptr) + tlv_length;
> +
> + if (tlv->type == TYPE_127) { /* private TLV */
> + /* TODO: give VSI TLV to VDP */
> + }
> +
> + if ((tlv->type != TYPE_0) && !tlv_stored) {
> + printf("\n%s: allocated TLV (%lu) "
> + " was not stored! (%p)\n", __func__, tlv->type,
> + tlv);
> + tlv = free_unpkd_tlv(tlv);
> + port->ecp.stats.statsTLVsUnrecognizedTotal++;
> + }
> +
> + tlv = NULL;
> + tlv_stored = false;
> + } while(tlv_type != 0);
> +
> +out:
> + if (frame_error) {
> + port->ecp.stats.statsFramesDiscardedTotal++;
> + port->ecp.stats.statsFramesInErrorsTotal++;
> + port->ecp.rx.badFrame = true;
> + }
> +
> + return;
> +}
> +
snip
> +
> +/* ecp_build_ECPDU - create an ecp protocol data unit
> + * @port: currently used port
> + * @mode: mode to create pdu with (REQ or ACK)
> + *
> + * returns true on success, false on failure
> + *
> + * creates the frame header with the ports mac address, the ecp header with REQ
> + * or ACK mode, plus a list of packed TLVs created from the profiles on this
> + * port.
> + */
> +bool ecp_build_ECPDU(struct port *port, int mode)
> +{
> + struct l2_ethhdr eth;
> + struct ecp_hdr ecp_hdr;
> + u8 own_addr[ETH_ALEN];
> + u32 fb_offset = 0;
> + u32 datasize = 0;
> + struct packed_tlv *ptlv = NULL;
> + struct lldp_module *np;
> + struct vdp_data *vd;
> + struct vsi_profile *p;
> +
> + if (port->ecp.tx.frameout) {
> + free(port->ecp.tx.frameout);
> + port->ecp.tx.frameout = NULL;
> + }
> +
> + /* TODO: different multicast address for sending ECP over S-channel (multi_cast_source_s)
> + * S-channels to implement later */
> + memcpy(eth.h_dest, multi_cast_source, ETH_ALEN);
> + l2_packet_get_own_src_addr(port->ecp.l2,(u8 *)&own_addr);
> + memcpy(eth.h_source, &own_addr, ETH_ALEN);
> + eth.h_proto = htons(ETH_P_ECP);
> + port->ecp.tx.frameout = (u8 *)malloc(ETH_FRAME_LEN);
> + if (port->ecp.tx.frameout == NULL) {
> + printf("InfoECPDU: Failed to malloc frame buffer \n");
> + return false;
> + }
> + memset(port->ecp.tx.frameout,0,ETH_FRAME_LEN);
> + memcpy(port->ecp.tx.frameout, (void *)ð, sizeof(struct l2_ethhdr));
> + fb_offset += sizeof(struct l2_ethhdr);
> +
> + ecp_hdr.oui[0] = 0x0;
> + ecp_hdr.oui[1] = 0x1b;
> + ecp_hdr.oui[2] = 0x3f;
> +
> + ecp_hdr.pad1 = 0x0;
> +
> + ecp_hdr.subtype = ECP_SUBTYPE;
> + switch(mode) {
> + case VDP_PROFILE_REQ:
> + ecp_hdr.mode = ECP_REQUEST;
> + break;
> + case VDP_PROFILE_ACK:
> + ecp_hdr.mode = ECP_ACK;
> + break;
> + default:
> + printf("%s(%i): unknown mode for %s !\n", __func__, __LINE__,
> + port->ifname);
> + }
> +
> + ecp_hdr.seqnr = port->ecp.lastSequence;
> +
> + if ((sizeof(struct ecp_hdr)+fb_offset) > ETH_MAX_DATA_LEN)
> + goto error;
> + memcpy(port->ecp.tx.frameout+fb_offset, (void *)&ecp_hdr, sizeof(struct ecp_hdr));
> + datasize += sizeof(struct ecp_hdr);
> + fb_offset += sizeof(struct ecp_hdr);
> +
> + /* TODO: create tlvs from profiles here */
> +
> + /* The End TLV marks the end of the LLDP PDU */
> + ptlv = pack_end_tlv();
> + if (!ptlv || ((ptlv->size + fb_offset) > ETH_MAX_DATA_LEN))
> + goto error;
> + memcpy(port->ecp.tx.frameout + fb_offset, ptlv->tlv, ptlv->size);
> + datasize += ptlv->size;
> + fb_offset += ptlv->size;
> + ptlv = free_pkd_tlv(ptlv);
> +
> + if (datasize < ETH_MIN_DATA_LEN)
> + port->ecp.tx.sizeout = ETH_MIN_PKT_LEN;
Might also be worth checking ETH_MAX_DATA_LEN after the above TODO adding profiles is done.
> + else
> + port->ecp.tx.sizeout = fb_offset;
> +
> + return true;
> +
> +error:
> + ptlv = free_pkd_tlv(ptlv);
> + if (port->ecp.tx.frameout)
> + free(port->ecp.tx.frameout);
> + port->ecp.tx.frameout = NULL;
> + printf("InfoECPDU: packed TLV too large for tx frame\n");
> + return false;
> +}
> +
Please merge the relevant pieces of this patch with the following patch so it does not add 'struct ecp' to the port structure then immediately move it to vdp_data in the following patch.
Thanks,
John.
^ permalink raw reply
* Re: [E1000-eedc] [PATCH 02/10] implementation of IEEE 802.1Qbg in lldpad, part 1
From: John Fastabend @ 2010-09-23 0:50 UTC (permalink / raw)
To: Jens Osterkamp
Cc: chrisw@redhat.com, evb@yahoogroups.com,
e1000-eedc@lists.sourceforge.net,
virtualization@lists.linux-foundation.org
In-Reply-To: <1282739262-14968-3-git-send-email-jens@linux.vnet.ibm.com>
On 8/25/2010 5:27 AM, Jens Osterkamp wrote:
> This patch contains the first part of an initial implementation of the
> IEEE 802.1Qbg standard: it implements code for the exchange of EVB
> capabilities between a host with virtual machines and an adjacent switch.
> For this it adds a new EVB TLV to LLDP.
>
> Exchange of EVB TLV may be enabled or disabled on a per port basis.
> Information about the information negotiated by the protocol can be
> queried on the commandline with lldptool.
>
> This patch adds support for querying and setting parameters used in
> the exchange of EVB TLV messages.
> The parameters that can be set are:
>
> - forwarding mode
> - host protocol capabilities (RTE, ECP, VDP)
> - no. of supported VSIs
> - retransmission timer exponent (RTE)
>
> The parameters are implemented as a local policy: all frames received by
> an adjacent switch are validated against this policy and taken over where
> appropriate. Negotiated parameters are stored in lldpads config, picked up
> again and used at the next start.
>
> The patch applies to lldpad 0.9.38 and still contains code to log protocol
> activity more verbosely than it would be necessary in the final version.
>
> Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
> ---
> Makefile.am | 10 +-
> include/lldp.h | 19 ++
> include/lldp_evb.h | 80 ++++++
> include/lldp_evb_clif.h | 51 ++++
> include/lldp_evb_cmds.h | 31 +++
> include/lldp_tlv.h | 1 +
> lldp_evb.c | 658 +++++++++++++++++++++++++++++++++++++++++++++++
> lldp_evb_clif.c | 226 ++++++++++++++++
> lldp_evb_cmds.c | 512 ++++++++++++++++++++++++++++++++++++
> lldpad.c | 2 +
> lldptool.c | 2 +
> 11 files changed, 1588 insertions(+), 4 deletions(-)
> create mode 100644 include/lldp_evb.h
> create mode 100644 include/lldp_evb_clif.h
> create mode 100644 include/lldp_evb_cmds.h
> create mode 100644 lldp_evb.c
> create mode 100644 lldp_evb_clif.c
> create mode 100644 lldp_evb_cmds.c
>
> diff --git a/Makefile.am b/Makefile.am
> index 743e16f..d59a6fa 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -37,7 +37,7 @@ lldpad_include_HEADERS = include/dcb_types.h include/dcbtool.h \
> include/dcb_osdep.h include/clif.h include/lldp_dcbx_cmds.h include/common.h \
> include/lldpad.h include/os.h include/includes.h include/lldp_mand_cmds.h \
> include/clif_msgs.h include/lldp_basman_cmds.h include/lldp_8023_cmds.h \
> -include/lldp_med_cmds.h include/lldp_dcbx_cfg.h
> +include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h
>
> noinst_HEADERS = include/config.h include/ctrl_iface.h \
> include/dcb_driver_if_types.h include/dcb_driver_interface.h \
> @@ -47,7 +47,7 @@ include/event_iface.h include/messages.h include/parse_cli.h include/version.h \
> include/lldptool_cli.h include/list.h \
> include/lldp_mand_clif.h include/lldp_basman_clif.h include/lldp_med_clif.h \
> include/lldp_8023_clif.h include/lldp_dcbx_clif.h include/lldptool.h \
> -include/lldp_rtnl.h
> +include/lldp_rtnl.h include/lldp_evb_clif.h
>
> lldpad_SOURCES = lldpad.c config.c drv_cfg.c ctrl_iface.c event_iface.c eloop.c \
> common.c os_unix.c lldp_dcbx_cmds.c log.c lldpad_shm.c \
> @@ -62,10 +62,12 @@ lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
> lldp_util.c include/lldp_util.h \
> lldp_mand.c include/lldp_mand.h \
> lldp_mand_cmds.c lldp_basman_cmds.c lldp_8023_cmds.c lldp_med_cmds.c \
> +lldp_evb_cmds.c \
> lldp_tlv.c include/lldp_tlv.h \
> lldp_basman.c include/lldp_basman.h \
> lldp_med.c include/lldp_med.h \
> -lldp_8023.c include/lldp_8023.h
> +lldp_8023.c include/lldp_8023.h \
> +lldp_evb.c include/lldp_evb.h
>
>
>
> @@ -74,7 +76,7 @@ $(lldpad_include_HEADERS) $(noinst_HEADERS)
>
> lldptool_SOURCES = lldptool.c clif.c lldptool_cmds.c common.c os_unix.c \
> lldp_mand_clif.c lldp_basman_clif.c lldp_med_clif.c lldp_8023_clif.c \
> -lldp_dcbx_clif.c $(lldpad_include_HEADERS) $(noinst_HEADERS)
> +lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) $(noinst_HEADERS)
>
> nltest_SOURCES = nltest.c nltest.h
>
> diff --git a/include/lldp.h b/include/lldp.h
> index 66532bd..e00ba7a 100644
> --- a/include/lldp.h
> +++ b/include/lldp.h
> @@ -45,6 +45,8 @@
> /* Telecommunications Industry Association TR-41 Committee */
> #define OUI_TIA_TR41 0x0012bb
>
> +#define OUI_IEEE_8021Qbg 0x001b3f
> +
> /* IEEE 802.3AB Clause 9: TLV Types */
> #define CHASSIS_ID_TLV 1
> #define PORT_ID_TLV 2
> @@ -186,5 +188,22 @@ enum {
> #define LLDP_8023_LINKAGG_CAPABLE (1 << 0)
> #define LLDP_8023_LINKAGG_ENABLED (1 << 1)
>
> +/* IEEE 802.1Qbg subtype */
> +#define LLDP_EVB_SUBTYPE 0
> +
> +/* forwarding mode */
> +#define LLDP_EVB_CAPABILITY_FORWARD_STANDARD (1 << 7)
> +#define LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY (1 << 6)
> +
> +/* EVB supported protocols */
> +#define LLDP_EVB_CAPABILITY_PROTOCOL_RTE (1 << 2)
> +#define LLDP_EVB_CAPABILITY_PROTOCOL_ECP (1 << 1)
> +#define LLDP_EVB_CAPABILITY_PROTOCOL_VDP (1 << 0)
> +
> +/* EVB specific values */
> +#define LLDP_EVB_DEFAULT_MAX_VSI 4096
> +#define LLDP_EVB_DEFAULT_SVSI 3295
> +#define LLDP_EVB_DEFAULT_RTE 15
> +
> void somethingChangedLocal(char *ifname);
> #endif /* _LLDP_H */
> diff --git a/include/lldp_evb.h b/include/lldp_evb.h
> new file mode 100644
> index 0000000..667f9ad
> --- /dev/null
> +++ b/include/lldp_evb.h
> @@ -0,0 +1,80 @@
> +/*******************************************************************************
> +
> + implementation of EVB TLVs for LLDP
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#ifndef _LLDP_EVB_H
> +#define _LLDP_EVB_H
> +
> +#include "lldp_mod.h"
> +
> +#define LLDP_MOD_EVB OUI_IEEE_8021Qbg
> +#define LLDP_OUI_SUBTYPE { 0x00, 0x1b, 0x3f, 0x00 }
> +
> +typedef enum {
> + EVB_OFFER_CAPABILITIES = 0,
> + EVB_CONFIGURE,
> + EVB_CONFIRMATION
> +} evb_state;
> +
> +struct tlv_info_evb {
> + u8 oui[3];
> + u8 sub;
> + /* supported forwarding mode */
> + u8 smode;
> + /* supported capabilities */
> + u8 scap;
> + /* currently configured forwarding mode */
> + u8 cmode;
> + /* currently configured capabilities */
> + u8 ccap;
> + /* supported no. of vsi */
> + u16 svsi;
> + /* currently configured no. of vsi */
> + u16 cvsi;
> + /* retransmission exponent */
> + u8 rte;
> +} __attribute__ ((__packed__));
> +
> +struct evb_data {
> + char ifname[IFNAMSIZ];
> + struct unpacked_tlv *evb;
> + struct tlv_info_evb *tie;
> + /* local policy */
> + struct tlv_info_evb *policy;
> + int state;
> + LIST_ENTRY(evb_data) entry;
> +};
> +
> +struct evb_user_data {
> + LIST_HEAD(evb_head, evb_data) head;
> +};
> +
> +struct lldp_module *evb_register(void);
> +void evb_unregister(struct lldp_module *mod);
> +struct packed_tlv *evb_gettlv(struct port *port);
> +void evb_ifdown(char *);
> +void evb_ifup(char *);
> +struct evb_data *evb_data(char *ifname);
> +
> +#endif /* _LLDP_EVB_H */
> diff --git a/include/lldp_evb_clif.h b/include/lldp_evb_clif.h
> new file mode 100644
> index 0000000..acaee5e
> --- /dev/null
> +++ b/include/lldp_evb_clif.h
> @@ -0,0 +1,51 @@
> +/*******************************************************************************
> +
> + implementation of EVB TLVs for LLDP
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#ifndef _LLDP_EVB_CLIF_H
> +#define _LLDP_EVB_CLIF_H
> +
> +struct lldp_module *evb_cli_register(void);
> +void evb_cli_unregister(struct lldp_module *);
> +int evb_print_tlv(u32, u16, char *);
> +
> +#define EVB_BUF_SIZE 256
> +
> +#define ARG_EVB_FORWARDING_MODE "fmode"
> +
> +#define VAL_EVB_FMODE_BRIDGE "bridge"
> +#define VAL_EVB_FMODE_REFLECTIVE_RELAY "reflectiverelay"
> +
> +#define ARG_EVB_CAPABILITIES "capabilities"
> +
> +#define VAL_EVB_CAPA_RTE "rte"
> +#define VAL_EVB_CAPA_ECP "ecp"
> +#define VAL_EVB_CAPA_VDP "vdp"
> +#define VAL_EVB_CAPA_NONE "none"
> +
> +#define ARG_EVB_VSIS "vsis"
> +
> +#define ARG_EVB_RTE "rte"
> +
> +#endif
> diff --git a/include/lldp_evb_cmds.h b/include/lldp_evb_cmds.h
> new file mode 100644
> index 0000000..1367e5d
> --- /dev/null
> +++ b/include/lldp_evb_cmds.h
> @@ -0,0 +1,31 @@
> +/*******************************************************************************
> +
> + implementation of EVB TLVs for LLDP
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#ifndef _LLDP_EVB_CMDS_H
> +#define _LLDP_EVB_CMDS_H
> +
> +struct arg_handlers *evb_get_arg_handlers();
> +
> +#endif
> diff --git a/include/lldp_tlv.h b/include/lldp_tlv.h
> index a32cc71..fe3a75a 100644
> --- a/include/lldp_tlv.h
> +++ b/include/lldp_tlv.h
> @@ -144,6 +144,7 @@ int tlv_ok(struct unpacked_tlv *tlv);
> #define TLVID_8021(sub) TLVID(OUI_IEEE_8021, (sub))
> #define TLVID_8023(sub) TLVID(OUI_IEEE_8023, (sub))
> #define TLVID_MED(sub) TLVID(OUI_TIA_TR41, (sub))
> +#define TLVID_8021Qbg(sub) TLVID(OUI_IEEE_8021Qbg, (sub))
>
> /* the size in bytes needed for a packed tlv from unpacked tlv */
> #define TLVSIZE(t) ((t) ? (2 + (t)->length) : 0)
> diff --git a/lldp_evb.c b/lldp_evb.c
> new file mode 100644
> index 0000000..4213137
> --- /dev/null
> +++ b/lldp_evb.c
> @@ -0,0 +1,658 @@
> +/*******************************************************************************
> +
> + implementation of EVB TLVs for LLDP
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#include <net/if.h>
> +#include <sys/queue.h>
> +#include <sys/socket.h>
> +#include <sys/ioctl.h>
> +#include <sys/utsname.h>
> +#include <linux/if_bridge.h>
> +#include <string.h>
> +#include "lldp.h"
> +#include "lldp_evb.h"
> +#include "messages.h"
> +#include "config.h"
> +#include "common.h"
> +#include "lldp_mand_clif.h"
> +#include "lldp_evb_clif.h"
> +#include "lldp_evb_cmds.h"
> +
> +extern struct lldp_head lldp_head;
> +
> +struct evb_data *evb_data(char *ifname)
> +{
> + struct evb_user_data *ud;
> + struct evb_data *ed = NULL;
> +
> + ud = find_module_user_data_by_if(ifname, &lldp_head, LLDP_MOD_EVB);
> + if (ud) {
> + LIST_FOREACH(ed, &ud->head, entry) {
> + if (!strncmp(ifname, ed->ifname, IFNAMSIZ))
> + return ed;
> + }
> + }
> + return NULL;
> +}
> +
> +static void evb_print_tlvinfo(struct tlv_info_evb *tie)
> +{
> + printf("%s(%i): supported forwarding mode: %02x\n", __FILE__, __LINE__, tie->smode);
> + printf("%s(%i): configured forwarding mode: %02x\n", __FILE__, __LINE__, tie->cmode);
> + printf("%s(%i): supported capabilities: %02x\n", __FILE__, __LINE__, tie->scap);
> + printf("%s(%i): configured capabilities: %02x\n", __FILE__, __LINE__, tie->ccap);
> + printf("%s(%i): supported no. of vsis: %04i\n", __FILE__, __LINE__, tie->svsi);
> + printf("%s(%i): configured no. of vsis: %04i\n", __FILE__, __LINE__, tie->cvsi);
> + printf("%s(%i): rte: %02i\n\n", __FILE__, __LINE__, tie->rte);
> +}
> +
> +/*
> + * evb_bld_cfg_tlv - build the EVB TLV
> + * @ed: the evb data struct
> + *
> + * Returns 0 on success
> + */
> +static int evb_bld_cfg_tlv(struct evb_data *ed)
> +{
> + int rc = 0;
> + int i;
> + struct unpacked_tlv *tlv = NULL;
> +
> + /* free ed->evb if it exists */
> + FREE_UNPKD_TLV(ed, evb);
> +
> + if (!is_tlv_txenabled(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
> + fprintf(stderr, "%s:%s:EVB tx is currently disabled !\n",
> + __func__, ed->ifname);
> + rc = EINVAL;
> + goto out_err;
> + }
> +
> + tlv = create_tlv();
> + if (!tlv)
> + goto out_err;
> +
> + tlv->type = ORG_SPECIFIC_TLV;
> + tlv->length = sizeof(struct tlv_info_evb);
> + tlv->info = (u8 *)malloc(tlv->length);
> + if(!tlv->info) {
> + free(tlv);
> + tlv = NULL;
> + rc = ENOMEM;
> + goto out_err;
> + }
> + memcpy(tlv->info, ed->tie, tlv->length);
> +
> + printf("### %s:type %i, length %i, info ", __func__, tlv->type, tlv->length);
> +
> + for (i=0; i < tlv->length; i++) {
> + printf("%02x ", tlv->info[i]);
> + }
> +
Remove the extra braces around the for statement. Granted the rest of
lldpad may not follow a consistent coding style but lets try going
forward and hopefully I get around to lldpad soon.
> + printf("\n");
> +
> + ed->evb = tlv;
> +out_err:
> + return rc;
> +}
> +
> +static void evb_free_tlv(struct evb_data *ed)
> +{
> + if (ed) {
> + FREE_UNPKD_TLV(ed, evb);
> + }
Same here extra braces.
> +}
> +
> +/* evb_init_cfg_tlv:
> + *
> + * fill up tlv_info_evb structure with reasonable info
> + */
> +static int evb_init_cfg_tlv(struct evb_data *ed)
> +{
> + char arg_path[EVB_BUF_SIZE];
> + char *param;
> +
> + /* load policy from config */
> + ed->policy = (struct tlv_info_evb *) calloc(1, sizeof(struct tlv_info_evb));
Use malloc instead of callod() of one.
> +
> + if (!ed->policy)
> + return ENOMEM;
> +
> + /* set defaults */
> + hton24(ed->policy->oui, LLDP_MOD_EVB);
> + ed->policy->smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
> + ed->policy->scap = 0;
> + ed->policy->cmode = 0;
> + ed->policy->ccap = 0;
> + ed->policy->svsi = 0 /*LLDP_EVB_DEFAULT_SVSI*/;
> + ed->policy->rte = 0 /*LLDP_EVB_DEFAULT_RTE*/;
> +
> + /* pull forwarding mode into policy */
> + snprintf(arg_path, sizeof(arg_path), "%s%08x.fmode",
> + TLVID_PREFIX, TLVID_8021Qbg(LLDP_EVB_SUBTYPE));
> +
> + if (get_cfg(ed->ifname, arg_path, (void *) ¶m, CONFIG_TYPE_STRING)) {
> + printf("%s:%s: loading EVB policy for forwarding mode failed, using default.\n",
> + __func__, ed->ifname);
> + } else {
> + if (strcasestr(param, VAL_EVB_FMODE_BRIDGE)) {
> + ed->policy->smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
> + }
> +
> + if (strcasestr(param, VAL_EVB_FMODE_REFLECTIVE_RELAY)) {
> + ed->policy->smode = LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY;
> + }
> +
> + printf("%s:%s: policy param fmode = %s.\n", __func__, ed->ifname, param);
> + printf("%s:%s: policy param smode = %x.\n", __func__, ed->ifname, ed->policy->smode);
> + }
> +
> + /* pull capabilities into policy */
> + snprintf(arg_path, sizeof(arg_path), "%s%08x.capabilities",
> + TLVID_PREFIX, TLVID_8021Qbg(LLDP_EVB_SUBTYPE));
> +
> + if (get_cfg(ed->ifname, arg_path, (void *) ¶m, CONFIG_TYPE_STRING)) {
> + printf("%s:%s: loading EVB policy for capabilities failed, using default.\n",
> + __func__, ed->ifname);
> + } else {
> + if (strcasestr(param, VAL_EVB_CAPA_RTE)) {
> + ed->policy->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
> + }
> +
> + if (strcasestr(param, VAL_EVB_CAPA_ECP)) {
> + ed->policy->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
> + }
> +
> + if (strcasestr(param, VAL_EVB_CAPA_VDP)) {
> + ed->policy->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
> + }
> +
> + printf("%s:%s: policy param capabilities = %s.\n", __func__, ed->ifname, param);
> + printf("%s:%s: policy param scap = %x.\n", __func__, ed->ifname, ed->policy->scap);
> + }
> +
> + /* pull rte into policy */
> + snprintf(arg_path, sizeof(arg_path), "%s%08x.rte",
> + TLVID_PREFIX, TLVID_8021Qbg(LLDP_EVB_SUBTYPE));
> +
> + if (get_cfg(ed->ifname, arg_path, (void *) ¶m, CONFIG_TYPE_STRING)) {
> + printf("%s:%s: loading EVB policy for rte failed, using default.\n",
> + __func__, ed->ifname);
> + } else {
> + ed->policy->rte = atoi(param);
> +
> + printf("%s:%s: policy param rte = %s.\n", __func__, ed->ifname, param);
> + printf("%s:%s: policy param rte = %i.\n", __func__, ed->ifname, ed->policy->rte);
> + }
> +
> + /* pull vsis into policy */
> + snprintf(arg_path, sizeof(arg_path), "%s%08x.vsis",
> + TLVID_PREFIX, TLVID_8021Qbg(LLDP_EVB_SUBTYPE));
> +
> + if (get_cfg(ed->ifname, arg_path, (void *) ¶m, CONFIG_TYPE_STRING)) {
> + printf("%s:%s: loading EVB policy for vsis failed, using default.\n",
> + __func__, ed->ifname);
> + } else {
> + ed->policy->svsi = atoi(param);
> +
> + printf("%s:%s: policy param vsis = %s.\n", __func__, ed->ifname, param);
> + printf("%s:%s: policy param vsis = %i.\n", __func__, ed->ifname, ed->policy->svsi);
> + }
> +
> + /* load last used EVB TLV ... */
> + ed->tie = (struct tlv_info_evb *) calloc(1, sizeof(struct tlv_info_evb));
> +
> + if (!ed->tie)
> + return ENOMEM;
> +
> + if (get_config_tlvinfo_bin(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE),
> + (void *)ed->tie, sizeof(struct tlv_info_evb))) {
> + printf("%s:%s: loading last used EVB TLV failed, using default.\n",
> + __func__, ed->ifname);
> + hton24(ed->tie->oui, LLDP_MOD_EVB);
> + ed->tie->smode = LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY | LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
> + ed->tie->cmode = 0x0;
> + ed->tie->scap = LLDP_EVB_CAPABILITY_PROTOCOL_RTE | LLDP_EVB_CAPABILITY_PROTOCOL_ECP
> + | LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
> + ed->tie->ccap = 0x0;
> + ed->tie->svsi = LLDP_EVB_DEFAULT_SVSI;
> + ed->tie->cvsi = 0x0;
> + ed->tie->rte = LLDP_EVB_DEFAULT_RTE;
> + } else {
> + printf("%s(%i): loaded last used EVB TLV from file.\n", __FILE__, __LINE__);
> + }
> +
> + return 0;
> +}
> +
> +static int evb_bld_tlv(struct evb_data *ed)
> +{
> + int rc = 0;
> +
> + if (!port_find_by_name(ed->ifname)) {
> + rc = EEXIST;
> + goto out_err;
> + }
> +
> + if (!init_cfg()) {
> + rc = ENOENT;
> + goto out_err;
> + }
> +
> + if (evb_bld_cfg_tlv(ed)) {
> + fprintf(stderr, "### %s:%s:evb_bld_cfg_tlv() failed\n",
> + __func__, ed->ifname);
> + rc = EINVAL;
> + goto out_err_destroy;
> + }
> +
Looks like you need 'return rc;' here.
This code falls through to destroy_cfg() if this is the case the 'goto
out_err_destroy' is unneeded above. It really looks like a missed return
code though
> +out_err_destroy:
> + destroy_cfg();
> +
> +out_err:
> + return rc;
> +}
> +
> +static void evb_free_data(struct evb_user_data *ud)
> +{
> + struct evb_data *ed;
> + if (ud) {
> + while (!LIST_EMPTY(&ud->head)) {
> + ed = LIST_FIRST(&ud->head);
> + LIST_REMOVE(ed, entry);
> + evb_free_tlv(ed);
> + free(ed);
> + }
> + }
> +}
> +
> +struct packed_tlv *evb_gettlv(struct port *port)
> +{
> + int size;
> + struct evb_data *ed;
> + struct packed_tlv *ptlv = NULL;
> +
> + ed = evb_data(port->ifname);
> + if (!ed)
> + goto out_err;
> +
> + evb_free_tlv(ed);
> +
> + if (evb_bld_tlv(ed)) {
> + fprintf(stderr, "### %s:%s evb_bld_tlv failed\n",
> + __func__, port->ifname);
> + goto out_err;
> + }
> +
> + size = TLVSIZE(ed->evb);
> +
> + if (!size)
> + goto out_err;
> +
> + ptlv = create_ptlv();
> + if (!ptlv)
> + goto out_err;
> +
> + ptlv->tlv = malloc(size);
> + if (!ptlv->tlv)
> + goto out_free;
> +
> + ptlv->size = 0;
> + PACK_TLV_AFTER(ed->evb, ptlv, size, out_free);
> + return ptlv;
> +out_free:
> + /* FIXME: free function returns pointer ? */
> + ptlv = free_pkd_tlv(ptlv);
> +out_err:
> + fprintf(stderr,"### %s:%s: failed\n", __func__, port->ifname);
> + return NULL;
> +
remove extra line between return and closing brace.
> +}
> +
> +/* evb_check_and_fill
> + *
> + * checks values received in TLV and takes over some values
> + */
> +int evb_check_and_fill(struct evb_data *ed, struct tlv_info_evb *tie)
> +{
> + /* sanity check of received data in tie */
> + if ((tie->smode & (LLDP_EVB_CAPABILITY_FORWARD_STANDARD |
> + LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY)) == 0)
> + return TLV_ERR;
> +
> + if ((tie->svsi < 0) || (tie->svsi > LLDP_EVB_DEFAULT_MAX_VSI))
> + return TLV_ERR;
> +
> + if ((tie->cvsi < 0) || (tie->cvsi > LLDP_EVB_DEFAULT_MAX_VSI))
> + return TLV_ERR;
> +
> + /* check bridge capabilities against local policy*/
> + /* if bridge supports RR and we support it as well, request it
> + * by setting smode in tlv to be sent out (ed->tie->smode) */
> + if ( (tie->smode & ed->policy->smode) ==
> + LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY ) {
> + ed->tie->smode = LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY;
> + } else {
> + ed->tie->smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
> + }
> +
> + /* If both sides support RTE, set it */
> + if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_RTE)
> + ed->tie->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
> +
> + /* If both sides support ECP, set it */
> + if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_ECP)
> + ed->tie->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
> +
> + /* If both sides support VDP, set it */
> + if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_VDP)
> + ed->tie->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
> +
> + /* If supported caps include VDP take over min value of both */
> + if (ed->tie->scap & LLDP_EVB_CAPABILITY_PROTOCOL_VDP)
> + ed->tie->cvsi = MIN(ed->policy->svsi,tie->svsi);
> +
> + /* If both sides support RTE and value offer is > 0, set it */
> + if ((ed->tie->scap & LLDP_EVB_CAPABILITY_PROTOCOL_RTE) &&
> + (tie->rte > 0) && (ed->policy->rte > 0))
> + ed->tie->rte = MAX(ed->policy->rte,tie->rte);
> +
> + if (set_config_tlvinfo_bin(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE),
> + (void *)ed->tie, sizeof(struct tlv_info_evb))) {
> + printf("%s(%i): error saving tlv_info_evb !\n", __FILE__, __LINE__);
> + } else {
> + printf("%s(%i): saved tlv_info_evb to config !\n", __FILE__, __LINE__);
> + }
> +
> + /* maybe switch has already set the mode based on the saved info sent
> + * out on ifup */
> +
> + if (tie->cmode == ed->tie->smode) {
> + ed->tie->cmode = tie->cmode;
> + }
> +
remove the unneeded braces in the if statements above.
> + /* only look at the mode for now
> + if (tie->ccap == ed->tie->ccap) {
> + ed->tie->ccap = tie->ccap;
> + }
> +
> + if (tie->cvsi == ed->tie->cvsi) {
> + ed->tie->cvsi = tie->cvsi;
> + }
> + */
Why is this commented out? I will review the spec shortly, but please
remind me. If its not needed remove it and add it later in a clean
patch
> +
> + return TLV_OK;
> +}
> +
> +/* evb_compare
> + *
> + * compare our own and received tlv_info_evb
> + */
> +static int evb_compare(struct evb_data *ed, struct tlv_info_evb *tie)
> +{
> + printf("%s(%i): \n", __func__, __LINE__);
> +
> + if ((ed->tie->cmode == tie->cmode) /* &&
> + (ed->tie->ccap == tie->ccap) &&
> + (ed->tie->cvsi == tie->cvsi)*/)
Same here if its going to be commented out lets remove it for now.
> + return 0;
> + else
> + return 1;
> +}
> +
> +/* evb_statemachine:
> + *
> + * handle possible states during EVB capabilities exchange
> + *
> + * possible states: EVB_OFFER_CAPABILITIES
> + * EVB_CONFIGURE
> + * EVB_CONFIRMATION
> + */
> +static void evb_statemachine(struct evb_data *ed, struct tlv_info_evb *tie)
> +{
> + switch(ed->state) {
> + case EVB_OFFER_CAPABILITIES:
> + /* waiting for valid packets to pour in
> + * if valid packet was received,
> + * - check parameters with what we have offered for this if,
> + * - fill structure with data,
> + * - enable local tx
> + * - switch to EVB_CONFIGURE
> + */
> + printf("%s: state -> EVB_OFFER_CAPABILITIES\n", __func__);
> + if (evb_check_and_fill(ed, tie) != TLV_OK) {
> + fprintf(stderr, "Invalid contents of EVB Cfg TLV !\n");
> + return;
> + }
> + somethingChangedLocal(ed->ifname); /* trigger tx with new values */
> + ed->state = EVB_CONFIGURE;
> + break;
> + case EVB_CONFIGURE:
> + /* we received a valid packet, if contents is same with our local settings
> + * we can switch state to EVB_CONFIRMATION.*/
> + printf("%s: state -> EVB_CONFIGURE\n", __func__);
> + if (evb_compare(ed, tie)) {
> + ed->state= EVB_OFFER_CAPABILITIES;
> + } else {
> + printf("tlv_info_evb now equal !\n");
> + ed->state = EVB_CONFIRMATION;
> + }
> + somethingChangedLocal(ed->ifname);
> + break;
> + case EVB_CONFIRMATION:
> + /* we are already in confirmation and received a new packet with
> + * different parameters ? Check parameters. switch state back to
> + * EVB_CONFIGURE ? */
> + printf("%s: state -> EVB_CONFIRMATION\n", __func__);
> +#if 0
> + if (ed->tie->scap & LLDP_EVB_CAPABILITY_PROTOCOL_ECP)
> + ecp_init(ed->ifname);
> +#endif
remove the #if 0/endif it is never used.
> + break;
> + default:
> + fprintf(stderr, "EVB statemachine reached invalid state !\n");
> + break;
> + }
> +}
> +
> +/*
> + * evb_rchange: process RX TLV LLDPDU
> + *
> + * TLV not consumed on error
> + */
> +static int evb_rchange(struct port *port, struct unpacked_tlv *tlv)
> +{
> + int i;
> + struct evb_data *ed;
> + struct tlv_info_evb *tie = (struct tlv_info_evb *) tlv->info;
> + u8 oui_subtype[OUI_SUB_SIZE] = LLDP_OUI_SUBTYPE;
> +
> + if (!init_cfg()) {
> + return SUBTYPE_INVALID;
> + }
> +
> + ed = evb_data(port->ifname);
> +
> + if (!ed)
> + return SUBTYPE_INVALID;
> +
> + if (tlv->type == TYPE_127) {
> + /* check for length */
> + if (tlv->length < (OUI_SUB_SIZE)) {
> + return TLV_ERR;
> + }
> +
> + /* check for oui */
> + if (memcmp(tlv->info, &oui_subtype, OUI_SUB_SIZE)) {
> + return SUBTYPE_INVALID;
> + }
> +
> + /* disable rx if tx has been disabled by administrator */
> + if (!is_tlv_txenabled(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
> + fprintf(stderr, "### %s:%s:EVB Config disabled\n",
> + __func__, ed->ifname);
> + return TLV_OK;
> + }
> +
> + fprintf(stderr, "%s:type %i, length %i, info ", __func__, tlv->type, tlv->length);
> +
> + for (i=0; i < tlv->length; i++) {
> + fprintf(stderr, "%02x ", tlv->info[i]);
> + }
> +
> + printf("\n");
> +
> + evb_print_tlvinfo(tie);
> +
> + /* change state */
> + evb_statemachine(ed, tie);
> +
> + /* check which values have been taken over */
> + evb_print_tlvinfo(ed->tie);
> + }
> +
> + return TLV_OK;
> +}
> +
> +void evb_ifdown(char *ifname)
> +{
> + struct evb_data *ed;
> +
> + printf("%s called !\n", __func__);
> +
> + ed = evb_data(ifname);
> + if (!ed)
> + goto out_err;
> +
> + free(ed->tie);
> + LIST_REMOVE(ed, entry);
> + evb_free_tlv(ed);
> + free(ed);
> + fprintf(stderr, "### %s:port %s removed\n", __func__, ifname);
> + return;
> +out_err:
> + fprintf(stderr, "### %s:port %s adding failed\n", __func__, ifname);
> +
This error message is a cut and paste error from ifup? Nothing is being added here suspect "port %s remove failed" would be more accurate.
> + return;
> +}
> +
> +void evb_ifup(char *ifname)
> +{
> + struct evb_data *ed;
> + struct evb_user_data *ud;
> +
> + ed = evb_data(ifname);
> + if (ed) {
> + fprintf(stderr, "### %s:%s exists\n", __func__, ifname);
> + goto out_err;
> + }
> +
> + /* not found, alloc/init per-port tlv data */
> + ed = (struct evb_data *) calloc(1, sizeof(struct evb_data));
Use malloc for calloc of one.
> + if (!ed) {
> + fprintf(stderr, "### %s:%s malloc %ld failed\n",
> + __func__, ifname, sizeof(*ed));
> + goto out_err;
> + }
> + strncpy(ed->ifname, ifname, IFNAMSIZ);
> +
> + if (!init_cfg()) {
> + goto out_err;
> + }
> +
> + if (evb_init_cfg_tlv(ed)) {
> + fprintf(stderr, "### %s:%s evb_init_cfg_tlv failed\n", __func__, ifname);
> + free(ed);
> + goto out_err;
> + }
> +
> + ed->state = EVB_OFFER_CAPABILITIES;
> +
> + if (evb_bld_tlv(ed)) {
> + fprintf(stderr, "### %s:%s evb_bld_tlv failed\n", __func__, ifname);
> + free(ed);
> + goto out_err;
> + }
> +
> + ud = find_module_user_data_by_if(ifname, &lldp_head, LLDP_MOD_EVB);
> + LIST_INSERT_HEAD(&ud->head, ed, entry);
> + fprintf(stderr, "### %s:port %s added\n", __func__, ifname);
> + return;
> +
> +out_err:
> + fprintf(stderr, "### %s:port %s adding failed\n", __func__, ifname);
This error message is a bit misleading if it comes from ed already existing.
> + return;
> +}
> +
> +static const struct lldp_mod_ops evb_ops = {
> + .lldp_mod_register = evb_register,
> + .lldp_mod_unregister = evb_unregister,
> + .lldp_mod_gettlv = evb_gettlv,
> + .lldp_mod_rchange = evb_rchange,
> + .lldp_mod_ifup = evb_ifup,
> + .lldp_mod_ifdown = evb_ifdown,
> + .get_arg_handler = evb_get_arg_handlers,
> +};
> +
> +struct lldp_module *evb_register(void)
> +{
> + struct lldp_module *mod;
> + struct evb_user_data *ud;
> +
> + mod = malloc(sizeof(*mod));
> + if (!mod) {
> + fprintf(stderr, "failed to malloc module data\n");
> + log_message(MSG_ERR_SERVICE_START_FAILURE,
> + "%s", "failed to malloc module data");
> + goto out_err;
> + }
> + ud = malloc(sizeof(struct evb_user_data));
> + if (!ud) {
> + free(mod);
> + fprintf(stderr, "failed to malloc module user data\n");
> + log_message(MSG_ERR_SERVICE_START_FAILURE,
> + "%s", "failed to malloc module user data");
> + goto out_err;
> + }
> + LIST_INIT(&ud->head);
> + mod->id = LLDP_MOD_EVB;
> + mod->ops = &evb_ops;
> + mod->data = ud;
> + fprintf(stderr, "### %s:done\n", __func__);
> + return mod;
> +
> +out_err:
> + fprintf(stderr, "### %s:failed\n", __func__);
> + return NULL;
> +}
> +
> +void evb_unregister(struct lldp_module *mod)
> +{
> + if (mod->data) {
> + evb_free_data((struct evb_user_data *) mod->data);
> + free(mod->data);
> + }
> + free(mod);
> + fprintf(stderr, "### %s:done\n", __func__);
> +}
> diff --git a/lldp_evb_clif.c b/lldp_evb_clif.c
> new file mode 100644
> index 0000000..7479d74
> --- /dev/null
> +++ b/lldp_evb_clif.c
> @@ -0,0 +1,226 @@
> +/*******************************************************************************
> +
> + implementation of EVB TLVs for LLDP
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#include "includes.h"
> +#include "common.h"
> +#include <stdio.h>
> +#include <syslog.h>
> +#include <sys/un.h>
> +#include <sys/stat.h>
> +#include "lldp_mod.h"
> +#include "lldptool.h"
> +#include "lldp.h"
> +#include "lldp_evb.h"
> +#include "lldp_evb_clif.h"
> +
> +void evb_print_cfg_tlv(u16, char *info);
> +int evb_print_help();
> +
> +u32 evb_lookup_tlv_name(char *tlvid_str);
> +
> +static const struct lldp_mod_ops evb_ops_clif = {
> + .lldp_mod_register = evb_cli_register,
> + .lldp_mod_unregister = evb_cli_unregister,
> + .print_tlv = evb_print_tlv,
> + .lookup_tlv_name = evb_lookup_tlv_name,
> + .print_help = evb_print_help,
> +};
> +
> +struct type_name_info evb_tlv_names[] = {
> + { (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE,
> + "EVB Configuration TLV",
> + "evbCfg", evb_print_cfg_tlv },
> + { INVALID_TLVID, NULL, NULL }
> +};
> +
> +int evb_print_help()
> +{
> + struct type_name_info *tn = &evb_tlv_names[0];
> +
> + while (tn->type != INVALID_TLVID) {
> + if (tn->key && strlen(tn->key) && tn->name) {
> + printf(" %s", tn->key);
> + if (strlen(tn->key)+3 <= 8)
> + printf("\t");
> + printf("\t: %s\n", tn->name);
> + }
> + tn++;
> + }
> +
> + return 0;
> +}
> +
> +struct lldp_module *evb_cli_register(void)
> +{
> + struct lldp_module *mod;
> +
> + mod = malloc(sizeof(*mod));
> + if (!mod) {
> + fprintf(stderr, "failed to malloc module data\n");
> + return NULL;
> + }
> + mod->id = LLDP_MOD_EVB;
> + mod->ops = &evb_ops_clif;
> +
> + return mod;
> +}
> +
> +void evb_cli_unregister(struct lldp_module *mod)
> +{
> + free(mod);
> +}
> +
> +void evb_print_cfg_tlv(u16 len, char *info)
> +{
> + u8 smode;
> + u8 scap;
> + u8 cmode;
> + u8 ccap;
> + u16 svsi;
> + u16 cvsi;
> + u8 rte;
> +
> + if (len != 9) {
> + printf("Bad Cfg TLV: %s\n", info);
> + return;
> + }
> +
> + if (!hexstr2bin(info, &smode, sizeof(smode))) {
> + printf("supported forwarding mode: (0x%02hhx)", smode);
> +
> + if (smode & LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY)
> + printf(" reflective relay");
> +
> + if (smode & LLDP_EVB_CAPABILITY_FORWARD_STANDARD)
> + printf(" standard 802.1Q");
> +
> + printf("\n");
> + } else {
> + printf("Unable to decode smode !\n");
> + }
> +
> + if (!hexstr2bin(info+2, &scap, sizeof(scap))) {
> + printf("\tsupported capabilities: (0x%02hhx)", scap);
> +
> + if ( scap & LLDP_EVB_CAPABILITY_PROTOCOL_RTE)
> + printf(" RTE");
> +
> + if ( scap & LLDP_EVB_CAPABILITY_PROTOCOL_ECP)
> + printf(" ECP");
> +
> + if ( scap & LLDP_EVB_CAPABILITY_PROTOCOL_VDP)
> + printf(" VDP");
> +
> + printf("\n");
> + } else {
> + printf("Unable to decode scap !\n");
> + }
> +
> + if (!hexstr2bin(info+4, &cmode, sizeof(cmode))) {
> + printf("\tconfigured forwarding mode: (0x%02hhx)", cmode);
> +
> + if (cmode & LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY)
> + printf(" reflective relay");
> +
> + if (cmode & LLDP_EVB_CAPABILITY_FORWARD_STANDARD)
> + printf(" standard 802.1Q");
> +
> + printf("\n");
> + } else {
> + printf("Unable to decode cmode !\n");
> + }
> +
> + if (!hexstr2bin(info+6, &ccap, sizeof(ccap))) {
> + printf("\tconfigured capabilities: (0x%02hhx)", ccap);
> +
> + if ( ccap & LLDP_EVB_CAPABILITY_PROTOCOL_RTE)
> + printf(" RTE");
> +
> + if ( ccap & LLDP_EVB_CAPABILITY_PROTOCOL_ECP)
> + printf(" ECP");
> +
> + if ( ccap & LLDP_EVB_CAPABILITY_PROTOCOL_VDP)
> + printf(" VDP");
> +
> + printf("\n");
> + } else {
> + printf("Unable to decode ccap !\n");
> + }
> +
> + if (!hexstr2bin(info+8, (u8 *)&svsi, sizeof(svsi))) {
> + printf("\tno. of supported VSIs: %04i\n",svsi);
> + } else {
> + printf("Unable to decode svsi !\n");
> + }
> +
> + if (!hexstr2bin(info+12, (u8 *)&cvsi, sizeof(cvsi))) {
> + printf("\tno. of configured VSIs: %04i\n",cvsi);
> + } else {
> + printf("Unable to decode cvsi !\n");
> + }
> +
> + if (!hexstr2bin(info+16, &rte, sizeof(rte))) {
> + printf("\tRTE: %i\n",rte);
> + } else {
> + printf("Unable to decode cvsi !\n");
> + }
> +
> + printf("\n");
> +}
> +
> +/* return 1: if it printed the TLV
> + * 0: if it did not
> + */
> +int evb_print_tlv(u32 tlvid, u16 len, char *info)
> +{
> + struct type_name_info *tn = &evb_tlv_names[0];
> +
> + while (tn->type != INVALID_TLVID) {
> + if (tlvid == tn->type) {
> + printf("%s\n", tn->name);
> + if (tn->print_info) {
> + printf("\t");
> + tn->print_info(len-4, info);
> + }
> + return 1;
> + }
> + tn++;
> + }
> +
> + return 0;
> +}
> +
> +u32 evb_lookup_tlv_name(char *tlvid_str)
> +{
> + struct type_name_info *tn = &evb_tlv_names[0];
> +
> + while (tn->type != INVALID_TLVID) {
> + if (!strcasecmp(tn->key, tlvid_str))
> + return tn->type;
> + tn++;
> + }
> + return INVALID_TLVID;
> +}
> +
> diff --git a/lldp_evb_cmds.c b/lldp_evb_cmds.c
> new file mode 100644
> index 0000000..095a32c
> --- /dev/null
> +++ b/lldp_evb_cmds.c
> @@ -0,0 +1,512 @@
> +/*******************************************************************************
> +
> + implementation of EVB TLVs for LLDP
> + (c) Copyright IBM Corp. 2010
> +
> + Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
> +
> + This program is free software; you can redistribute it and/or modify it
> + under the terms and conditions of the GNU General Public License,
> + version 2, as published by the Free Software Foundation.
> +
> + This program is distributed in the hope it will be useful, but WITHOUT
> + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + more details.
> +
> + You should have received a copy of the GNU General Public License along with
> + this program; if not, write to the Free Software Foundation, Inc.,
> + 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> +
> + The full GNU General Public License is included in this distribution in
> + the file called "COPYING".
> +
> +*******************************************************************************/
> +
> +#include "includes.h"
> +#include "common.h"
> +#include <stdio.h>
> +#include <syslog.h>
> +#include <sys/un.h>
> +#include <sys/stat.h>
> +#include <arpa/inet.h>
> +#include <string.h>
> +#include "lldpad.h"
> +#include "ctrl_iface.h"
> +#include "lldp.h"
> +#include "lldp_evb.h"
> +#include "lldp_mand_clif.h"
> +#include "lldp_evb_clif.h"
> +#include "lldp/ports.h"
> +#include "libconfig.h"
> +#include "config.h"
> +#include "clif_msgs.h"
> +#include "lldp/states.h"
> +
> +static int get_arg_tlvtxenable(struct cmd *, char *, char *, char *);
> +static int set_arg_tlvtxenable(struct cmd *, char *, char *, char *);
> +
> +static int get_arg_fmode(struct cmd *, char *, char *, char *);
> +static int set_arg_fmode(struct cmd *, char *, char *, char *);
> +
> +static int get_arg_rte(struct cmd *, char *, char *, char *);
> +static int set_arg_rte(struct cmd *, char *, char *, char *);
> +
> +static int get_arg_vsis(struct cmd *, char *, char *, char *);
> +static int set_arg_vsis(struct cmd *, char *, char *, char *);
> +
> +static int get_arg_capabilities(struct cmd *, char *, char *, char *);
> +static int set_arg_capabilities(struct cmd *, char *, char *, char *);
> +
> +static struct arg_handlers arg_handlers[] = {
> + { ARG_EVB_FORWARDING_MODE, get_arg_fmode, set_arg_fmode },
> + { ARG_EVB_CAPABILITIES, get_arg_capabilities, set_arg_capabilities },
> + { ARG_EVB_VSIS, get_arg_vsis, set_arg_vsis },
> + { ARG_EVB_RTE, get_arg_rte, set_arg_rte },
> + { ARG_TLVTXENABLE, get_arg_tlvtxenable, set_arg_tlvtxenable },
> + { NULL }
> +};
> +
> +static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + int value;
> + char *s;
> + char arg_path[EVB_BUF_SIZE];
> +
> + if (cmd->cmd != cmd_gettlv)
> + return cmd_invalid;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
> + TLVID_PREFIX, cmd->tlvid, arg);
> +
> + if (get_cfg(cmd->ifname, arg_path, (void *)&value,
> + CONFIG_TYPE_BOOL))
> + value = false;
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + if (value)
> + s = VAL_YES;
> + else
> + s = VAL_NO;
> +
> + sprintf(obuf, "%02x%s%04x%s", (unsigned int) strlen(arg), arg,
> + (unsigned int) strlen(s), s);
> +
> + return cmd_success;
> +}
> +
> +static int set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + int value;
> + char arg_path[EVB_BUF_SIZE];
> +
> + if (cmd->cmd != cmd_settlv)
> + return cmd_invalid;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + if (!strcasecmp(argvalue, VAL_YES))
> + value = 1;
> + else if (!strcasecmp(argvalue, VAL_NO))
> + value = 0;
> + else
> + return cmd_invalid;
> +
> + snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
> + TLVID_PREFIX, cmd->tlvid, arg);
> +
> + if (set_cfg(cmd->ifname, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
> + return cmd_failed;
> +
> + return cmd_success;
> +}
> +
> +static int get_arg_fmode(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + char *s;
> + struct evb_data *ed;
> +
> + if (cmd->cmd != cmd_gettlv)
> + return cmd_invalid;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + ed = evb_data((char *) &cmd->ifname);
> + if (!ed)
> + return cmd_invalid;
> + if (ed->policy->smode & LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY)
> + s = VAL_EVB_FMODE_BRIDGE;
> + else
> + s = VAL_EVB_FMODE_REFLECTIVE_RELAY;
> +
> + sprintf(obuf, "%02x%s%04x%s", (unsigned int) strlen(arg), arg,
> + (unsigned int) strlen(s), s);
> +
> + return cmd_success;
> +}
> +
> +static int set_arg_fmode(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + u8 smode;
> + char arg_path[EVB_BUF_SIZE];
> + struct evb_data *ed;
> +
> + if (cmd->cmd != cmd_settlv)
> + return cmd_invalid;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + ed = evb_data((char *) &cmd->ifname);
> +
> + if (!ed)
> + return cmd_invalid;
> +
> + smode = 0;
> +
> + if (!strcasecmp(argvalue, VAL_EVB_FMODE_BRIDGE)) {
> + smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
> + }
> +
> + if (!strcasecmp(argvalue, VAL_EVB_FMODE_REFLECTIVE_RELAY)) {
> + smode = LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY;
> + }
> +
> + if (smode == 0) {
> + return cmd_invalid;
> + } else {
> + ed->policy->smode = smode;
> + }
> +
> + snprintf(arg_path, sizeof(arg_path), "%s%08x.fmode",
> + TLVID_PREFIX, cmd->tlvid);
> +
> + if (set_cfg(ed->ifname, arg_path, (void *) &argvalue, CONFIG_TYPE_STRING)) {
> + printf("%s:%s: saving EVB forwarding mode failed.\n",
> + __func__, ed->ifname);
> + return cmd_invalid;
> + }
> +
> + return cmd_success;
> +}
> +
> +static int get_arg_capabilities(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + int c;
> + char *s, *t;
> + struct evb_data *ed;
> +
> + printf("%s(%i): arg %s, argvalue %s !\n", __func__, __LINE__, arg, argvalue);
> +
> + s = t = malloc(EVB_BUF_SIZE);
> +
This looks like a memory leak? Where does s or t get free'd.
> + if (!s)
> + return cmd_invalid;
> +
> + memset(s, 0, EVB_BUF_SIZE);
> +
> + if (cmd->cmd != cmd_gettlv)
> + return cmd_invalid;
certainly a memory leak if 'cmd != cmd_gettlv'.
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + ed = evb_data((char *) &cmd->ifname);
> + if (!ed)
> + return cmd_invalid;
> +
> + if (ed->policy->scap & LLDP_EVB_CAPABILITY_PROTOCOL_RTE) {
> + c = sprintf(s, VAL_EVB_CAPA_RTE " ");
> + if (c <= 0)
> + return cmd_invalid;
> + s += c;
> + }
> +
> + if (ed->policy->scap & LLDP_EVB_CAPABILITY_PROTOCOL_ECP) {
> + c = sprintf(s, VAL_EVB_CAPA_ECP " ");
> + if (c <= 0)
> + return cmd_invalid;
> + s += c;
> + }
> +
> + if (ed->policy->scap & LLDP_EVB_CAPABILITY_PROTOCOL_VDP) {
> + c = sprintf(s, VAL_EVB_CAPA_VDP " ");
> + if (c <= 0)
> + return cmd_invalid;
> + s += c;
> + }
> +
> + sprintf(obuf, "%02x%s%04x%s", (unsigned int) strlen(arg), arg,
> + (unsigned int) strlen(t), t);
> +
> + return cmd_success;
> +}
> +
> +static int set_arg_capabilities(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + u8 scap = 0;
> + char arg_path[EVB_BUF_SIZE];
> + struct evb_data *ed;
> +
> + if (cmd->cmd != cmd_settlv)
> + return cmd_invalid;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + ed = evb_data((char *) &cmd->ifname);
> +
> + if (!ed)
> + return cmd_invalid;
> +
> + if (strcasestr(argvalue, VAL_EVB_CAPA_RTE)) {
> + scap |= LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
> + }
> +
> + if (strcasestr(argvalue, VAL_EVB_CAPA_ECP)) {
> + scap |= LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
> + }
> +
> + if (strcasestr(argvalue, VAL_EVB_CAPA_VDP)) {
> + scap |= LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
> + }
Fix the above indentation scap has one too many tabs. Remove the extra braces as well.
> +
> + ed->policy->scap = scap;
> +
> + snprintf(arg_path, sizeof(arg_path), "%s%08x.capabilities",
> + TLVID_PREFIX, cmd->tlvid);
> +
> + if (set_cfg(ed->ifname, arg_path, (void *) &argvalue, CONFIG_TYPE_STRING)) {
> + printf("%s:%s: saving EVB capabilities failed.\n",
> + __func__, ed->ifname);
> + return cmd_invalid;
> + }
> +
> + return cmd_success;
> +}
> +
> +static int get_arg_rte(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + char s[EVB_BUF_SIZE];
> + struct evb_data *ed;
> +
> + if (cmd->cmd != cmd_gettlv)
> + return cmd_invalid;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + ed = evb_data((char *) &cmd->ifname);
> + if (!ed)
> + return cmd_invalid;
> +
> + if (sprintf(s, "%i", ed->policy->rte) <= 0)
> + return cmd_invalid;
> +
> + sprintf(obuf, "%02x%s%04x%s", (unsigned int) strlen(arg), arg,
> + (unsigned int) strlen(s), s);
> +
> + return cmd_success;
> +}
> +
> +static int set_arg_rte(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + int value, err;
> + char arg_path[EVB_BUF_SIZE];
> + char svalue[10];
> + char *sv;
> + struct evb_data *ed = NULL;
> +
> + if (cmd->cmd != cmd_settlv)
> + goto out_err;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + goto out_err;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + ed = evb_data((char *) &cmd->ifname);
> +
> + if (!ed)
> + goto out_err;
'goto out_err' will cause a null pointer dereference on ed->ifname below.
> +
> + value = atoi(argvalue);
> +
> + if ((value < 0))
> + goto out_err;
> +
> + ed->policy->rte = value;
> +
> + err = snprintf(arg_path, sizeof(arg_path), "%s%08x.rte",
> + TLVID_PREFIX, cmd->tlvid);
> +
> + if (err < 0)
> + goto out_err;
> +
> + err = snprintf(svalue, sizeof(svalue), "%i", value);
> +
> + if (err < 0)
> + goto out_err;
> +
> + sv = &svalue[0];
> +
> + if (set_cfg(ed->ifname, arg_path, (void *) &sv, CONFIG_TYPE_STRING)) {
> + goto out_err;
> + }
Is this correct '&sv' why not just use svalue.
> +
> + return cmd_success;
> +
> +out_err:
> + printf("%s:%s: saving EVB rte failed.\n", __func__, ed->ifname);
> + return cmd_invalid;
> +}
> +
> +static int get_arg_vsis(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + char s[EVB_BUF_SIZE];
> + struct evb_data *ed;
> +
> + if (cmd->cmd != cmd_gettlv)
> + return cmd_invalid;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + return cmd_invalid;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + ed = evb_data((char *) &cmd->ifname);
> + if (!ed)
> + return cmd_invalid;
> +
> + if (sprintf(s, "%04i", ed->policy->svsi) <= 0)
> + return cmd_invalid;
> +
> + sprintf(obuf, "%02x%s%04x%s", (unsigned int) strlen(arg), arg,
> + (unsigned int) strlen(s), s);
> +
> + return cmd_success;
> +}
> +
> +static int set_arg_vsis(struct cmd *cmd, char *arg, char *argvalue,
> + char *obuf)
> +{
> + int value, err;
> + char arg_path[EVB_BUF_SIZE];
> + char svalue[10];
> + char *sv;
> + struct evb_data *ed = NULL;
> +
> + if (cmd->cmd != cmd_settlv)
> + goto out_err;
> +
> + switch (cmd->tlvid) {
> + case (LLDP_MOD_EVB << 8) | LLDP_EVB_SUBTYPE:
> + break;
> + case INVALID_TLVID:
> + goto out_err;
> + default:
> + return cmd_not_applicable;
> + }
> +
> + ed = evb_data((char *) &cmd->ifname);
> +
> + if (!ed)
> + goto out_err;
> +
> + value = atoi(argvalue);
> +
> + if ((value < 0) || (value > LLDP_EVB_DEFAULT_MAX_VSI))
> + goto out_err;
> +
> + ed->policy->svsi = value;
> +
> + err = snprintf(arg_path, sizeof(arg_path), "%s%08x.vsis",
> + TLVID_PREFIX, cmd->tlvid);
> +
> + if (err < 0)
> + goto out_err;
> +
> + err = snprintf(svalue, sizeof(svalue), "%i", value);
> +
> + if (err < 0)
> + goto out_err;
> +
> + sv = &svalue[0];
> +
> + if (set_cfg(ed->ifname, arg_path, (void *) &sv, CONFIG_TYPE_STRING)) {
> + goto out_err;
> + }
> +
> + return cmd_success;
> +
> +out_err:
> + printf("%s:%s: saving EVB vsis failed.\n", __func__, ed->ifname);
'goto out_err' is used above twice before ed has been initialized.
> + return cmd_invalid;
> +}
> +
> +struct arg_handlers *evb_get_arg_handlers()
> +{
> + return &arg_handlers[0];
> +}
> diff --git a/lldpad.c b/lldpad.c
> index a89b5a4..571da31 100644
> --- a/lldpad.c
> +++ b/lldpad.c
> @@ -49,6 +49,7 @@
> #include "lldp_dcbx.h"
> #include "lldp_med.h"
> #include "lldp_8023.h"
> +#include "lldp_evb.h"
> #include "config.h"
> #include "lldpad_shm.h"
> #include "clif.h"
> @@ -63,6 +64,7 @@ struct lldp_module *(*register_tlv_table[])(void) = {
> dcbx_register,
> med_register,
> ieee8023_register,
> + evb_register,
> NULL,
> };
>
> diff --git a/lldptool.c b/lldptool.c
> index 5cf2846..7e166fe 100644
> --- a/lldptool.c
> +++ b/lldptool.c
> @@ -39,6 +39,7 @@
> #include "lldp_med_clif.h"
> #include "lldp_8023_clif.h"
> #include "lldp_dcbx_clif.h"
> +#include "lldp_evb_clif.h"
> #include "lldptool.h"
> #include "lldptool_cli.h"
> #include "lldp_mod.h"
> @@ -156,6 +157,7 @@ struct lldp_module *(*register_tlv_table[])(void) = {
> ieee8023_cli_register,
> med_cli_register,
> dcbx_cli_register,
> + evb_cli_register,
> NULL,
> };
>
Jens, in general this looks OK. Can you fix the coding style throughout
I prefer for single line if statements,
if (x)
a_line;
else (y)
b_line;
The intent here is to use the same coding style as linux kernel where it
is reasonable to do so. Like I said before I know lldpad is not at all
consistent in this regard, but I want to get the rest of the code in
order and certainly have new code be consistent.
Thanks!
John
^ permalink raw reply
* Re: [PATCH 1/4] x86: remove cast from void*
From: matt mooney @ 2010-09-21 19:15 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: xen-devel, x86, kernel-janitors, Chris Wright, virtualization,
Ingo Molnar, H. Peter Anvin, Tejun Heo, Thomas Gleixner,
Ian Campbell
In-Reply-To: <4C98FBDB.6030601@goop.org>
On 11:39 Tue 21 Sep , Jeremy Fitzhardinge wrote:
> On 09/13/2010 10:18 PM, matt mooney wrote:
> > Unnecessary cast from void* in assignment.
> >
> > Signed-off-by: matt mooney <mfm@muteddisk.com>
> > ---
> > arch/x86/xen/mmu.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> > index 42086ac..7436283 100644
> > --- a/arch/x86/xen/mmu.c
> > +++ b/arch/x86/xen/mmu.c
> > @@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
> >
> > if (offset < pgd_index(USER_LIMIT)) {
> > struct page *page = virt_to_page(pgd_page);
> > - user_ptr = (pgd_t *)page->private;
> > + user_ptr = page->private;
>
> Um, page->private is unsigned long anyway, so this is needed either way.
>
You're right. I missed that one, sorry; I really thought I had verified it.
-mfm
^ permalink raw reply
* PROBLEM: [BISECTED] 2.6.35.5 xen domU panics just after the boot
From: Paweł Zuzelski @ 2010-09-21 19:05 UTC (permalink / raw)
To: Jeremy Fitzhardinge; +Cc: lkml, virtualization, xen-devel
Hello,
kernels 2.6.35.5 and 2.6.32.22 xen domU panics at the very begining of the
boot process.
I have bisected it to a single commit, and the first bad commit is:
[fb412a178502dc498430723b082a932f797e4763] xen: use percpu interrupts for IPIs and VIRQs
kernel v2.6.35.5 with reverted this commit works for me.
Here are the kernel configs I was using:
http://carme.pld-linux.org/~pawelz/kernel-2.6.35.5-domU-config
http://carme.pld-linux.org/~pawelz/kernel-2.6.32.22-domU-config
As you can see they are stripped down configs, intended to run in domU only.
I was testing it with the very simple domU configuration:
kernel = '/srv/xen/bzImage'
memory = '128'
vcpus = 2
name = 'test'
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
Here is the full output of kernel 2.6.35.5:
Using config file "/etc/xen/test".
Started domain test
[ 0.000000] Policy zone: DMA32
[ 0.000000] Kernel command line:
[ 0.000000] PID hash table entries: 512 (order: 0, 4096 bytes)
[ 0.000000] Subtract (33 early reservations)
[ 0.000000] #1 [0001976000 - 0001987000] XEN PAGETABLES
[ 0.000000] #2 [0001000000 - 00019125f8] TEXT DATA BSS
[ 0.000000] #3 [0001933000 - 0001976000] XEN START INFO
[ 0.000000] #4 [0000010000 - 0000012000] TRAMPOLINE
[ 0.000000] #5 [0000012000 - 0000040000] PGTABLE
[ 0.000000] #6 [0001912600 - 0001917600] NODE_DATA
[ 0.000000] #7 [0001917600 - 0001918600] BOOTMEM
[ 0.000000] #8 [0001918600 - 0001918618] BOOTMEM
[ 0.000000] #9 [0001919000 - 000191a000] BOOTMEM
[ 0.000000] #10 [000191a000 - 000191b000] BOOTMEM
[ 0.000000] #11 [000191b000 - 000191c000] BOOTMEM
[ 0.000000] #12 [0002200000 - 00023c0000] MEMMAP 0
[ 0.000000] #13 [0001918640 - 00019187c0] BOOTMEM
[ 0.000000] #14 [000191c000 - 000191cc00] BOOTMEM
[ 0.000000] #15 [000191d000 - 000191e000] BOOTMEM
[ 0.000000] #16 [000191e000 - 000191f000] BOOTMEM
[ 0.000000] #17 [000191f000 - 0001920000] BOOTMEM
[ 0.000000] #18 [00019187c0 - 00019188a0] BOOTMEM
[ 0.000000] #19 [00019188c0 - 0001918928] BOOTMEM
[ 0.000000] #20 [0001918940 - 00019189a8] BOOTMEM
[ 0.000000] #21 [00019189c0 - 0001918a28] BOOTMEM
[ 0.000000] #22 [0001918a40 - 0001918a41] BOOTMEM
[ 0.000000] #23 [0001918a80 - 0001918a81] BOOTMEM
[ 0.000000] #24 [0001987000 - 00019c1000] BOOTMEM
[ 0.000000] #25 [0001918ac0 - 0001918ac8] BOOTMEM
[ 0.000000] #26 [0001918b00 - 0001918b08] BOOTMEM
[ 0.000000] #27 [0001918b40 - 0001918b48] BOOTMEM
[ 0.000000] #28 [0001918b80 - 0001918b90] BOOTMEM
[ 0.000000] #29 [0001918bc0 - 0001918cc0] BOOTMEM
[ 0.000000] #30 [0001918cc0 - 0001918d08] BOOTMEM
[ 0.000000] #31 [0001918d40 - 0001918d88] BOOTMEM
[ 0.000000] #32 [0001920000 - 0001921000] BOOTMEM
[ 0.000000] Memory: 118724k/131072k available (3327k kernel code, 448k absent, 11900k reserved, 3931k data, 440k init)
[ 0.000000] SLUB: Genslabs=14, HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[ 0.000000] Hierarchical RCU implementation.
[ 0.000000] RCU-based detection of stalled CPUs is disabled.
[ 0.000000] Verbose stalled-CPUs detection is disabled.
[ 0.000000] NR_IRQS:2304
[ 0.000000] Console: colour dummy device 80x25
[ 0.000000] console [tty0] enabled
[ 0.000000] console [hvc0] enabled
[ 0.000000] installing Xen timer for CPU 0
[ 0.000000] BUG: unable to handle kernel NULL pointer dereference at (null)
[ 0.000000] IP: [<(null)>] (null)
[ 0.000000] PGD 0
[ 0.000000] Oops: 0010 [#1] SMP
[ 0.000000] last sysfs file:
[ 0.000000] CPU 0
[ 0.000000] Modules linked in:
[ 0.000000]
[ 0.000000] Pid: 0, comm: swapper Not tainted 2.6.35.5 #1 /
[ 0.000000] RIP: e030:[<0000000000000000>] [<(null)>] (null)
[ 0.000000] RSP: e02b:ffffffff81601d70 EFLAGS: 00010082
[ 0.000000] RAX: ffffffff818fdb50 RBX: 0000000000000000 RCX: 0000000000000000
[ 0.000000] RDX: 0000000000000000 RSI: ffffffff818c7958 RDI: 0000000000000000
[ 0.000000] RBP: ffffffff81601d88 R08: ffffea00001b22d8 R09: 000000000000001a
[ 0.000000] R10: 0000000000000000 R11: 0000000000006477 R12: ffffffff81623280
[ 0.000000] R13: 0000000000000000 R14: 00000000ffffffea R15: 0000000000000000
[ 0.000000] FS: 0000000000000000(0000) GS:ffff880001987000(0000) knlGS:0000000000000000
[ 0.000000] CS: e033 DS: 0000 ES: 0000 CR0: 000000008005003b
[ 0.000000] CR2: 0000000000000000 CR3: 00000000016b9000 CR4: 0000000000002620
[ 0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 0.000000] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[ 0.000000] Process swapper (pid: 0, threadinfo ffffffff81600000, task ffffffff816c1020)
[ 0.000000] Stack:
[ 0.000000] ffffffff8107c849 0000000000000000 ffff880007c0d000 ffffffff81601da8
[ 0.000000] <0> ffffffff8107c829 ffffffff8133d3fb ffffffff81623280 ffffffff81601df8
[ 0.000000] <0> ffffffff8107c033 ffffffff816202e4 ffffffff816232e4 ffffffff8100572f
[ 0.000000] Call Trace:
[ 0.000000] [<ffffffff8107c849>] ? default_enable+0x1a/0x28
[ 0.000000] [<ffffffff8107c829>] default_startup+0x19/0x1f
[ 0.000000] [<ffffffff8133d3fb>] ? _raw_spin_lock_irqsave+0xd/0x24
[ 0.000000] [<ffffffff8107c033>] __setup_irq+0x1ab/0x2d8
[ 0.000000] [<ffffffff8100572f>] ? xen_restore_fl_direct_end+0x0/0x1
[ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
[ 0.000000] [<ffffffff8107c278>] request_threaded_irq+0x118/0x146
[ 0.000000] [<ffffffff8125dda5>] bind_virq_to_irqhandler+0x146/0x168
[ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
[ 0.000000] [<ffffffff810055ee>] xen_setup_timer+0x59/0x9d
[ 0.000000] [<ffffffff81731b68>] xen_time_init+0x7b/0x89
[ 0.000000] [<ffffffff81731ead>] x86_late_time_init+0xa/0x11
[ 0.000000] [<ffffffff8172eb49>] start_kernel+0x30b/0x38d
[ 0.000000] [<ffffffff8172e2c6>] x86_64_start_reservations+0xb1/0xb5
[ 0.000000] [<ffffffff817313e8>] xen_start_kernel+0x508/0x50f
[ 0.000000] Code: Bad RIP value.
[ 0.000000] RIP [<(null)>] (null)
[ 0.000000] RSP <ffffffff81601d70>
[ 0.000000] CR2: 0000000000000000
[ 0.000000] ---[ end trace 4eaa2a86a8e2da22 ]---
[ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
[ 0.000000] Pid: 0, comm: swapper Tainted: G D 2.6.35.5 #1
[ 0.000000] Call Trace:
[ 0.000000] [<ffffffff8133bae9>] panic+0x86/0xfa
[ 0.000000] [<ffffffff8103c5c6>] do_exit+0x6d/0x77e
[ 0.000000] [<ffffffff8133d43f>] ? _raw_spin_unlock_irqrestore+0x11/0x13
[ 0.000000] [<ffffffff8103ac55>] ? kmsg_dump+0x11e/0x139
[ 0.000000] [<ffffffff8100b936>] oops_end+0x8f/0x94
[ 0.000000] [<ffffffff810239cc>] no_context+0x1f4/0x203
[ 0.000000] [<ffffffff81023b65>] __bad_area_nosemaphore+0x18a/0x1ad
[ 0.000000] [<ffffffff81023b96>] bad_area_nosemaphore+0xe/0x10
[ 0.000000] [<ffffffff81023f10>] do_page_fault+0x115/0x229
[ 0.000000] [<ffffffff8133daf5>] page_fault+0x25/0x30
[ 0.000000] [<ffffffff8107c849>] ? default_enable+0x1a/0x28
[ 0.000000] [<ffffffff8107c829>] default_startup+0x19/0x1f
[ 0.000000] [<ffffffff8133d3fb>] ? _raw_spin_lock_irqsave+0xd/0x24
[ 0.000000] [<ffffffff8107c033>] __setup_irq+0x1ab/0x2d8
[ 0.000000] [<ffffffff8100572f>] ? xen_restore_fl_direct_end+0x0/0x1
[ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
[ 0.000000] [<ffffffff8107c278>] request_threaded_irq+0x118/0x146
[ 0.000000] [<ffffffff8125dda5>] bind_virq_to_irqhandler+0x146/0x168
[ 0.000000] [<ffffffff810052bb>] ? xen_timer_interrupt+0x0/0x17a
[ 0.000000] [<ffffffff810055ee>] xen_setup_timer+0x59/0x9d
[ 0.000000] [<ffffffff81731b68>] xen_time_init+0x7b/0x89
[ 0.000000] [<ffffffff81731ead>] x86_late_time_init+0xa/0x11
[ 0.000000] [<ffffffff8172eb49>] start_kernel+0x30b/0x38d
[ 0.000000] [<ffffffff8172e2c6>] x86_64_start_reservations+0xb1/0xb5
[ 0.000000] [<ffffffff817313e8>] xen_start_kernel+0x508/0x50f
Additional info:
arch: x86_64
cpu: Intel(R) Xeon(R) CPU E5345 @ 2.33GHz
xen: 3.2.1
dom0: Linux version 2.6.26-2-xen-amd64 (Debian 2.6.26-24lenny1)
(dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease)
(Debian 4.1.2-25)) #1 SMP Thu Aug 19 01:12:45 UTC 2010
--
Regards,
Paweł Zuzelski
^ permalink raw reply
* Re: [PATCH 1/4] x86: remove cast from void*
From: Jeremy Fitzhardinge @ 2010-09-21 18:39 UTC (permalink / raw)
To: matt mooney
Cc: xen-devel, Jeremy Fitzhardinge, x86, kernel-janitors,
Chris Wright, virtualization, Ingo Molnar, H. Peter Anvin,
Tejun Heo, Thomas Gleixner, Ian Campbell
In-Reply-To: <1284441511-11511-1-git-send-email-mfm@muteddisk.com>
On 09/13/2010 10:18 PM, matt mooney wrote:
> Unnecessary cast from void* in assignment.
>
> Signed-off-by: matt mooney <mfm@muteddisk.com>
> ---
> arch/x86/xen/mmu.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
> index 42086ac..7436283 100644
> --- a/arch/x86/xen/mmu.c
> +++ b/arch/x86/xen/mmu.c
> @@ -737,7 +737,7 @@ pgd_t *xen_get_user_pgd(pgd_t *pgd)
>
> if (offset < pgd_index(USER_LIMIT)) {
> struct page *page = virt_to_page(pgd_page);
> - user_ptr = (pgd_t *)page->private;
> + user_ptr = page->private;
Um, page->private is unsigned long anyway, so this is needed either way.
J
^ permalink raw reply
* RE: [PATCH 2/2] staging: hv: Remove camel cases from vmbus channel functions
From: Haiyang Zhang @ 2010-09-21 15:10 UTC (permalink / raw)
To: Greg KH
Cc: 'linux-kernel@vger.kernel.org',
'devel@driverdev.osuosl.org',
'virtualization@lists.osdl.org', 'gregkh@suse.de',
Hank Janssen
In-Reply-To: <20100920232921.GA31204@kroah.com>
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Monday, September 20, 2010 7:29 PM
> Function name changes are one thing.
>
> Variable names are another thing.
>
> Again, one patch per thing please.
>
> It's easier to read and verify that everything is sane.
>
> Please try this one again.
I will separate the variable names and function names into two patches,
And, incorporate your suggestions like - naming the functions as vmbus_*
instead of vmbus_channel_*, updating the comments, and etc..
Thanks,
- Haiyang
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox