mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
dpif: Save added ports in a port map for netdev flow api use
To use netdev flow offloading api, dpifs needs to iterate over added ports. This addition inserts the added dpif ports in a hash map, The map will also be used to translate dpif ports to netdevs. Signed-off-by: Paul Blakey <paulb@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Acked-by: Flavio Leitner <fbl@sysclose.org> Signed-off-by: Simon Horman <simon.horman@netronome.com>
This commit is contained in:
committed by
Simon Horman
parent
691d20cbdc
commit
32b77c316d
32
lib/dpif.c
32
lib/dpif.c
@@ -355,7 +355,28 @@ do_open(const char *name, const char *type, bool create, struct dpif **dpifp)
|
||||
error = registered_class->dpif_class->open(registered_class->dpif_class,
|
||||
name, create, &dpif);
|
||||
if (!error) {
|
||||
struct dpif_port_dump port_dump;
|
||||
struct dpif_port dpif_port;
|
||||
|
||||
ovs_assert(dpif->dpif_class == registered_class->dpif_class);
|
||||
|
||||
DPIF_PORT_FOR_EACH(&dpif_port, &port_dump, dpif) {
|
||||
struct netdev *netdev;
|
||||
int err;
|
||||
|
||||
if (!strcmp(dpif_port.type, "internal")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
err = netdev_open(dpif_port.name, dpif_port.type, &netdev);
|
||||
|
||||
if (!err) {
|
||||
netdev_ports_insert(netdev, DPIF_HMAP_KEY(dpif), &dpif_port);
|
||||
netdev_close(netdev);
|
||||
} else {
|
||||
VLOG_WARN("could not open netdev %s type %s", name, type);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dp_class_unref(registered_class);
|
||||
}
|
||||
@@ -548,6 +569,15 @@ dpif_port_add(struct dpif *dpif, struct netdev *netdev, odp_port_t *port_nop)
|
||||
if (!error) {
|
||||
VLOG_DBG_RL(&dpmsg_rl, "%s: added %s as port %"PRIu32,
|
||||
dpif_name(dpif), netdev_name, port_no);
|
||||
|
||||
if (strcmp(netdev_get_type(netdev), "internal")) {
|
||||
struct dpif_port dpif_port;
|
||||
|
||||
dpif_port.type = CONST_CAST(char *, netdev_get_type(netdev));
|
||||
dpif_port.name = CONST_CAST(char *, netdev_name);
|
||||
dpif_port.port_no = port_no;
|
||||
netdev_ports_insert(netdev, DPIF_HMAP_KEY(dpif), &dpif_port);
|
||||
}
|
||||
} else {
|
||||
VLOG_WARN_RL(&error_rl, "%s: failed to add %s as port: %s",
|
||||
dpif_name(dpif), netdev_name, ovs_strerror(error));
|
||||
@@ -572,6 +602,8 @@ dpif_port_del(struct dpif *dpif, odp_port_t port_no)
|
||||
if (!error) {
|
||||
VLOG_DBG_RL(&dpmsg_rl, "%s: port_del(%"PRIu32")",
|
||||
dpif_name(dpif), port_no);
|
||||
|
||||
netdev_ports_remove(port_no, DPIF_HMAP_KEY(dpif));
|
||||
} else {
|
||||
log_operation(dpif, "port_del", error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user