]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xen-netfront: move rx_gso_checksum_fixup into netfront_stats
authorJoao Martins <joao.m.martins@oracle.com>
Fri, 12 May 2017 08:46:43 +0000 (09:46 +0100)
committerJoao Martins <joao.m.martins@oracle.com>
Wed, 31 May 2017 21:52:01 +0000 (22:52 +0100)
It allows us to remove one atomic op (on a very rare case) and
further allow easier adding of new statistics.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Shannon Nelson <shannon.nelson@oracle.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Orabug: 26107942

drivers/net/xen-netfront.c

index 8709ddddd9e4f4ab9b80713e8a466528de6090d3..197308ec75bf60288928d954e520cc5bb289b9d5 100644 (file)
@@ -95,6 +95,8 @@ struct netfront_stats {
        u64                     packets;
        u64                     bytes;
        struct u64_stats_sync   syncp;
+
+       u64     rx_gso_checksum_fixup;
 };
 
 struct netfront_info;
@@ -181,8 +183,6 @@ struct netfront_info {
        /* Statistics */
        struct netfront_stats __percpu *rx_stats;
        struct netfront_stats __percpu *tx_stats;
-
-       atomic_t rx_gso_checksum_fixup;
 };
 
 struct netfront_rx_info {
@@ -935,7 +935,7 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
        return cons;
 }
 
-static int checksum_setup(struct net_device *dev, struct sk_buff *skb)
+static int checksum_setup(struct netfront_info *info, struct sk_buff *skb)
 {
        bool recalculate_partial_csum = false;
 
@@ -946,8 +946,9 @@ static int checksum_setup(struct net_device *dev, struct sk_buff *skb)
         * recalculate the partial checksum.
         */
        if (skb->ip_summed != CHECKSUM_PARTIAL && skb_is_gso(skb)) {
-               struct netfront_info *np = netdev_priv(dev);
-               atomic_inc(&np->rx_gso_checksum_fixup);
+               struct netfront_stats *rx_stats = this_cpu_ptr(info->rx_stats);
+
+               rx_stats->rx_gso_checksum_fixup++;
                skb->ip_summed = CHECKSUM_PARTIAL;
                recalculate_partial_csum = true;
        }
@@ -976,7 +977,7 @@ static int handle_incoming_queue(struct netfront_queue *queue,
                skb->protocol = eth_type_trans(skb, queue->info->netdev);
                skb_reset_network_header(skb);
 
-               if (checksum_setup(queue->info->netdev, skb)) {
+               if (checksum_setup(queue->info, skb)) {
                        kfree_skb(skb);
                        packets_dropped++;
                        queue->info->netdev->stats.rx_errors++;
@@ -2277,7 +2278,7 @@ static const struct xennet_stat {
 } xennet_stats[] = {
        {
                "rx_gso_checksum_fixup",
-               offsetof(struct netfront_info, rx_gso_checksum_fixup)
+               offsetof(struct netfront_stats, rx_gso_checksum_fixup)
        },
 };
 
@@ -2294,11 +2295,21 @@ static int xennet_get_sset_count(struct net_device *dev, int string_set)
 static void xennet_get_ethtool_stats(struct net_device *dev,
                                     struct ethtool_stats *stats, u64 * data)
 {
-       void *np = netdev_priv(dev);
-       int i;
+       struct netfront_info *np = netdev_priv(dev);
+       struct netfront_stats tot_stats;
+       void *temp = &tot_stats;
+       int i, cpu;
+
+       memset(temp, 0, sizeof(tot_stats));
+
+       for_each_possible_cpu(cpu) {
+               struct netfront_stats *s = per_cpu_ptr(np->rx_stats, cpu);
+
+               tot_stats.rx_gso_checksum_fixup += s->rx_gso_checksum_fixup;
+       }
 
        for (i = 0; i < ARRAY_SIZE(xennet_stats); i++)
-               data[i] = atomic_read((atomic_t *)(np + xennet_stats[i].offset));
+               data[i] = *((u64 *)(temp + xennet_stats[i].offset));
 }
 
 static void xennet_get_strings(struct net_device *dev, u32 stringset, u8 * data)