qlcnic: fix eswitch stats
authorAmit Kumar Salecha <amit.salecha@qlogic.com>
Mon, 4 Oct 2010 04:20:10 +0000 (04:20 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Oct 2010 05:46:49 +0000 (22:46 -0700)
Some of the counters are not implemented in fw.
Fw return NOT AVAILABLE VALUE as (0xffffffffffffffff).
Adding these counters, result in invalid value.

Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/qlcnic/qlcnic.h
drivers/net/qlcnic/qlcnic_ctx.c

index 714ddf461d7310dd7cdd8284f1697e1a92c3f62a..4667463d5523f8f1b4f8f59243fc4c4478ea2f21 100644 (file)
@@ -1169,6 +1169,18 @@ struct qlcnic_esw_func_cfg {
 #define QLCNIC_STATS_ESWITCH           2
 #define QLCNIC_QUERY_RX_COUNTER                0
 #define QLCNIC_QUERY_TX_COUNTER                1
+#define QLCNIC_ESW_STATS_NOT_AVAIL     0xffffffffffffffffULL
+
+#define QLCNIC_ADD_ESW_STATS(VAL1, VAL2)\
+do {   \
+       if (((VAL1) == QLCNIC_ESW_STATS_NOT_AVAIL) && \
+           ((VAL2) != QLCNIC_ESW_STATS_NOT_AVAIL)) \
+               (VAL1) = (VAL2); \
+       else if (((VAL1) != QLCNIC_ESW_STATS_NOT_AVAIL) && \
+                ((VAL2) != QLCNIC_ESW_STATS_NOT_AVAIL)) \
+                       (VAL1) += (VAL2); \
+} while (0)
+
 struct __qlcnic_esw_statistics {
        __le16 context_id;
        __le16 version;
index 95a821e0b66ff82cbb7332f2204c6f161247467b..a4c4d091739ef1c73f9ce18e84ed04c1a6fd2f5c 100644 (file)
@@ -1016,7 +1016,14 @@ int qlcnic_get_eswitch_stats(struct qlcnic_adapter *adapter, const u8 eswitch,
        if (adapter->npars == NULL)
                return -EIO;
 
-       memset(esw_stats, 0, sizeof(struct __qlcnic_esw_statistics));
+       memset(esw_stats, 0, sizeof(u64));
+       esw_stats->unicast_frames = QLCNIC_ESW_STATS_NOT_AVAIL;
+       esw_stats->multicast_frames = QLCNIC_ESW_STATS_NOT_AVAIL;
+       esw_stats->broadcast_frames = QLCNIC_ESW_STATS_NOT_AVAIL;
+       esw_stats->dropped_frames = QLCNIC_ESW_STATS_NOT_AVAIL;
+       esw_stats->errors = QLCNIC_ESW_STATS_NOT_AVAIL;
+       esw_stats->local_frames = QLCNIC_ESW_STATS_NOT_AVAIL;
+       esw_stats->numbytes = QLCNIC_ESW_STATS_NOT_AVAIL;
        esw_stats->context_id = eswitch;
 
        for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
@@ -1029,14 +1036,20 @@ int qlcnic_get_eswitch_stats(struct qlcnic_adapter *adapter, const u8 eswitch,
 
                esw_stats->size = port_stats.size;
                esw_stats->version = port_stats.version;
-               esw_stats->unicast_frames += port_stats.unicast_frames;
-               esw_stats->multicast_frames += port_stats.multicast_frames;
-               esw_stats->broadcast_frames += port_stats.broadcast_frames;
-               esw_stats->dropped_frames += port_stats.dropped_frames;
-               esw_stats->errors += port_stats.errors;
-               esw_stats->local_frames += port_stats.local_frames;
-               esw_stats->numbytes += port_stats.numbytes;
-
+               QLCNIC_ADD_ESW_STATS(esw_stats->unicast_frames,
+                                               port_stats.unicast_frames);
+               QLCNIC_ADD_ESW_STATS(esw_stats->multicast_frames,
+                                               port_stats.multicast_frames);
+               QLCNIC_ADD_ESW_STATS(esw_stats->broadcast_frames,
+                                               port_stats.broadcast_frames);
+               QLCNIC_ADD_ESW_STATS(esw_stats->dropped_frames,
+                                               port_stats.dropped_frames);
+               QLCNIC_ADD_ESW_STATS(esw_stats->errors,
+                                               port_stats.errors);
+               QLCNIC_ADD_ESW_STATS(esw_stats->local_frames,
+                                               port_stats.local_frames);
+               QLCNIC_ADD_ESW_STATS(esw_stats->numbytes,
+                                               port_stats.numbytes);
                ret = 0;
        }
        return ret;