diff options
| author | Ben Pfaff <blp@nicira.com> | 2011-01-10 13:12:12 -0800 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2011-01-27 21:08:36 -0800 |
| commit | b0ec0f279ea4537cb421eba807254aba8f1971f2 (patch) | |
| tree | a75fc9103d901333f548d8838854d19db86a9eeb /lib/dpif-provider.h | |
| parent | 856081f683d3e7d5b5fa07af4233d285eb205c47 (diff) | |
| download | openvswitch-b0ec0f279ea4537cb421eba807254aba8f1971f2.tar.gz | |
datapath: Change listing ports to use an iterator concept.
One of the goals for Open vSwitch is to decouple kernel and userspace
software, so that either one can be upgraded or rolled back independent of
the other. To do this in full generality, it must be possible to add new
features to the kernel vport layer without changing userspace software. In
turn, that means that the odp_port structure must become variable-length.
This does not, however, fit in well with the ODP_PORT_LIST ioctl in its
current form, because that would require userspace to know how much space
to allocate for each port in advance, or to allocate as much space as
could possibly be needed. Neither choice is very attractive.
This commit prepares for a different solution, by replacing ODP_PORT_LIST
by a new ioctl ODP_VPORT_DUMP that retrieves information about a single
vport from the datapath on each call. It is much cleaner to allocate the
maximum amount of space for a single vport than to do so for possibly a
large number of vports.
It would be faster to retrieve a number of vports in batch instead of just
one at a time, but that will naturally happen later when the kernel
datapath interface is changed to use Netlink, so this patch does not bother
with it.
The Netlink version won't need to take the starting port number from
userspace, since Netlink sockets can keep track of that state as part
of their "dump" feature.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'lib/dpif-provider.h')
| -rw-r--r-- | lib/dpif-provider.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h index bb7b2a87e..649a49279 100644 --- a/lib/dpif-provider.h +++ b/lib/dpif-provider.h @@ -153,11 +153,24 @@ struct dpif_class { int (*port_query_by_name)(const struct dpif *dpif, const char *devname, struct odp_port *port); - /* Stores in 'ports' information about up to 'n' ports attached to 'dpif', - * in no particular order. Returns the number of ports attached to 'dpif' - * (not the number stored), if successful, otherwise a negative errno - * value. */ - int (*port_list)(const struct dpif *dpif, struct odp_port *ports, int n); + /* Attempts to begin dumping the ports in a dpif. On success, returns 0 + * and initializes '*statep' with any data needed for iteration. On + * failure, returns a positive errno value. */ + int (*port_dump_start)(const struct dpif *dpif, void **statep); + + /* Attempts to retrieve another port from 'dpif' for 'state', which was + * initialized by a successful call to the 'port_dump_start' function for + * 'dpif'. On success, stores a new odp_port into 'port' and returns 0. + * Returns EOF if the end of the port table has been reached, or a positive + * errno value on error. This function will not be called again once it + * returns nonzero once for a given iteration (but the 'port_dump_done' + * function will be called afterward). */ + int (*port_dump_next)(const struct dpif *dpif, void *state, + struct odp_port *port); + + /* Releases resources from 'dpif' for 'state', which was initialized by a + * successful call to the 'port_dump_start' function for 'dpif'. */ + int (*port_dump_done)(const struct dpif *dpif, void *state); /* Polls for changes in the set of ports in 'dpif'. If the set of ports in * 'dpif' has changed, then this function should do one of the |
