From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Pirko Subject: Re: [patch net-next 02/10] switchdev: introduce transaction item queue for attr_set and obj_add Date: Tue, 22 Sep 2015 18:25:57 +0200 Message-ID: <20150922162557.GC2255@nanopsycho.orion> References: <1442930031-4732-1-git-send-email-jiri@resnulli.us> <1442930031-4732-3-git-send-email-jiri@resnulli.us> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: Jiri Pirko , Netdev , "David S. Miller" , Ido Schimmel , , Florian Fainelli , Guenter Roeck , Vivien Didelot , "Rosen, Rami" , Roopa Prabhu , Premkumar Jonnala , "andrew@lunn.ch" , Andy Gospodarek To: Scott Feldman Return-path: Received: from mail-db3on0066.outbound.protection.outlook.com ([157.55.234.66]:9336 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758813AbbIVQkM (ORCPT ); Tue, 22 Sep 2015 12:40:12 -0400 Content-Disposition: inline In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: Tue, Sep 22, 2015 at 06:10:24PM CEST, sfeldma@gmail.com wrote: >On Tue, Sep 22, 2015 at 6:53 AM, Jiri Pirko wrote: >> From: Jiri Pirko >> >> Now, the memory allocation in prepare/commit state is done separatelly >> in each driver (rocker). Introduce the similar mechanism in generic >> switchdev code, in form of queue. That can be used not only for memory >> allocations, but also for different items. Commit/abort item destruction >> is handled as well. >> >> Signed-off-by: Jiri Pirko > >> diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c >> index df5a544..55a8411 100644 >> --- a/net/switchdev/switchdev.c >> +++ b/net/switchdev/switchdev.c >> @@ -1,6 +1,6 @@ >> /* >> * net/switchdev/switchdev.c - Switch device API >> - * Copyright (c) 2014 Jiri Pirko >> + * Copyright (c) 2014-2015 Jiri Pirko >> * Copyright (c) 2014-2015 Scott Feldman >> * >> * This program is free software; you can redistribute it and/or modify >> @@ -16,9 +16,56 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> >> +void switchdev_trans_item_enqueue(struct switchdev_trans *trans, >> + void *data, void (*destructor)(void const *), >> + struct switchdev_trans_item *tritem) >> +{ >> + tritem->data = data; >> + tritem->destructor = destructor; >> + list_add_tail(&tritem->list, &trans->item_list); >> +} >> +EXPORT_SYMBOL_GPL(switchdev_trans_item_enqueue); >> + >> +static struct switchdev_trans_item * >> +__switchdev_trans_item_dequeue(struct switchdev_trans *trans) >> +{ >> + struct switchdev_trans_item *tritem; >> + >> + if (list_empty(&trans->item_list)) >> + return NULL; >> + tritem = list_first_entry(&trans->item_list, >> + struct switchdev_trans_item, list); >> + list_del(&tritem->list); >> + return tritem; >> +} >> + >> +void *switchdev_trans_item_dequeue(struct switchdev_trans *trans) >> +{ >> + struct switchdev_trans_item *tritem; >> + >> + tritem = __switchdev_trans_item_dequeue(trans); >> + BUG_ON(!tritem); >> + return tritem->data; >> +} >> +EXPORT_SYMBOL_GPL(switchdev_trans_item_dequeue); > >Please add header comment block for these EXPORT_SYMBOL_GPL funcs. Right, will do.