History

switchdev: Remove unused transaction item queue

There are no more in tree users of the switchdev_trans_item_{dequeue,enqueue} or switchdev_trans_item structure in the kernel since commit 00fc0c51e35b ("rocker: Change world_ops API and implementation to be switchdev independant"). Remove this unused code and update the documentation accordingly since.

Florian Fainelli committed 7 years ago

Commit 91cf8ec1 parent 9bfc4453 files · +2 −129Browse files

Unified · Split

3 files
  1. Documentation/networking/switchdev.txt +0 −19
  2. include/net/switchdev.h +0 −12
  3. net/switchdev/switchdev.c +2 −98
Documentation/networking/switchdev.txt+0−19
@@ -371,22 +371,3 @@ The driver can monitor for updates to arp_tbl using the netevent notifier · 370 unmodified lines
371371 NETEVENT_NEIGH_UPDATE. The device can be programmed with resolved nexthops
372372 for the routes as arp_tbl updates. The driver implements ndo_neigh_destroy
373373 to know when arp_tbl neighbor entries are purged from the port.
374−
375−Transaction item queue
376−^^^^^^^^^^^^^^^^^^^^^^
377−
378−For switchdev ops attr_set and obj_add, there is a 2 phase transaction model
379−used. First phase is to "prepare" anything needed, including various checks,
380−memory allocation, etc. The goal is to handle the stuff that is not unlikely
381−to fail here. The second phase is to "commit" the actual changes.
382−
383−Switchdev provides an infrastructure for sharing items (for example memory
384−allocations) between the two phases.
385−
386−The object created by a driver in "prepare" phase and it is queued up by:
387−switchdev_trans_item_enqueue()
388−During the "commit" phase, the driver gets the object by:
389−switchdev_trans_item_dequeue()
390−
391−If a transaction is aborted during "prepare" phase, switchdev code will handle
392−cleanup of the queued-up objects.
include/net/switchdev.h+0−12
@@ -20,14 +20,7 @@ · 19 unmodified lines
2020 #define SWITCHDEV_F_SKIP_EOPNOTSUPP BIT(1)
2121 #define SWITCHDEV_F_DEFER BIT(2)
2222
23−struct switchdev_trans_item {
24− struct list_head list;
25− void *data;
26− void (*destructor)(const void *data);
27−};
28−
2923 struct switchdev_trans {
30− struct list_head item_list;
3124 bool ph_prepare;
3225 };
3326
@@ -105,11 +98,6 @@ struct switchdev_obj_port_mdb { · 71 unmodified lines
10598 #define SWITCHDEV_OBJ_PORT_MDB(OBJ) \
10699 container_of((OBJ), struct switchdev_obj_port_mdb, obj)
107100
108−void switchdev_trans_item_enqueue(struct switchdev_trans *trans,
109− void *data, void (*destructor)(void const *),
110− struct switchdev_trans_item *tritem);
111−void *switchdev_trans_item_dequeue(struct switchdev_trans *trans);
112−
113101 typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj);
114102
115103 enum switchdev_notifier_type {
net/switchdev/switchdev.c+2−98
@@ -23,78 +23,6 @@ · 22 unmodified lines
2323 #include <linux/rtnetlink.h>
2424 #include <net/switchdev.h>
2525
26−/**
27− * switchdev_trans_item_enqueue - Enqueue data item to transaction queue
28− *
29− * @trans: transaction
30− * @data: pointer to data being queued
31− * @destructor: data destructor
32− * @tritem: transaction item being queued
33− *
34− * Enqeueue data item to transaction queue. tritem is typically placed in
35− * cointainter pointed at by data pointer. Destructor is called on
36− * transaction abort and after successful commit phase in case
37− * the caller did not dequeue the item before.
38− */
39−void switchdev_trans_item_enqueue(struct switchdev_trans *trans,
40− void *data, void (*destructor)(void const *),
41− struct switchdev_trans_item *tritem)
42−{
43− tritem->data = data;
44− tritem->destructor = destructor;
45− list_add_tail(&tritem->list, &trans->item_list);
46−}
47−EXPORT_SYMBOL_GPL(switchdev_trans_item_enqueue);
48−
49−static struct switchdev_trans_item *
50−__switchdev_trans_item_dequeue(struct switchdev_trans *trans)
51−{
52− struct switchdev_trans_item *tritem;
53−
54− if (list_empty(&trans->item_list))
55− return NULL;
56− tritem = list_first_entry(&trans->item_list,
57− struct switchdev_trans_item, list);
58− list_del(&tritem->list);
59− return tritem;
60−}
61−
62−/**
63− * switchdev_trans_item_dequeue - Dequeue data item from transaction queue
64− *
65− * @trans: transaction
66− */
67−void *switchdev_trans_item_dequeue(struct switchdev_trans *trans)
68−{
69− struct switchdev_trans_item *tritem;
70−
71− tritem = __switchdev_trans_item_dequeue(trans);
72− BUG_ON(!tritem);
73− return tritem->data;
74−}
75−EXPORT_SYMBOL_GPL(switchdev_trans_item_dequeue);
76−
77−static void switchdev_trans_init(struct switchdev_trans *trans)
78−{
79− INIT_LIST_HEAD(&trans->item_list);
80−}
81−
82−static void switchdev_trans_items_destroy(struct switchdev_trans *trans)
83−{
84− struct switchdev_trans_item *tritem;
85−
86− while ((tritem = __switchdev_trans_item_dequeue(trans)))
87− tritem->destructor(tritem->data);
88−}
89−
90−static void switchdev_trans_items_warn_destroy(struct net_device *dev,
91− struct switchdev_trans *trans)
92−{
93− WARN(!list_empty(&trans->item_list), "%s: transaction item queue is not empty.\n",
94− dev->name);
95− switchdev_trans_items_destroy(trans);
96−}
97−
9826 static LIST_HEAD(deferred);
9927 static DEFINE_SPINLOCK(deferred_lock);
10028
@@ -208,8 +136,6 @@ static int switchdev_port_attr_set_now(struct net_device *dev, · 107 unmodified lines
208136 struct switchdev_trans trans;
209137 int err;
210138
211− switchdev_trans_init(&trans);
212−
213139 /* Phase I: prepare for attr set. Driver/device should fail
214140 * here if there are going to be issues in the commit phase,
215141 * such as lack of resources or support. The driver/device
@@ -220,17 +146,8 @@ static int switchdev_port_attr_set_now(struct net_device *dev, · 4 unmodified lines
220146 trans.ph_prepare = true;
221147 err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, dev, attr,
222148 &trans);
223− if (err) {
224− /* Prepare phase failed: abort the transaction. Any
225− * resources reserved in the prepare phase are
226− * released.
227− */
228−
229− if (err != -EOPNOTSUPP)
230− switchdev_trans_items_destroy(&trans);
231−
149+ if (err)
232150 return err;
233− }
234151
235152 /* Phase II: commit attr set. This cannot fail as a fault
236153 * of driver/device. If it does, it's a bug in the driver/device
@@ -242,7 +159,6 @@ static int switchdev_port_attr_set_now(struct net_device *dev, · 5 unmodified lines
242159 &trans);
243160 WARN(err, "%s: Commit of attribute (id=%d) failed.\n",
244161 dev->name, attr->id);
245− switchdev_trans_items_warn_destroy(dev, &trans);
246162
247163 return err;
248164 }
@@ -341,8 +257,6 @@ static int switchdev_port_obj_add_now(struct net_device *dev, · 92 unmodified lines
341257
342258 ASSERT_RTNL();
343259
344− switchdev_trans_init(&trans);
345−
346260 /* Phase I: prepare for obj add. Driver/device should fail
347261 * here if there are going to be issues in the commit phase,
348262 * such as lack of resources or support. The driver/device
@@ -353,17 +267,8 @@ static int switchdev_port_obj_add_now(struct net_device *dev, · 4 unmodified lines
353267 trans.ph_prepare = true;
354268 err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_ADD,
355269 dev, obj, &trans, extack);
356− if (err) {
357− /* Prepare phase failed: abort the transaction. Any
358− * resources reserved in the prepare phase are
359− * released.
360− */
361−
362− if (err != -EOPNOTSUPP)
363− switchdev_trans_items_destroy(&trans);
364−
270+ if (err)
365271 return err;
366− }
367272
368273 /* Phase II: commit obj add. This cannot fail as a fault
369274 * of driver/device. If it does, it's a bug in the driver/device
@@ -374,7 +279,6 @@ static int switchdev_port_obj_add_now(struct net_device *dev, · 4 unmodified lines
374279 err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_ADD,
375280 dev, obj, &trans, extack);
376281 WARN(err, "%s: Commit of object (id=%d) failed.\n", dev->name, obj->id);
377− switchdev_trans_items_warn_destroy(dev, &trans);
378282
379283 return err;
380284 }