[ovs-dev] [PATCH v3 5/9] dpif-netdev: record rx queue id for the upcall
Yuanhan Liu
yliu at fridaylinux.org
Tue Sep 26 05:36:35 UTC 2017
From: Shachar Beiser <shacharbe at mellanox.com>
For the DPDK flow offload, which basically just binds a MARK action to
a flow, the MARK is required to be used together with a QUEUE action for
the most NICs I'm aware of. The QUEUE action then needs a queue index,
which is not given in the flow content.
Here we record the rx queue while recieving the pkts to solve above issue.
Co-authored-by: Yuanhan Liu <yliu at fridaylinux.org>
Signed-off-by: Shachar Beiser <shacharbe at mellanox.com>
Signed-off-by: Yuanhan Liu <yliu at fridaylinux.org>
---
lib/dp-packet.h | 1 +
lib/dpif-netdev.c | 19 +++++++++++--------
lib/netdev.c | 1 +
lib/netdev.h | 1 +
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index a7a062f..479a734 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -709,6 +709,7 @@ enum { NETDEV_MAX_BURST = 32 }; /* Maximum number packets in a batch. */
struct dp_packet_batch {
size_t count;
bool trunc; /* true if the batch needs truncate. */
+ int rxq;
struct dp_packet *packets[NETDEV_MAX_BURST];
};
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 5c33c74..1a70af6 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -2550,7 +2550,7 @@ static void
try_netdev_flow_put(struct dp_netdev_pmd_thread *pmd, odp_port_t in_port,
struct dp_netdev_flow *flow, struct match *match,
const ovs_u128 *ufid, const struct nlattr *actions,
- size_t actions_len)
+ size_t actions_len, int rxq)
{
struct offload_info info;
struct dp_netdev_port *port;
@@ -2562,6 +2562,7 @@ try_netdev_flow_put(struct dp_netdev_pmd_thread *pmd, odp_port_t in_port,
if (!port) {
return;
}
+ info.rxq = rxq;
if (modification) {
info.flow_mark = flow->mark;
@@ -2598,7 +2599,8 @@ try_netdev_flow_put(struct dp_netdev_pmd_thread *pmd, odp_port_t in_port,
static struct dp_netdev_flow *
dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd,
struct match *match, const ovs_u128 *ufid,
- const struct nlattr *actions, size_t actions_len)
+ const struct nlattr *actions, size_t actions_len,
+ int rxq)
OVS_REQUIRES(pmd->flow_mutex)
{
struct dp_netdev_flow *flow;
@@ -2647,7 +2649,7 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd,
dp_netdev_flow_hash(&flow->ufid));
try_netdev_flow_put(pmd, in_port, flow, match, ufid,
- actions, actions_len);
+ actions, actions_len, rxq);
if (OVS_UNLIKELY(!VLOG_DROP_DBG((&upcall_rl)))) {
struct ds ds = DS_EMPTY_INITIALIZER;
@@ -2717,7 +2719,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd,
if (put->flags & DPIF_FP_CREATE) {
if (cmap_count(&pmd->flow_table) < MAX_FLOWS) {
dp_netdev_flow_add(pmd, match, ufid, put->actions,
- put->actions_len);
+ put->actions_len, -1);
error = 0;
} else {
error = EFBIG;
@@ -2738,7 +2740,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd,
ovsrcu_set(&netdev_flow->actions, new_actions);
try_netdev_flow_put(pmd, in_port, netdev_flow, match, ufid,
- put->actions, put->actions_len);
+ put->actions, put->actions_len, -1);
if (stats) {
get_dpif_flow_stats(netdev_flow, stats);
@@ -5119,7 +5121,7 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd,
struct dp_packet *packet,
const struct netdev_flow_key *key,
struct ofpbuf *actions, struct ofpbuf *put_actions,
- int *lost_cnt, long long now)
+ int *lost_cnt, long long now, int rxq)
{
struct ofpbuf *add_actions;
struct dp_packet_batch b;
@@ -5175,7 +5177,8 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd,
if (OVS_LIKELY(!netdev_flow)) {
netdev_flow = dp_netdev_flow_add(pmd, &match, &ufid,
add_actions->data,
- add_actions->size);
+ add_actions->size,
+ rxq);
}
ovs_mutex_unlock(&pmd->flow_mutex);
emc_probabilistic_insert(pmd, key, netdev_flow);
@@ -5245,7 +5248,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
miss_cnt++;
handle_packet_upcall(pmd, packets[i], &keys[i], &actions,
- &put_actions, &lost_cnt, now);
+ &put_actions, &lost_cnt, now, packets_->rxq);
}
ofpbuf_uninit(&actions);
diff --git a/lib/netdev.c b/lib/netdev.c
index b4e570b..c9b7019 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -700,6 +700,7 @@ netdev_rxq_recv(struct netdev_rxq *rx, struct dp_packet_batch *batch)
retval = rx->netdev->netdev_class->rxq_recv(rx, batch);
if (!retval) {
+ batch->rxq = rx->queue_id;
COVERAGE_INC(netdev_received);
} else {
batch->count = 0;
diff --git a/lib/netdev.h b/lib/netdev.h
index 2003165..28ad39d 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -194,6 +194,7 @@ struct offload_info {
* it will be in the pkt meta data.
*/
uint32_t flow_mark;
+ int rxq;
};
struct dpif_class;
struct netdev_flow_dump;
--
2.7.4
More information about the dev
mailing list