- local_bh_disable();
- stats = per_cpu_ptr(dp->stats_percpu, smp_processor_id());
-
- write_seqcount_begin(&stats->seqlock);
- (*(u64 *)((u8 *)stats + stats_counter_off))++;
- write_seqcount_end(&stats->seqlock);
-
- local_bh_enable();
-}
-
-static void copy_and_csum_skb(struct sk_buff *skb, void *to)
-{
- u16 csum_start, csum_offset;
- __wsum csum;
-
- get_skb_csum_pointers(skb, &csum_start, &csum_offset);
- csum_start -= skb_headroom(skb);
-
- skb_copy_bits(skb, 0, to, csum_start);
-
- csum = skb_copy_and_csum_bits(skb, csum_start, to + csum_start,
- skb->len - csum_start, 0);
- *(__sum16 *)(to + csum_start + csum_offset) = csum_fold(csum);
-}
-
-static struct genl_family dp_packet_genl_family = {
- .id = GENL_ID_GENERATE,
- .hdrsize = sizeof(struct ovs_header),
- .name = OVS_PACKET_FAMILY,
- .version = 1,
- .maxattr = OVS_PACKET_ATTR_MAX
-};
-
-/* Generic Netlink multicast groups for upcalls.
- *
- * We really want three unique multicast groups per datapath, but we can't even
- * get one, because genl_register_mc_group() takes genl_lock, which is also
- * held during Generic Netlink message processing, so trying to acquire
- * multicast groups during OVS_DP_NEW processing deadlocks. Instead, we
- * preallocate a few groups and use them round-robin for datapaths. Collision
- * isn't fatal--multicast listeners should check that the family is the one
- * that they want and discard others--but it wastes time and memory to receive
- * unwanted messages.
- */
-#define PACKET_N_MC_GROUPS 16
-static struct genl_multicast_group packet_mc_groups[PACKET_N_MC_GROUPS];
-
-static u32 packet_mc_group(struct datapath *dp, u8 cmd)
-{
- u32 idx;
- BUILD_BUG_ON_NOT_POWER_OF_2(PACKET_N_MC_GROUPS);
-
- idx = jhash_2words(dp->dp_ifindex, cmd, 0) & (PACKET_N_MC_GROUPS - 1);
- return packet_mc_groups[idx].id;