Lines Matching refs:dp
124 static int queue_gso_packets(struct datapath *dp, struct sk_buff *,
128 static int queue_userspace_packet(struct datapath *dp, struct sk_buff *,
134 const char *ovs_dp_name(const struct datapath *dp) in ovs_dp_name() argument
136 struct vport *vport = ovs_vport_ovsl_rcu(dp, OVSP_LOCAL); in ovs_dp_name()
140 static int get_dpifindex(const struct datapath *dp) in get_dpifindex() argument
147 local = ovs_vport_rcu(dp, OVSP_LOCAL); in get_dpifindex()
160 struct datapath *dp = container_of(rcu, struct datapath, rcu); in destroy_dp_rcu() local
162 ovs_flow_tbl_destroy(&dp->table); in destroy_dp_rcu()
163 free_percpu(dp->stats_percpu); in destroy_dp_rcu()
164 kfree(dp->ports); in destroy_dp_rcu()
165 ovs_meters_exit(dp); in destroy_dp_rcu()
166 kfree(dp); in destroy_dp_rcu()
169 static struct hlist_head *vport_hash_bucket(const struct datapath *dp, in vport_hash_bucket() argument
172 return &dp->ports[port_no & (DP_VPORT_HASH_BUCKETS - 1)]; in vport_hash_bucket()
176 struct vport *ovs_lookup_vport(const struct datapath *dp, u16 port_no) in ovs_lookup_vport() argument
181 head = vport_hash_bucket(dp, port_no); in ovs_lookup_vport()
196 struct datapath *dp = parms->dp; in new_vport() local
197 struct hlist_head *head = vport_hash_bucket(dp, vport->port_no); in new_vport()
219 struct datapath *dp = p->dp; in ovs_dp_process_packet() local
227 stats = this_cpu_ptr(dp->stats_percpu); in ovs_dp_process_packet()
230 flow = ovs_flow_tbl_lookup_stats(&dp->table, key, &n_mask_hit); in ovs_dp_process_packet()
238 error = ovs_dp_upcall(dp, skb, key, &upcall, 0); in ovs_dp_process_packet()
249 error = ovs_execute_actions(dp, skb, sf_acts, key); in ovs_dp_process_packet()
252 ovs_dp_name(dp), error); in ovs_dp_process_packet()
264 int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb, in ovs_dp_upcall() argument
278 err = queue_userspace_packet(dp, skb, key, upcall_info, cutlen); in ovs_dp_upcall()
280 err = queue_gso_packets(dp, skb, key, upcall_info, cutlen); in ovs_dp_upcall()
287 stats = this_cpu_ptr(dp->stats_percpu); in ovs_dp_upcall()
296 static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, in queue_gso_packets() argument
328 err = queue_userspace_packet(dp, skb, key, upcall_info, cutlen); in queue_gso_packets()
373 static void pad_packet(struct datapath *dp, struct sk_buff *skb) in pad_packet() argument
375 if (!(dp->user_features & OVS_DP_F_UNALIGNED)) { in pad_packet()
383 static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, in queue_userspace_packet() argument
396 dp_ifindex = get_dpifindex(dp); in queue_userspace_packet()
426 if (dp->user_features & OVS_DP_F_UNALIGNED) in queue_userspace_packet()
493 pad_packet(dp, user_skb); in queue_userspace_packet()
503 pad_packet(dp, user_skb); in queue_userspace_packet()
519 pad_packet(dp, user_skb); in queue_userspace_packet()
523 err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid); in queue_userspace_packet()
542 struct datapath *dp; in ovs_packet_cmd_execute() local
591 dp = get_dp_rcu(net, ovs_header->dp_ifindex); in ovs_packet_cmd_execute()
593 if (!dp) in ovs_packet_cmd_execute()
596 input_vport = ovs_vport_rcu(dp, flow->key.phy.in_port); in ovs_packet_cmd_execute()
598 input_vport = ovs_vport_rcu(dp, OVSP_LOCAL); in ovs_packet_cmd_execute()
608 err = ovs_execute_actions(dp, packet, sf_acts, &flow->key); in ovs_packet_cmd_execute()
654 static void get_dp_stats(const struct datapath *dp, struct ovs_dp_stats *stats, in get_dp_stats() argument
661 stats->n_flows = ovs_flow_tbl_count(&dp->table); in get_dp_stats()
662 mega_stats->n_masks = ovs_flow_tbl_num_masks(&dp->table); in get_dp_stats()
671 percpu_stats = per_cpu_ptr(dp->stats_percpu, i); in get_dp_stats()
904 struct datapath *dp; in ovs_flow_cmd_new() local
966 dp = get_dp(net, ovs_header->dp_ifindex); in ovs_flow_cmd_new()
967 if (unlikely(!dp)) { in ovs_flow_cmd_new()
974 flow = ovs_flow_tbl_lookup_ufid(&dp->table, &new_flow->id); in ovs_flow_cmd_new()
976 flow = ovs_flow_tbl_lookup(&dp->table, &new_flow->key); in ovs_flow_cmd_new()
981 error = ovs_flow_tbl_insert(&dp->table, new_flow, &mask); in ovs_flow_cmd_new()
1016 flow = ovs_flow_tbl_lookup_exact(&dp->table, in ovs_flow_cmd_new()
1143 struct datapath *dp; in ovs_flow_cmd_set() local
1175 dp = get_dp(net, ovs_header->dp_ifindex); in ovs_flow_cmd_set()
1176 if (unlikely(!dp)) { in ovs_flow_cmd_set()
1182 flow = ovs_flow_tbl_lookup_ufid(&dp->table, &sfid); in ovs_flow_cmd_set()
1184 flow = ovs_flow_tbl_lookup_exact(&dp->table, &match); in ovs_flow_cmd_set()
1245 struct datapath *dp; in ovs_flow_cmd_get() local
1267 dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex); in ovs_flow_cmd_get()
1268 if (!dp) { in ovs_flow_cmd_get()
1274 flow = ovs_flow_tbl_lookup_ufid(&dp->table, &ufid); in ovs_flow_cmd_get()
1276 flow = ovs_flow_tbl_lookup_exact(&dp->table, &match); in ovs_flow_cmd_get()
1304 struct datapath *dp; in ovs_flow_cmd_del() local
1322 dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex); in ovs_flow_cmd_del()
1323 if (unlikely(!dp)) { in ovs_flow_cmd_del()
1329 err = ovs_flow_tbl_flush(&dp->table); in ovs_flow_cmd_del()
1334 flow = ovs_flow_tbl_lookup_ufid(&dp->table, &ufid); in ovs_flow_cmd_del()
1336 flow = ovs_flow_tbl_lookup_exact(&dp->table, &match); in ovs_flow_cmd_del()
1342 ovs_flow_tbl_remove(&dp->table, flow); in ovs_flow_cmd_del()
1380 struct datapath *dp; in ovs_flow_cmd_dump() local
1391 dp = get_dp_rcu(sock_net(skb->sk), ovs_header->dp_ifindex); in ovs_flow_cmd_dump()
1392 if (!dp) { in ovs_flow_cmd_dump()
1397 ti = rcu_dereference(dp->table.ti); in ovs_flow_cmd_dump()
1483 static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, in ovs_dp_cmd_fill_info() argument
1496 ovs_header->dp_ifindex = get_dpifindex(dp); in ovs_dp_cmd_fill_info()
1498 err = nla_put_string(skb, OVS_DP_ATTR_NAME, ovs_dp_name(dp)); in ovs_dp_cmd_fill_info()
1502 get_dp_stats(dp, &dp_stats, &dp_megaflow_stats); in ovs_dp_cmd_fill_info()
1512 if (nla_put_u32(skb, OVS_DP_ATTR_USER_FEATURES, dp->user_features)) in ovs_dp_cmd_fill_info()
1534 struct datapath *dp; in lookup_datapath() local
1537 dp = get_dp(net, ovs_header->dp_ifindex); in lookup_datapath()
1542 dp = vport && vport->port_no == OVSP_LOCAL ? vport->dp : NULL; in lookup_datapath()
1544 return dp ? dp : ERR_PTR(-ENODEV); in lookup_datapath()
1549 struct datapath *dp; in ovs_dp_reset_user_features() local
1551 dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs); in ovs_dp_reset_user_features()
1552 if (IS_ERR(dp)) in ovs_dp_reset_user_features()
1555 WARN(dp->user_features, "Dropping previously announced user features\n"); in ovs_dp_reset_user_features()
1556 dp->user_features = 0; in ovs_dp_reset_user_features()
1561 static int ovs_dp_change(struct datapath *dp, struct nlattr *a[]) in ovs_dp_change() argument
1579 dp->user_features = user_features; in ovs_dp_change()
1581 if (dp->user_features & OVS_DP_F_TC_RECIRC_SHARING) in ovs_dp_change()
1594 struct datapath *dp; in ovs_dp_cmd_new() local
1608 dp = kzalloc(sizeof(*dp), GFP_KERNEL); in ovs_dp_cmd_new()
1609 if (dp == NULL) in ovs_dp_cmd_new()
1612 ovs_dp_set_net(dp, sock_net(skb->sk)); in ovs_dp_cmd_new()
1615 err = ovs_flow_tbl_init(&dp->table); in ovs_dp_cmd_new()
1619 dp->stats_percpu = netdev_alloc_pcpu_stats(struct dp_stats_percpu); in ovs_dp_cmd_new()
1620 if (!dp->stats_percpu) { in ovs_dp_cmd_new()
1625 dp->ports = kmalloc_array(DP_VPORT_HASH_BUCKETS, in ovs_dp_cmd_new()
1628 if (!dp->ports) { in ovs_dp_cmd_new()
1634 INIT_HLIST_HEAD(&dp->ports[i]); in ovs_dp_cmd_new()
1636 err = ovs_meters_init(dp); in ovs_dp_cmd_new()
1644 parms.dp = dp; in ovs_dp_cmd_new()
1648 err = ovs_dp_change(dp, a); in ovs_dp_cmd_new()
1674 err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid, in ovs_dp_cmd_new()
1678 ovs_net = net_generic(ovs_dp_get_net(dp), ovs_net_id); in ovs_dp_cmd_new()
1679 list_add_tail_rcu(&dp->list_node, &ovs_net->dps); in ovs_dp_cmd_new()
1687 ovs_meters_exit(dp); in ovs_dp_cmd_new()
1689 kfree(dp->ports); in ovs_dp_cmd_new()
1691 free_percpu(dp->stats_percpu); in ovs_dp_cmd_new()
1693 ovs_flow_tbl_destroy(&dp->table); in ovs_dp_cmd_new()
1695 kfree(dp); in ovs_dp_cmd_new()
1703 static void __dp_destroy(struct datapath *dp) in __dp_destroy() argument
1711 hlist_for_each_entry_safe(vport, n, &dp->ports[i], dp_hash_node) in __dp_destroy()
1716 list_del_rcu(&dp->list_node); in __dp_destroy()
1721 ovs_dp_detach_port(ovs_vport_ovsl(dp, OVSP_LOCAL)); in __dp_destroy()
1724 call_rcu(&dp->rcu, destroy_dp_rcu); in __dp_destroy()
1730 struct datapath *dp; in ovs_dp_cmd_del() local
1738 dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs); in ovs_dp_cmd_del()
1739 err = PTR_ERR(dp); in ovs_dp_cmd_del()
1740 if (IS_ERR(dp)) in ovs_dp_cmd_del()
1743 err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid, in ovs_dp_cmd_del()
1747 __dp_destroy(dp); in ovs_dp_cmd_del()
1763 struct datapath *dp; in ovs_dp_cmd_set() local
1771 dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs); in ovs_dp_cmd_set()
1772 err = PTR_ERR(dp); in ovs_dp_cmd_set()
1773 if (IS_ERR(dp)) in ovs_dp_cmd_set()
1776 err = ovs_dp_change(dp, info->attrs); in ovs_dp_cmd_set()
1780 err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid, in ovs_dp_cmd_set()
1798 struct datapath *dp; in ovs_dp_cmd_get() local
1806 dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs); in ovs_dp_cmd_get()
1807 if (IS_ERR(dp)) { in ovs_dp_cmd_get()
1808 err = PTR_ERR(dp); in ovs_dp_cmd_get()
1811 err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid, in ovs_dp_cmd_get()
1827 struct datapath *dp; in ovs_dp_cmd_dump() local
1832 list_for_each_entry(dp, &ovs_net->dps, list_node) { in ovs_dp_cmd_dump()
1834 ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid, in ovs_dp_cmd_dump()
1906 ovs_header->dp_ifindex = get_dpifindex(vport->dp); in ovs_vport_cmd_fill_info()
1973 struct datapath *dp; in lookup_vport() local
1983 ovs_header->dp_ifindex != get_dpifindex(vport->dp)) in lookup_vport()
1992 dp = get_dp(net, ovs_header->dp_ifindex); in lookup_vport()
1993 if (!dp) in lookup_vport()
1996 vport = ovs_vport_ovsl_rcu(dp, port_no); in lookup_vport()
2005 static unsigned int ovs_get_max_headroom(struct datapath *dp) in ovs_get_max_headroom() argument
2013 hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) { in ovs_get_max_headroom()
2025 static void ovs_update_headroom(struct datapath *dp, unsigned int new_headroom) in ovs_update_headroom() argument
2030 dp->max_headroom = new_headroom; in ovs_update_headroom()
2032 hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) in ovs_update_headroom()
2043 struct datapath *dp; in ovs_vport_cmd_new() local
2065 dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex); in ovs_vport_cmd_new()
2067 if (!dp) in ovs_vport_cmd_new()
2071 vport = ovs_vport_ovsl(dp, port_no); in ovs_vport_cmd_new()
2081 vport = ovs_vport_ovsl(dp, port_no); in ovs_vport_cmd_new()
2090 parms.dp = dp; in ovs_vport_cmd_new()
2108 if (new_headroom > dp->max_headroom) in ovs_vport_cmd_new()
2109 ovs_update_headroom(dp, new_headroom); in ovs_vport_cmd_new()
2111 netdev_set_rx_headroom(vport->dev, dp->max_headroom); in ovs_vport_cmd_new()
2183 struct datapath *dp; in ovs_vport_cmd_del() local
2209 dp = vport->dp; in ovs_vport_cmd_del()
2210 if (netdev_get_fwd_headroom(vport->dev) == dp->max_headroom) in ovs_vport_cmd_del()
2217 new_headroom = ovs_get_max_headroom(dp); in ovs_vport_cmd_del()
2219 if (new_headroom < dp->max_headroom) in ovs_vport_cmd_del()
2220 ovs_update_headroom(dp, new_headroom); in ovs_vport_cmd_del()
2267 struct datapath *dp; in ovs_vport_cmd_dump() local
2272 dp = get_dp_rcu(sock_net(skb->sk), ovs_header->dp_ifindex); in ovs_vport_cmd_dump()
2273 if (!dp) { in ovs_vport_cmd_dump()
2281 hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) { in ovs_vport_cmd_dump()
2406 struct datapath *dp; in list_vports_from_net() local
2408 list_for_each_entry(dp, &ovs_net->dps, list_node) { in list_vports_from_net()
2414 hlist_for_each_entry(vport, &dp->ports[i], dp_hash_node) { in list_vports_from_net()
2427 struct datapath *dp, *dp_next; in ovs_exit_net() local
2435 list_for_each_entry_safe(dp, dp_next, &ovs_net->dps, list_node) in ovs_exit_net()
2436 __dp_destroy(dp); in ovs_exit_net()