developer | 58aa068 | 2023-09-18 14:02:26 +0800 | [diff] [blame] | 1 | From 842a435bd21807447504a387e5ebb8071b0db93f Mon Sep 17 00:00:00 2001 |
| 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Mon, 18 Sep 2023 11:11:41 +0800 |
| 4 | Subject: [PATCH 14/22] flow-offload-ovs-support |
| 5 | |
| 6 | --- |
| 7 | net/openvswitch/vport-internal_dev.c | 46 ++++++++++++++++++++++++++++ |
| 8 | 1 file changed, 46 insertions(+) |
| 9 | |
| 10 | diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c |
| 11 | index 58a7b83..8475727 100644 |
developer | 267a3de | 2022-07-15 15:48:26 +0800 | [diff] [blame] | 12 | --- a/net/openvswitch/vport-internal_dev.c |
| 13 | +++ b/net/openvswitch/vport-internal_dev.c |
developer | 58aa068 | 2023-09-18 14:02:26 +0800 | [diff] [blame] | 14 | @@ -113,12 +113,58 @@ internal_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) |
developer | 267a3de | 2022-07-15 15:48:26 +0800 | [diff] [blame] | 15 | } |
| 16 | } |
developer | 58aa068 | 2023-09-18 14:02:26 +0800 | [diff] [blame] | 17 | |
developer | 267a3de | 2022-07-15 15:48:26 +0800 | [diff] [blame] | 18 | +static int internal_dev_fill_forward_path(struct net_device_path_ctx *ctx, struct net_device_path *path) |
| 19 | +{ |
| 20 | + struct vport *vport; |
| 21 | + int i; |
| 22 | + struct table_instance *ti; |
| 23 | + struct datapath *dp; |
| 24 | + struct sw_flow_key *key; |
| 25 | + struct sw_flow_actions *sf_acts; |
| 26 | + struct nlattr *a; |
| 27 | + int rem; |
| 28 | + |
| 29 | + vport = ovs_internal_dev_get_vport(ctx->dev); |
| 30 | + dp = vport->dp; |
| 31 | + ti = rcu_dereference_ovsl(dp->table.ti); |
| 32 | + |
| 33 | + for (i = 0; i < ti->n_buckets; i++) { |
| 34 | + struct sw_flow *flow; |
| 35 | + struct hlist_head *head = &ti->buckets[i]; |
| 36 | + struct hlist_node *n; |
| 37 | + |
| 38 | + hlist_for_each_entry_safe(flow, n, head, flow_table.node[ti->node_ver]) { |
| 39 | + key = &flow->key; |
| 40 | + |
| 41 | + if((!memcmp(ctx->dev->dev_addr, key->eth.dst, ETH_ALEN)) && (!memcmp(ctx->daddr, key->eth.src, ETH_ALEN))){ |
| 42 | + sf_acts = rcu_dereference_ovsl(flow->sf_acts); |
| 43 | + for (a = sf_acts->actions, rem = sf_acts->actions_len; rem > 0; |
| 44 | + a = nla_next(a, &rem)) { |
| 45 | + if(nla_type(a) == OVS_ACTION_ATTR_OUTPUT){ |
| 46 | + vport = ovs_vport_rcu(dp, key->phy.in_port); |
| 47 | + goto out; |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | +out: |
| 55 | + |
| 56 | + path->type = DEV_PATH_BRIDGE; |
| 57 | + path->dev = ctx->dev; |
| 58 | + ctx->dev = vport->dev; |
| 59 | + |
| 60 | + return 0; |
| 61 | +} |
| 62 | + |
| 63 | static const struct net_device_ops internal_dev_netdev_ops = { |
| 64 | .ndo_open = internal_dev_open, |
| 65 | .ndo_stop = internal_dev_stop, |
| 66 | .ndo_start_xmit = internal_dev_xmit, |
| 67 | .ndo_set_mac_address = eth_mac_addr, |
| 68 | .ndo_get_stats64 = internal_get_stats, |
| 69 | + .ndo_fill_forward_path = internal_dev_fill_forward_path, |
| 70 | }; |
developer | 58aa068 | 2023-09-18 14:02:26 +0800 | [diff] [blame] | 71 | |
developer | ee39bcf | 2023-06-16 08:03:30 +0800 | [diff] [blame] | 72 | static struct rtnl_link_ops internal_dev_link_ops __read_mostly = { |
developer | 58aa068 | 2023-09-18 14:02:26 +0800 | [diff] [blame] | 73 | -- |
| 74 | 2.18.0 |
| 75 | |