@@ -1553,7 +1553,8 @@ netdev_bsd_update_flags(struct netdev *netdev_, enum netdev_flags off,
netdev_bsd_rxq_wait, \
netdev_bsd_rxq_drain, \
\
- NO_OFFLOAD_API \
+ NO_OFFLOAD_API, \
+ NULL /* get_block_id */ \
}
const struct netdev_class netdev_bsd_class =
@@ -3957,7 +3957,8 @@ unlock:
RXQ_RECV, \
NULL, /* rx_wait */ \
NULL, /* rxq_drain */ \
- NO_OFFLOAD_API \
+ NO_OFFLOAD_API, \
+ NULL /* get_block_id */ \
}
static const struct netdev_class dpdk_class =
@@ -1464,7 +1464,8 @@ netdev_dummy_update_flags(struct netdev *netdev_,
netdev_dummy_rxq_wait, \
netdev_dummy_rxq_drain, \
\
- NO_OFFLOAD_API \
+ NO_OFFLOAD_API, \
+ NULL /* get_block_id */ \
}
static const struct netdev_class dummy_class =
@@ -3115,7 +3115,8 @@ exit:
netdev_linux_rxq_wait, \
netdev_linux_rxq_drain, \
\
- FLOW_OFFLOAD_API \
+ FLOW_OFFLOAD_API, \
+ NULL /* get_block_id */ \
}
const struct netdev_class netdev_linux_class =
@@ -870,6 +870,10 @@ struct netdev_class {
/* Initializies the netdev flow api.
* Return 0 if successful, otherwise returns a positive errno value. */
int (*init_flow_api)(struct netdev *);
+
+ /* Get a block_id from the netdev.
+ * Returns the block_id or 0 if none exists for netdev. */
+ uint32_t (*get_block_id)(struct netdev *);
};
int netdev_register_provider(const struct netdev_class *);
@@ -304,6 +304,16 @@ get_prio_for_tc_flower(struct tc_flower *flower)
return new_data->prio;
}
+static uint32_t
+get_block_id_from_netdev(struct netdev *netdev)
+{
+ if (block_support) {
+ return netdev_get_block_id(netdev);
+ }
+
+ return 0;
+}
+
int
netdev_tc_flow_flush(struct netdev *netdev)
{
@@ -316,6 +326,8 @@ netdev_tc_flow_flush(struct netdev *netdev)
return -ifindex;
}
+ block_id = get_block_id_from_netdev(netdev);
+
return tc_flush(ifindex, block_id);
}
@@ -334,6 +346,7 @@ netdev_tc_flow_dump_create(struct netdev *netdev,
return -ifindex;
}
+ block_id = get_block_id_from_netdev(netdev);
dump = xzalloc(sizeof *dump);
dump->nl_dump = xzalloc(sizeof *dump->nl_dump);
dump->netdev = netdev_ref(netdev);
@@ -1098,6 +1111,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match,
}
}
+ block_id = get_block_id_from_netdev(netdev);
handle = get_ufid_tc_mapping(ufid, &prio, NULL);
if (handle && prio) {
VLOG_DBG_RL(&rl, "updating old handle: %d prio: %d", handle, prio);
@@ -1157,6 +1171,7 @@ netdev_tc_flow_get(struct netdev *netdev OVS_UNUSED,
VLOG_DBG_RL(&rl, "flow get (dev %s prio %d handle %d)",
netdev_get_name(dev), prio, handle);
+ block_id = get_block_id_from_netdev(netdev);
err = tc_get_flower(ifindex, prio, handle, &flower, block_id);
netdev_close(dev);
if (err) {
@@ -1200,6 +1215,8 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED,
return -ifindex;
}
+ block_id = get_block_id_from_netdev(netdev);
+
if (stats) {
memset(stats, 0, sizeof *stats);
if (!tc_get_flower(ifindex, prio, handle, &flower, block_id)) {
@@ -1289,6 +1306,7 @@ netdev_tc_init_flow_api(struct netdev *netdev)
ovsthread_once_done(&block_once);
}
+ block_id = get_block_id_from_netdev(netdev);
error = tc_add_del_ingress_qdisc(ifindex, true, block_id);
if (error && error != EEXIST) {
@@ -1050,7 +1050,8 @@ netdev_vport_get_ifindex(const struct netdev *netdev_)
NULL, /* rx_wait */ \
NULL, /* rx_drain */ \
\
- NETDEV_FLOW_OFFLOAD_API
+ NETDEV_FLOW_OFFLOAD_API, \
+ NULL /* get_block_id */
#define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER, \
@@ -2225,6 +2225,16 @@ netdev_init_flow_api(struct netdev *netdev)
: EOPNOTSUPP);
}
+uint32_t
+netdev_get_block_id(struct netdev *netdev)
+{
+ const struct netdev_class *class = netdev->netdev_class;
+
+ return (class->get_block_id
+ ? class->get_block_id(netdev)
+ : 0);
+}
+
bool
netdev_is_flow_api_enabled(void)
{
@@ -220,6 +220,7 @@ int netdev_flow_get(struct netdev *, struct match *, struct nlattr **actions,
int netdev_flow_del(struct netdev *, const ovs_u128 *,
struct dpif_flow_stats *);
int netdev_init_flow_api(struct netdev *);
+uint32_t netdev_get_block_id(struct netdev *);
bool netdev_is_flow_api_enabled(void);
void netdev_set_flow_api_enabled(const struct smap *ovs_other_config);