summaryrefslogtreecommitdiff
path: root/datapath
diff options
context:
space:
mode:
authorThomas Graf <tgraf@noironetworks.com>2014-09-23 16:02:35 +0200
committerPravin B Shelar <pshelar@nicira.com>2014-09-23 14:47:58 -0700
commitf1f60b858337898035fe892d4d82d9d187f4ad6f (patch)
treee4ac21b9a23751043f0e3048ed3cd631f0a5f186 /datapath
parentb2a23c4ea70a18dd088f041ed6bb75ba59f2b6b5 (diff)
downloadopenvswitch-f1f60b858337898035fe892d4d82d9d187f4ad6f.tar.gz
datapath: Constify various function arguments
Help produce better optimized code. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Diffstat (limited to 'datapath')
-rw-r--r--datapath/actions.c9
-rw-r--r--datapath/datapath.c21
-rw-r--r--datapath/datapath.h7
-rw-r--r--datapath/flow.c2
-rw-r--r--datapath/flow.h8
-rw-r--r--datapath/flow_netlink.c4
-rw-r--r--datapath/flow_table.c14
-rw-r--r--datapath/flow_table.h8
-rw-r--r--datapath/vport-geneve.c2
-rw-r--r--datapath/vport-netdev.c2
-rw-r--r--datapath/vport.c8
-rw-r--r--datapath/vport.h6
12 files changed, 47 insertions, 44 deletions
diff --git a/datapath/actions.c b/datapath/actions.c
index c3f9427c5..b527cb655 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -71,7 +71,7 @@ static void action_fifo_init(struct action_fifo *fifo)
fifo->tail = 0;
}
-static bool action_fifo_is_empty(struct action_fifo *fifo)
+static bool action_fifo_is_empty(const struct action_fifo *fifo)
{
return (fifo->head == fifo->tail);
}
@@ -94,7 +94,7 @@ static struct deferred_action *action_fifo_put(struct action_fifo *fifo)
/* Return queue entry if fifo is not full */
static struct deferred_action *add_deferred_actions(struct sk_buff *skb,
- struct sw_flow_key *key,
+ const struct sw_flow_key *key,
const struct nlattr *attr)
{
struct action_fifo *fifo;
@@ -116,7 +116,7 @@ static void invalidate_flow_key(struct sw_flow_key *key)
key->eth.type = htons(0);
}
-static bool is_flow_key_valid(struct sw_flow_key *key)
+static bool is_flow_key_valid(const struct sw_flow_key *key)
{
return !!key->eth.type;
}
@@ -956,7 +956,8 @@ static void process_deferred_actions(struct datapath *dp)
/* Execute a list of actions against 'skb'. */
int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
- struct sw_flow_key *key, struct sw_flow_actions *acts)
+ struct sw_flow_key *key,
+ const struct sw_flow_actions *acts)
{
int level = this_cpu_read(exec_actions_level);
int err;
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 9a3c0520b..45e7c5673 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -135,9 +135,10 @@ int lockdep_ovsl_is_held(void)
#endif
static int queue_gso_packets(struct datapath *dp, struct sk_buff *,
- struct sw_flow_key *, const struct dp_upcall_info *);
+ const struct sw_flow_key *,
+ const struct dp_upcall_info *);
static int queue_userspace_packet(struct datapath *dp, struct sk_buff *,
- struct sw_flow_key *key,
+ const struct sw_flow_key *key,
const struct dp_upcall_info *);
/* Must be called with rcu_read_lock. */
@@ -175,7 +176,7 @@ const char *ovs_dp_name(const struct datapath *dp)
return vport->ops->get_name(vport);
}
-static int get_dpifindex(struct datapath *dp)
+static int get_dpifindex(const struct datapath *dp)
{
struct vport *local;
int ifindex;
@@ -300,7 +301,7 @@ out:
}
int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
- struct sw_flow_key *key,
+ const struct sw_flow_key *key,
const struct dp_upcall_info *upcall_info)
{
struct dp_stats_percpu *stats;
@@ -331,7 +332,7 @@ err:
}
static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
- struct sw_flow_key *key,
+ const struct sw_flow_key *key,
const struct dp_upcall_info *upcall_info)
{
unsigned short gso_type = skb_shinfo(skb)->gso_type;
@@ -399,7 +400,7 @@ static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
}
static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
- struct sw_flow_key *key,
+ const struct sw_flow_key *key,
const struct dp_upcall_info *upcall_info)
{
struct ovs_header *upcall;
@@ -635,7 +636,7 @@ static struct genl_family dp_packet_genl_family = {
.n_ops = ARRAY_SIZE(dp_packet_genl_ops),
};
-static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats,
+static void get_dp_stats(const struct datapath *dp, struct ovs_dp_stats *stats,
struct ovs_dp_megaflow_stats *mega_stats)
{
int i;
@@ -1356,7 +1357,7 @@ static struct sk_buff *ovs_dp_cmd_alloc_info(struct genl_info *info)
/* Called with rcu_read_lock or ovs_mutex. */
static struct datapath *lookup_datapath(struct net *net,
- struct ovs_header *ovs_header,
+ const struct ovs_header *ovs_header,
struct nlattr *a[OVS_DP_ATTR_MAX + 1])
{
struct datapath *dp;
@@ -1384,7 +1385,7 @@ static void ovs_dp_reset_user_features(struct sk_buff *skb, struct genl_info *in
dp->user_features = 0;
}
-static void ovs_dp_change(struct datapath *dp, struct nlattr **a)
+static void ovs_dp_change(struct datapath *dp, struct nlattr *a[])
{
if (a[OVS_DP_ATTR_USER_FEATURES])
dp->user_features = nla_get_u32(a[OVS_DP_ATTR_USER_FEATURES]);
@@ -1745,7 +1746,7 @@ struct sk_buff *ovs_vport_cmd_build_info(struct vport *vport, u32 portid,
/* Called with ovs_mutex or RCU read lock. */
static struct vport *lookup_vport(struct net *net,
- struct ovs_header *ovs_header,
+ const struct ovs_header *ovs_header,
struct nlattr *a[OVS_VPORT_ATTR_MAX + 1])
{
struct datapath *dp;
diff --git a/datapath/datapath.h b/datapath/datapath.h
index b30a9a4a1..d236cf43c 100644
--- a/datapath/datapath.h
+++ b/datapath/datapath.h
@@ -152,7 +152,7 @@ int lockdep_ovsl_is_held(void);
#define rcu_dereference_ovsl(p) \
rcu_dereference_check(p, lockdep_ovsl_is_held())
-static inline struct net *ovs_dp_get_net(struct datapath *dp)
+static inline struct net *ovs_dp_get_net(const struct datapath *dp)
{
return read_pnet(&dp->net);
}
@@ -189,14 +189,15 @@ extern struct genl_multicast_group ovs_dp_vport_multicast_group;
void ovs_dp_process_packet(struct sk_buff *, struct sw_flow_key *key);
void ovs_dp_detach_port(struct vport *);
int ovs_dp_upcall(struct datapath *, struct sk_buff *,
- struct sw_flow_key *, const struct dp_upcall_info *);
+ const struct sw_flow_key *, const struct dp_upcall_info *);
const char *ovs_dp_name(const struct datapath *dp);
struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 portid, u32 seq,
u8 cmd);
int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
- struct sw_flow_key *key, struct sw_flow_actions *acts);
+ struct sw_flow_key *key,
+ const struct sw_flow_actions *acts);
void ovs_dp_notify_wq(struct work_struct *work);
int action_fifos_init(void);
diff --git a/datapath/flow.c b/datapath/flow.c
index eb7df1376..a69f4e134 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -66,7 +66,7 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies)
#define TCP_FLAGS_BE16(tp) (*(__be16 *)&tcp_flag_word(tp) & htons(0x0FFF))
void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
- struct sk_buff *skb)
+ const struct sk_buff *skb)
{
struct flow_stats *stats;
int node = numa_node_id();
diff --git a/datapath/flow.h b/datapath/flow.h
index 44ed10df4..eb9246ae6 100644
--- a/datapath/flow.h
+++ b/datapath/flow.h
@@ -55,7 +55,7 @@ struct ovs_key_ipv4_tunnel {
struct ovs_tunnel_info {
struct ovs_key_ipv4_tunnel tunnel;
- struct geneve_opt *options;
+ const struct geneve_opt *options;
u8 options_len;
};
@@ -75,7 +75,7 @@ static inline void __ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info,
__be16 tp_dst,
__be64 tun_id,
__be16 tun_flags,
- struct geneve_opt *opts,
+ const struct geneve_opt *opts,
u8 opts_len)
{
tun_info->tunnel.tun_id = tun_id;
@@ -108,7 +108,7 @@ static inline void ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info,
__be16 tp_dst,
__be64 tun_id,
__be16 tun_flags,
- struct geneve_opt *opts,
+ const struct geneve_opt *opts,
u8 opts_len)
{
__ovs_flow_tun_info_init(tun_info, iph->saddr, iph->daddr,
@@ -246,7 +246,7 @@ struct arp_eth_header {
} __packed;
void ovs_flow_stats_update(struct sw_flow *, __be16 tcp_flags,
- struct sk_buff *);
+ const struct sk_buff *);
void ovs_flow_stats_get(const struct sw_flow *, struct ovs_flow_stats *,
unsigned long *used, __be16 *tcp_flags);
void ovs_flow_stats_clear(struct sw_flow *);
diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c
index 6c748410a..a3f34f154 100644
--- a/datapath/flow_netlink.c
+++ b/datapath/flow_netlink.c
@@ -1580,9 +1580,9 @@ static int validate_and_copy_set_tun(const struct nlattr *attr,
* everything else will go away after flow setup. We can append
* it to tun_info and then point there.
*/
- tun_info->options = (struct geneve_opt *)(tun_info + 1);
- memcpy(tun_info->options, GENEVE_OPTS(&key, key.tun_opts_len),
+ memcpy((tun_info + 1), GENEVE_OPTS(&key, key.tun_opts_len),
key.tun_opts_len);
+ tun_info->options = (struct geneve_opt *)(tun_info + 1);
} else {
tun_info->options = NULL;
}
diff --git a/datapath/flow_table.c b/datapath/flow_table.c
index 10bf83030..4efef1347 100644
--- a/datapath/flow_table.c
+++ b/datapath/flow_table.c
@@ -114,7 +114,7 @@ err:
return ERR_PTR(-ENOMEM);
}
-int ovs_flow_tbl_count(struct flow_table *table)
+int ovs_flow_tbl_count(const struct flow_table *table)
{
return table->count;
}
@@ -482,7 +482,7 @@ static bool flow_cmp_masked_key(const struct sw_flow *flow,
}
bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow,
- struct sw_flow_match *match)
+ const struct sw_flow_match *match)
{
struct sw_flow_key *key = match->key;
int key_start = flow_key_start(key);
@@ -493,7 +493,7 @@ bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow,
static struct sw_flow *masked_flow_lookup(struct table_instance *ti,
const struct sw_flow_key *unmasked,
- struct sw_flow_mask *mask,
+ const struct sw_flow_mask *mask,
u32 *n_mask_hit)
{
struct sw_flow *flow;
@@ -521,7 +521,7 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti,
*/
static struct sw_flow *flow_lookup(struct flow_table *tbl,
struct table_instance *ti,
- struct mask_array *ma,
+ const struct mask_array *ma,
const struct sw_flow_key *key,
u32 *n_mask_hit,
u32 *index)
@@ -627,7 +627,7 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl,
}
struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
- struct sw_flow_match *match)
+ const struct sw_flow_match *match)
{
struct mask_array *ma = ovsl_dereference(tbl->mask_array);
int i;
@@ -761,7 +761,7 @@ static struct sw_flow_mask *flow_mask_find(const struct flow_table *tbl,
/* Add 'mask' into the mask list, if it is not already there. */
static int flow_mask_insert(struct flow_table *tbl, struct sw_flow *flow,
- struct sw_flow_mask *new)
+ const struct sw_flow_mask *new)
{
struct sw_flow_mask *mask;
@@ -814,7 +814,7 @@ static int flow_mask_insert(struct flow_table *tbl, struct sw_flow *flow,
/* Must be called with OVS mutex held. */
int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
- struct sw_flow_mask *mask)
+ const struct sw_flow_mask *mask)
{
struct table_instance *new_ti = NULL;
struct table_instance *ti;
diff --git a/datapath/flow_table.h b/datapath/flow_table.h
index a05d36a7d..9eb4af928 100644
--- a/datapath/flow_table.h
+++ b/datapath/flow_table.h
@@ -73,12 +73,12 @@ struct sw_flow *ovs_flow_alloc(void);
void ovs_flow_free(struct sw_flow *, bool deferred);
int ovs_flow_tbl_init(struct flow_table *);
-int ovs_flow_tbl_count(struct flow_table *table);
+int ovs_flow_tbl_count(const struct flow_table *table);
void ovs_flow_tbl_destroy(struct flow_table *table);
int ovs_flow_tbl_flush(struct flow_table *flow_table);
int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
- struct sw_flow_mask *mask);
+ const struct sw_flow_mask *mask);
void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
int ovs_flow_tbl_num_masks(const struct flow_table *table);
struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
@@ -90,10 +90,10 @@ struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *,
struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
const struct sw_flow_key *);
struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *,
- struct sw_flow_match *match);
+ const struct sw_flow_match *match);
bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow,
- struct sw_flow_match *match);
+ const struct sw_flow_match *match);
void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
const struct sw_flow_mask *mask);
diff --git a/datapath/vport-geneve.c b/datapath/vport-geneve.c
index 6ed1e1f0a..d79e27bd5 100644
--- a/datapath/vport-geneve.c
+++ b/datapath/vport-geneve.c
@@ -117,7 +117,7 @@ static void tunnel_id_to_vni(__be64 tun_id, __u8 *vni)
}
/* Convert 24 bit VNI to 64 bit tunnel ID. */
-static __be64 vni_to_tunnel_id(__u8 *vni)
+static __be64 vni_to_tunnel_id(const __u8 *vni)
{
#ifdef __BIG_ENDIAN
return (vni[0] << 16) | (vni[1] << 8) | vni[2];
diff --git a/datapath/vport-netdev.c b/datapath/vport-netdev.c
index a00276b00..c76349128 100644
--- a/datapath/vport-netdev.c
+++ b/datapath/vport-netdev.c
@@ -85,7 +85,7 @@ static struct sk_buff *netdev_frame_hook(struct net_bridge_port *p,
#error
#endif
-static struct net_device *get_dpdev(struct datapath *dp)
+static struct net_device *get_dpdev(const struct datapath *dp)
{
struct vport *local;
diff --git a/datapath/vport.c b/datapath/vport.c
index de9bc23c3..bda643e0d 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -82,7 +82,7 @@ void ovs_vport_exit(void)
kfree(dev_table);
}
-static struct hlist_head *hash_bucket(struct net *net, const char *name)
+static struct hlist_head *hash_bucket(const struct net *net, const char *name)
{
unsigned int hash = jhash(name, strlen(name), (unsigned long) net);
return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
@@ -95,7 +95,7 @@ static struct hlist_head *hash_bucket(struct net *net, const char *name)
*
* Must be called with ovs or RCU read lock.
*/
-struct vport *ovs_vport_locate(struct net *net, const char *name)
+struct vport *ovs_vport_locate(const struct net *net, const char *name)
{
struct hlist_head *bucket = hash_bucket(net, name);
struct vport *vport;
@@ -352,7 +352,7 @@ static void vport_portids_destroy_rcu_cb(struct rcu_head *rcu)
*
* Must be called with ovs_mutex.
*/
-int ovs_vport_set_upcall_portids(struct vport *vport, struct nlattr *ids)
+int ovs_vport_set_upcall_portids(struct vport *vport, const struct nlattr *ids)
{
struct vport_portids *old, *vport_portids;
@@ -443,7 +443,7 @@ u32 ovs_vport_find_upcall_portid(const struct vport *p, struct sk_buff *skb)
* called compute_ip_summed() to initialize the checksumming fields.
*/
void ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
- struct ovs_tunnel_info *tun_info)
+ const struct ovs_tunnel_info *tun_info)
{
struct pcpu_sw_netstats *stats;
struct sw_flow_key key;
diff --git a/datapath/vport.h b/datapath/vport.h
index a0cf3dd0f..82d9a78fd 100644
--- a/datapath/vport.h
+++ b/datapath/vport.h
@@ -43,14 +43,14 @@ void ovs_vport_exit(void);
struct vport *ovs_vport_add(const struct vport_parms *);
void ovs_vport_del(struct vport *);
-struct vport *ovs_vport_locate(struct net *net, const char *name);
+struct vport *ovs_vport_locate(const struct net *net, const char *name);
void ovs_vport_get_stats(struct vport *, struct ovs_vport_stats *);
int ovs_vport_set_options(struct vport *, struct nlattr *options);
int ovs_vport_get_options(const struct vport *, struct sk_buff *);
-int ovs_vport_set_upcall_portids(struct vport *, struct nlattr *pids);
+int ovs_vport_set_upcall_portids(struct vport *, const struct nlattr *pids);
int ovs_vport_get_upcall_portids(const struct vport *, struct sk_buff *);
u32 ovs_vport_find_upcall_portid(const struct vport *, struct sk_buff *);
@@ -218,7 +218,7 @@ static inline struct vport *vport_from_priv(void *priv)
}
void ovs_vport_receive(struct vport *, struct sk_buff *,
- struct ovs_tunnel_info *);
+ const struct ovs_tunnel_info *);
/* List of statically compiled vport implementations. Don't forget to also
* add yours to the list at the top of vport.c. */